LRAUV  revA
ElementURI.h
Go to the documentation of this file.
1 
10 #ifndef ELEMENTURI_H_
11 #define ELEMENTURI_H_
12 
13 #include "data/BinaryDataType.h"
14 #include "data/BlobType.h"
15 #include "io/InStream.h"
16 #include "io/OutStream.h"
17 #include "units/Units.h"
18 #include "utils/Str.h"
19 
27 class ElementURI : public Str
28 {
29 public:
30 
32  {
39  };
40 
41  static const unsigned short NUM_CODES;
42  static const unsigned short NO_CODE;
43  static const unsigned short SELF_CODE;
44  static const Unit UNSPECIFIED_UNIT;
45 
46  ElementURI( const char* component, const char* elementName, ElementType = BASE_ELEMENT, const Unit& unit = UNSPECIFIED_UNIT, BinaryDataType binaryType = NO_TYPE,
47  BlobType blobType = NOT_BLOB, unsigned short dimension1 = 0,
48  unsigned short dimension2 = 0, unsigned short dimension3 = 0 );
49 
50  ElementURI( const Str& component, const char* elementName, ElementType = BASE_ELEMENT, const Unit& unit = UNSPECIFIED_UNIT, BinaryDataType binaryType = NO_TYPE,
51  BlobType blobType = NOT_BLOB, unsigned short dimension1 = 0,
52  unsigned short dimension2 = 0, unsigned short dimension3 = 0 );
53 
54  ElementURI( const Str& component, const char* elementName, const char* description, ElementType = BASE_ELEMENT, const Unit& unit = UNSPECIFIED_UNIT, BinaryDataType binaryType = NO_TYPE,
55  BlobType blobType = NOT_BLOB, unsigned short dimension1 = 0,
56  unsigned short dimension2 = 0, unsigned short dimension3 = 0 );
57 
58  ElementURI( const Str &component, const Str &elementName, ElementType = BASE_ELEMENT, const Unit& unit = UNSPECIFIED_UNIT, BinaryDataType binaryType = NO_TYPE,
59  BlobType blobType = NOT_BLOB, unsigned short dimension1 = 0,
60  unsigned short dimension2 = 0, unsigned short dimension3 = 0 );
61 
62  ElementURI( const ElementURI& src );
63 
65  virtual ~ElementURI()
66  {}
67 
68  // Cast
69  operator const Str& ( void ) const
70  {
71  return *this;
72  }
73 
74  unsigned short getCode() const
75  {
76  return code_;
77  }
78 
79  void setCode( unsigned short code )
80  {
81  code_ = code;
82  }
83 
84  virtual bool isUniversal() const
85  {
86  return false;
87  }
88 
89  const Unit& getUnit() const
90  {
91  return unit_;
92  }
93 
95  {
97  }
98 
100  {
101  return elementType_;
102  }
103 
104  static ElementURI* FindURI( const Str& str );
105 
106  static ElementURI* FindURI( const char* str );
107 
108  unsigned int write( OutStream& outStream );
109 
110  static ElementURI* Read( InStream& inStream );
111 
112  static ElementURI Create( const Str &component, const Str &elementName );
113 
114  const Str buildURI( const char* component, const char* elementName );
115 
116  const Str buildURI( const Str &component, const char* elementName );
117 
118  const Str buildURI( const Str &component, const Str &elementName );
119 
121  {
122  return blobType_;
123  }
124 
125  int getDimensions() const
126  {
127  return dimension3_ > 0 ? 3 : ( dimension2_ > 0 ? 2 : ( dimension1_ > 0 ? 1 :
128  ( blobType_ == NOT_BLOB ? 0 : 1 ) ) );
129  }
130 
131  const unsigned short getDimension1() const
132  {
133  return dimension1_;
134  }
135 
136  const unsigned short getDimension2() const
137  {
138  return dimension2_;
139  }
140 
141  const unsigned short getDimension3() const
142  {
143  return dimension3_;
144  }
145 
146 protected:
147 
148  friend class Slate;
149 
151  const Unit& unit_;
153  unsigned short code_;
155  const unsigned short dimension1_;
156  const unsigned short dimension2_;
157  const unsigned short dimension3_;
158 
159  ElementURI( unsigned short code, const char* component, const char* elementName, ElementType = BASE_ELEMENT,
160  const Unit& unit = UNSPECIFIED_UNIT, BinaryDataType binaryType = NO_TYPE,
161  BlobType blobType = NOT_BLOB, unsigned short dimension1 = 0,
162  unsigned short dimension2 = 0, unsigned short dimension3 = 0 );
163 
164 };
165 
166 class ConfigURI : public ElementURI
167 {
168 protected:
170 
171 public:
172 
173  ConfigURI( const Str& component, const char* elementName, const Unit& unit, BinaryDataType binaryType = NO_TYPE )
174  : ElementURI( component, elementName, CONFIG_ELEMENT, unit, binaryType ),
175  requiresRestart_( false )
176  {}
177 
178  ConfigURI( const Str& component, const char* elementName, const char* description, const Unit& unit, BinaryDataType binaryType = NO_TYPE )
179  : ElementURI( component, elementName, description, CONFIG_ELEMENT, unit, binaryType ),
180  requiresRestart_( false )
181  {}
182 
183  bool requiresRestart() const
184  {
185  return requiresRestart_;
186  }
187 
188  static const ConfigURI NO_CONFIG_URI;
189 
190 };
191 
193 {
194 
195 public:
196 
197  RestartConfigURI( const Str& component, const char* elementName, const Unit& unit, BinaryDataType binaryType = NO_TYPE )
198  : ConfigURI( component, elementName, unit, binaryType )
199  {
200  requiresRestart_ = true;
201  }
202 
203  RestartConfigURI( const Str& component, const char* elementName, const char* description, const Unit& unit, BinaryDataType binaryType = NO_TYPE )
204  : ConfigURI( component, elementName, description, unit, binaryType )
205  {
206  requiresRestart_ = true;
207  }
208 
209 };
210 
211 class BlobURI : public ElementURI
212 {
213 public:
214 
215  BlobURI( const Str& component, const char* elementName, const Unit& unit,
216  BlobType blobType, unsigned short dimension1, unsigned short dimension2 = 0,
217  unsigned short dimension3 = 0 )
218  : ElementURI( component, elementName, DATA_ELEMENT, unit, MULTIVALUE, blobType, dimension1, dimension2, dimension3 )
219  {}
220 
221  BlobURI( const Str& component, const char* elementName, const char* description, const Unit& unit,
222  BlobType blobType, unsigned short dimension1, unsigned short dimension2 = 0,
223  unsigned short dimension3 = 0 )
224  : ElementURI( component, elementName, description, DATA_ELEMENT, unit, MULTIVALUE, blobType, dimension1, dimension2, dimension3 )
225  {}
226 
227 };
228 
229 class DataURI : public ElementURI
230 {
231 public:
232 
233  DataURI( const Str& component, const char* elementName, const Unit& unit, BinaryDataType binaryType = NO_TYPE )
234  : ElementURI( component, elementName, DATA_ELEMENT, unit, binaryType )
235  {}
236 
237  DataURI( const Str& component, const char* elementName, const char* description, const Unit& unit, BinaryDataType binaryType = NO_TYPE )
238  : ElementURI( component, elementName, description, DATA_ELEMENT, unit, binaryType )
239  {}
240 };
241 
242 class NameURI : public Str
243 {
244 public:
245 
246  NameURI( const char* elementName )
247  : Str( elementName )
248  {}
249 
250  NameURI( const char* elementName, const char* description )
251  : Str( elementName )
252  {}
253 };
254 
255 class OutputURI : public ElementURI
256 {
257 public:
258 
259  OutputURI( const char* elementName, const Unit& unit, BinaryDataType binaryType = NO_TYPE )
260  : ElementURI( Str::EMPTY_STR, elementName, SETTING_ELEMENT, unit, binaryType )
261  {}
262 
263  OutputURI( const char* elementName, const char* description, const Unit& unit, BinaryDataType binaryType = NO_TYPE )
264  : ElementURI( Str::EMPTY_STR, elementName, description, SETTING_ELEMENT, unit, binaryType )
265  {}
266 };
267 
268 class SettingURI : public ElementURI
269 {
270 public:
271 
272  SettingURI( const char* elementName, const Unit& unit, BinaryDataType binaryType = NO_TYPE )
273  : ElementURI( Str::EMPTY_STR, elementName, SETTING_ELEMENT, unit, binaryType )
274  {}
275 
276  SettingURI( const char* elementName, const char* description, const Unit& unit, BinaryDataType binaryType = NO_TYPE )
277  : ElementURI( Str::EMPTY_STR, elementName, description, SETTING_ELEMENT, unit, binaryType )
278  {}
279 
280  SettingURI( const SettingURI& settingURI )
281  : ElementURI( settingURI )
282  {}
283 };
284 
286 {
287 public:
288 
289  StringSettingURI( const char* elementName )
290  : SettingURI( elementName, Units::NONE, MULTIVALUE )
291  {}
292 
293  StringSettingURI( const char* elementName, const char* description )
294  : SettingURI( elementName, description, Units::NONE, MULTIVALUE )
295  {}
296 };
297 
298 
299 #endif /*ELEMENTURI_H_*/
OutputURI(const char *elementName, const Unit &unit, BinaryDataType binaryType=NO_TYPE)
Definition: ElementURI.h:259
const unsigned short getDimension2() const
Definition: ElementURI.h:136
const Str buildURI(const char *component, const char *elementName)
Definition: ElementURI.cpp:292
BinaryDataType binaryType_
Definition: ElementURI.h:152
BinaryDataType
These are binary type identifiers for serializing and unserializing The syntax below handles up to 16...
Definition: BinaryDataType.h:39
virtual ~ElementURI()
Destructor.
Definition: ElementURI.h:65
static const unsigned short SELF_CODE
Definition: ElementURI.h:43
NameURI(const char *elementName)
Definition: ElementURI.h:246
Contains the BlobType enum definition.
const BinaryDataType getDefaultDataType() const
Definition: Unit.h:116
BlobURI(const Str &component, const char *elementName, const char *description, const Unit &unit, BlobType blobType, unsigned short dimension1, unsigned short dimension2=0, unsigned short dimension3=0)
Definition: ElementURI.h:221
StringSettingURI(const char *elementName)
Definition: ElementURI.h:289
static const unsigned short NUM_CODES
Definition: ElementURI.h:41
Definition: ElementURI.h:285
BlobType getBlobType() const
Definition: ElementURI.h:120
const unsigned short getDimension1() const
Definition: ElementURI.h:131
Definition: ElementURI.h:211
Definition: ElementURI.h:36
BlobType blobType_
Definition: ElementURI.h:154
const unsigned short dimension3_
Definition: ElementURI.h:157
Definition: ElementURI.h:33
unsigned short code_
Definition: ElementURI.h:153
ElementType elementType_
Definition: ElementURI.h:150
ConfigURI(const Str &component, const char *elementName, const Unit &unit, BinaryDataType binaryType=NO_TYPE)
Definition: ElementURI.h:173
static const unsigned short NO_CODE
Definition: ElementURI.h:42
Definition: HorizontalControlIF.h:74
Contains the OutStream class declaration.
DataURI(const Str &component, const char *elementName, const char *description, const Unit &unit, BinaryDataType binaryType=NO_TYPE)
Definition: ElementURI.h:237
ElementType getElementType() const
Definition: ElementURI.h:99
Definition: ElementURI.h:166
This is a very abstract class that can be implemented by classes that want to receive stream input...
Definition: InStream.h:29
int getDimensions() const
Definition: ElementURI.h:125
Definition: ElementURI.h:38
static ElementURI * FindURI(const Str &str)
Definition: ElementURI.cpp:108
BlobURI(const Str &component, const char *elementName, const Unit &unit, BlobType blobType, unsigned short dimension1, unsigned short dimension2=0, unsigned short dimension3=0)
Definition: ElementURI.h:215
Definition: ElementURI.h:37
const unsigned short getDimension3() const
Definition: ElementURI.h:141
BlobType
Definition: BlobType.h:13
SettingURI(const char *elementName, const Unit &unit, BinaryDataType binaryType=NO_TYPE)
Definition: ElementURI.h:272
DataURI(const Str &component, const char *elementName, const Unit &unit, BinaryDataType binaryType=NO_TYPE)
Definition: ElementURI.h:233
const Unit & unit_
Definition: ElementURI.h:151
Replacement for standard template class string.
Definition: Str.h:12
Definition: ElementURI.h:35
Definition: BlobType.h:15
Definition: ElementURI.h:268
ElementType
Definition: ElementURI.h:31
NameURI(const char *elementName, const char *description)
Definition: ElementURI.h:250
void setCode(unsigned short code)
Definition: ElementURI.h:79
SettingURI(const SettingURI &settingURI)
Definition: ElementURI.h:280
Definition: BinaryDataType.h:41
Contains the InStream and NullInStream class declarations.
static ElementURI * Read(InStream &inStream)
Definition: ElementURI.cpp:162
Contains the Units class declaration.
OutputURI(const char *elementName, const char *description, const Unit &unit, BinaryDataType binaryType=NO_TYPE)
Definition: ElementURI.h:263
StringSettingURI(const char *elementName, const char *description)
Definition: ElementURI.h:293
Definition: ElementURI.h:34
static const Unit UNSPECIFIED_UNIT
Definition: ElementURI.h:44
static const Str EMPTY_STR
Definition: Str.h:19
Static collection of standard engineering Units Can use UnitRegistry to look these up by name...
Definition: Units.h:33
Code unit that represents the slate.
Definition: Slate.h:73
BinaryDataType getBinaryType() const
Definition: ElementURI.h:94
Contains the BinaryDataType enumeration.
Definition: BinaryDataType.h:42
Definition: ElementURI.h:229
unsigned int write(OutStream &outStream)
Definition: ElementURI.cpp:118
const unsigned short dimension2_
Definition: ElementURI.h:156
Definition: ElementURI.h:255
ElementURI(const char *component, const char *elementName, ElementType=BASE_ELEMENT, const Unit &unit=UNSPECIFIED_UNIT, BinaryDataType binaryType=NO_TYPE, BlobType blobType=NOT_BLOB, unsigned short dimension1=0, unsigned short dimension2=0, unsigned short dimension3=0)
Definition: ElementURI.cpp:35
bool requiresRestart_
Definition: ElementURI.h:169
unsigned short getCode() const
Definition: ElementURI.h:74
const unsigned short dimension1_
Definition: ElementURI.h:155
Code unit that represents a unique name for a DataElement.
Definition: ElementURI.h:27
This is a very abstract class that can be implemented by classes that want to send stream output...
Definition: OutStream.h:41
RestartConfigURI(const Str &component, const char *elementName, const char *description, const Unit &unit, BinaryDataType binaryType=NO_TYPE)
Definition: ElementURI.h:203
ConfigURI(const Str &component, const char *elementName, const char *description, const Unit &unit, BinaryDataType binaryType=NO_TYPE)
Definition: ElementURI.h:178
virtual bool isUniversal() const
Definition: ElementURI.h:84
static const ConfigURI NO_CONFIG_URI
Definition: ElementURI.h:188
const Unit & getUnit() const
Definition: ElementURI.h:89
Definition: ElementURI.h:242
SettingURI(const char *elementName, const char *description, const Unit &unit, BinaryDataType binaryType=NO_TYPE)
Definition: ElementURI.h:276
Code that represents an engineering unit.
Definition: Unit.h:24
RestartConfigURI(const Str &component, const char *elementName, const Unit &unit, BinaryDataType binaryType=NO_TYPE)
Definition: ElementURI.h:197
Definition: ElementURI.h:192
bool requiresRestart() const
Definition: ElementURI.h:183
static ElementURI Create(const Str &component, const Str &elementName)
Definition: ElementURI.cpp:103