OnixS C++ CME MDP Conflated UDP Handler  1.1.2
API documentation
SettingGroup.h
Go to the documentation of this file.
1 // Copyright Onix Solutions Limited [OnixS]. All rights reserved.
2 //
3 // This software owned by Onix Solutions Limited [OnixS] and is
4 // protected by copyright law and international copyright treaties.
5 //
6 // Access to and use of the software is governed by the terms of the applicable
7 // OnixS Software Services Agreement (the Agreement) and Customer end user license
8 // agreements granting a non-assignable, non-transferable and non-exclusive license
9 // to use the software for it's own data processing purposes under the terms defined
10 // in the Agreement.
11 //
12 // Except as otherwise granted within the terms of the Agreement, copying or
13 // reproduction of any part of this source code or associated reference material
14 // to any other location for further reproduction or redistribution, and any
15 // amendments to this copyright notice, are expressly prohibited.
16 //
17 // Any reproduction or redistribution for sale or hiring of the Software not in
18 // accordance with the terms of the Agreement is a violation of copyright law.
19 //
20 
21 #pragma once
22 
24 
26 
28 (
29  SettingGroup
30 );
31 
32 /// Represents a service controlling assignment
33 /// operations for the collections of settings.
36 {
37  /// Begins the setting assignment operation.
38  ///
39  /// May throw an exception if assignment
40  /// is not possible for the moment or is
41  /// prohibited for a setting or a group to
42  /// which the setting being updated belongs.
43  virtual
44  void
45  beginAssign(
46  const SettingGroup&,
47  const Char*) = 0;
48 
49  /// Accomplishes the setting assignment operation.
50  ///
51  /// The given member must be invoked after
52  /// successful invocation of the 'beginAssign'
53  /// member and before any other setting update.
54  virtual
55  void
56  endAssign() = 0;
57 };
58 
59 // Default attributes and functionality.
63 {
64  /// Implements base class interface.
65  void
67  const SettingGroup&,
68  const Char*)
69  {
70  }
71 
72  /// Implements base class interface.
73  void
75  {
76  }
77 
78  /// Returns instance of the
79  /// trivial assignment controller.
80  static
82  self()
83  {
84  static
86  trivial;
87 
88  return trivial;
89  }
90 };
91 
92 /// Scope guard to update setting in the safe way.
94 {
95  SettingAssignController& controller_;
96 
98  const SettingAssignGuard&);
99 
101  operator =(
102  const SettingAssignGuard&);
103 
104 public:
105  /// Initializes the guard for the given setting update.
107  SettingAssignController& controller,
108  const SettingGroup& group,
109  const Char* details)
110  : controller_(controller)
111  {
112  controller_.beginAssign(group, details);
113  }
114 
115  /// Accomplishes setting update.
117  {
118  controller_.endAssign();
119  }
120 };
121 
122 /// Base services for settings grouped by a certain criteria.
124 {
125  // Controller for the given group of settings.
126  SettingAssignController& controller_;
127 
128  SettingGroup(
129  const SettingGroup&);
130 
131  SettingGroup&
132  operator =(
133  const SettingGroup&);
134 
135 public:
136  /// Initializes the group of settings
137  /// with the given validation services.
140  controller = NULL)
141  : controller_
142  (
143  controller
144  ? *controller
146  self()
147  )
148  {
149  }
150 
151  /// Does actually nothing.
153  {
154  }
155 
156  /// Guarded assignment of the given
157  /// value to the given variable.
158  template
159  <
160  class Assignee,
161  class Value
162  >
163  void
165  const Char* description,
166  Assignee& assignee,
167  Value value) const
168  {
169  const
171  guard(
172  controller_,
173  *this,
174  description);
175  {
176  assignee = value;
177  }
178  }
179 
180  /// Guarded invoke of the given routine
181  /// which assumes complex assignment or
182  /// update for the given object from the
183  /// given value.
184  template
185  <
186  class Assignee,
187  class Value,
188  class AssignRoutine
189  >
190  void
192  const Char* description,
193  AssignRoutine routine,
194  Assignee& assignee,
195  const Value& value) const
196  {
197  const
199  guard(
200  controller_,
201  *this,
202  description);
203  {
204  (assignee.*routine)(value);
205  }
206  }
207 
208  /// Returns an instance
209  /// representing a null group.
211  static
212  const SettingGroup&
214  {
215  static
216  const
217  SettingGroup
218  nullInstance;
219 
220  return nullInstance;
221  }
222 };
223 
224 /// Checks the two groups for equality.
225 inline
226 bool
228  const SettingGroup& left,
229  const SettingGroup& right)
230 {
231  return (&left == &right);
232 }
233 
234 /// Checks the two groups for inequality.
235 inline
236 bool
238  const SettingGroup& left,
239  const SettingGroup& right)
240 {
241  return (&left != &right);
242 }
243 
bool operator==(const SettingGroup &left, const SettingGroup &right)
Checks the two groups for equality.
Definition: SettingGroup.h:227
void endAssign()
Implements base class interface.
Definition: SettingGroup.h:74
SettingGroup(SettingAssignController *controller=NULL)
Definition: SettingGroup.h:138
Scope guard to update setting in the safe way.
Definition: SettingGroup.h:93
~SettingAssignGuard()
Accomplishes setting update.
Definition: SettingGroup.h:116
#define ONIXS_CONFLATEDUDP_LTWT_EXPORTED
Definition: Bootstrap.h:103
void controlAssignment(const Char *description, AssignRoutine routine, Assignee &assignee, const Value &value) const
Definition: SettingGroup.h:191
static ONIXS_CONFLATEDUDP_EXPORTED const SettingGroup & null()
Definition: SettingGroup.h:213
#define ONIXS_CONFLATEDUDP_LTWT_CLASS_DECL(name)
Definition: Bootstrap.h:107
void beginAssign(const SettingGroup &, const Char *)
Implements base class interface.
Definition: SettingGroup.h:66
char Char
Character type alias.
Definition: String.h:36
bool operator!=(const SettingGroup &left, const SettingGroup &right)
Checks the two groups for inequality.
Definition: SettingGroup.h:237
~SettingGroup()
Does actually nothing.
Definition: SettingGroup.h:152
#define ONIXS_CONFLATEDUDP_EXPORTED_STRUCT
Definition: Bootstrap.h:59
Base services for settings grouped by a certain criteria.
Definition: SettingGroup.h:123
SettingAssignGuard(SettingAssignController &controller, const SettingGroup &group, const Char *details)
Initializes the guard for the given setting update.
Definition: SettingGroup.h:106
#define ONIXS_CONFLATEDUDP_NAMESPACE_END
Definition: Bootstrap.h:157
virtual void beginAssign(const SettingGroup &, const Char *)=0
bool value(Number &number, const MultiContainer &container, Tag tag)
#define ONIXS_CONFLATEDUDP_LTWT_CLASS
Definition: Bootstrap.h:95
#define ONIXS_CONFLATEDUDP_NAMESPACE_BEGIN
Definition: Bootstrap.h:153
void controlAssignment(const Char *description, Assignee &assignee, Value value) const
Definition: SettingGroup.h:164