VR-Forces 4.1 Class Documentation
rangedObjType.h
Go to the documentation of this file.
1 /*******************************************************************************
2 ** Copyright (c) 2001 MAK Technologies, Inc.
3 ** All rights reserved.
4 *******************************************************************************/
5 /*******************************************************************************
6 ** $RCSfile: rangedObjType.h,v $ $Revision: 1.5 $ $State: Exp $
7 *******************************************************************************/
8 
9 #ifndef DtRangedObjectType_H_
10 #define DtRangedObjectType_H_
11 
12 #include <vrfExtProtocol/objType.h>
13 
14 #include <vector>
15 #include <stdlib.h>
16 
17 // class DtRangedObjectType:
18 //
19 // Instances of DtRangedObjectType are object types that can have ranges specified for
20 // any of the elements. Use the DtRangedObjectTypeIterator to iterate through all the
21 // different types.
22 
25 {
26 public:
27 
28  // default constructor
30 
31  DtRangedObjectType(int superType, int kind, int domain, int country,
32  int category, int subCategory, int specific, int extra);
33 
34  DtRangedObjectType(int superType, const DtEntityType & entityType);
35 
36  DtRangedObjectType(const char* superType, const char* kind, const char* domain, const char* country,
37  const char* category, const char* subCategory, const char* specific, const char* extra);
38 
39  DtRangedObjectType(const char* superType, const DtEntityType & entityType);
40 
41  // destructor
42  virtual ~DtRangedObjectType();
43 
44  // copy constructor
46  DtRangedObjectType(const DtObjectType& orig);
47 
48  // assignment operator
51 
52  // set/get the super type field. Enumerations for this field are found
53  // in objTypeEnums.h.
54  void setRangedSuperType(const char*);
55  const char* rangedSuperType() const;
56 
57  void setRangedKind(const char*);
58  const char* rangedKind() const;
59 
60  void setRangedDomain(const char*);
61  const char* rangedDomain() const;
62 
63  void setRangedCountry(const char*);
64  const char* rangedCountry() const;
65 
66  void setRangedCategory(const char*);
67  const char* rangedCategory() const;
68 
69  void setRangedSubCategory(const char*);
70  const char* rangedSubCategory() const;
71 
72  void setRangedSpecific(const char*);
73  const char* rangedSpecific() const;
74 
75  void setRangedExtra(const char*);
76  const char* rangedExtra() const;
77 
78  // Returns a string representation of the object type.
79  virtual const char *string() const;
80 
81  // Returns true if all fields either match exactly or with -1's.
82  virtual bool matchPattern(const DtObjectType &pat) const;
83 
84  // == returns 1 if all fields are exactly equal, 0 if they are not equal
85  virtual int match(const DtObjectType &type) const;
86 
87  // == returns 1 if all fields are exactly equal, 0 if they are not equal
88  virtual int operator==(const DtObjectType &type) const;
89 
90  // != returns 0 if they are equal, nonzero if they are not equal
91  virtual int operator!=(const DtObjectType &type) const;
92 
93  virtual bool isRange(const char*) const;
94 
95  virtual std::vector<int> parseRange(const char*) const;
96 
97  bool isRange(int) const;
98 
99  DtString operator[](int) const;
100  void setValue(int i, const DtString& value);
101 
102 protected:
103  // Will have length and be set only if item is actually a range. Ranges can be specified either
104  // by - or , (i.e. 5-10 or 6,17,9)
105  DtString myElements[8];
106 
107  // Elements are of the following type
108  // myRangedSuperType;
109  // myRangedKind;
110  // myRangedDomain;
111  // myRangedCountry;
112  // myRangedCategory;
113  // myRangedSubcategory;
114  // myRangedSpecific;
115  // myRangedExtra;
116 };
117 
119 {
120 public:
122 
123  DtObjectType current() const;
124 
125  DtObjectType operator++() { return next(); };
126  DtObjectType next();
127  bool atEnd() const;
128 
129  // Returns false if all combinations of offsets have been used
130  bool increaseOffsetsFrom(int);
131 
132 protected:
134 
135 protected:
137  std::vector<int> myOffsets;
138  std::vector<std::vector<int> > myElements;
140  bool myAtEnd;
141 };
142 
143 inline void DtRangedObjectType::setRangedSuperType(const char* s)
144 {
145  if (isRange(s))
146  {
147  myElements[7] = s;
148  }
149  else if (s)
150  {
151  setSuperType(s ? atoi(s) : -1);
152  }
153 }
154 
155 inline const char* DtRangedObjectType::rangedSuperType() const
156 {
157  return myElements[7];
158 }
159 
160 inline void DtRangedObjectType::setRangedKind(const char* s)
161 {
162  if (isRange(s))
163  {
164  myElements[0] = s;
165  }
166  else if (s)
167  {
168  setKind(s ? atoi(s) : -1);
169  }
170 }
171 
172 inline const char* DtRangedObjectType::rangedKind() const
173 {
174  return myElements[0];
175 }
176 
177 inline void DtRangedObjectType::setRangedDomain(const char* s)
178 {
179  if (isRange(s))
180  {
181  myElements[1] = s;
182  }
183  else if (s)
184  {
185  setDomain(s ? atoi(s) : -1);
186  }
187 }
188 
189 inline const char* DtRangedObjectType::rangedDomain() const
190 {
191  return myElements[1];
192 }
193 
194 inline void DtRangedObjectType::setRangedCountry(const char* s)
195 {
196  if (isRange(s))
197  {
198  myElements[2] = s;
199  }
200  else if (s)
201  {
202  setCountry(s ? atoi(s) : -1);
203  }
204 }
205 
206 inline const char* DtRangedObjectType::rangedCountry() const
207 {
208  return myElements[2];
209 }
210 
211 inline void DtRangedObjectType::setRangedCategory(const char* s)
212 {
213  if (isRange(s))
214  {
215  myElements[3] = s;
216  }
217  else
218  {
219  setCategory(s ? atoi(s) : -1);
220  }
221 }
222 
223 inline const char* DtRangedObjectType::rangedCategory() const
224 {
225  return myElements[3];
226 }
227 
229 {
230  if (isRange(s))
231  {
232  myElements[4] = s;
233  }
234  else
235  {
236  setSubCategory(s ? atoi(s) : -1);
237  }
238 }
239 
240 inline const char* DtRangedObjectType::rangedSubCategory() const
241 {
242  return myElements[4];
243 }
244 
245 inline void DtRangedObjectType::setRangedSpecific(const char* s)
246 {
247  if (isRange(s))
248  {
249  myElements[5] = s;
250  }
251  else
252  {
253  setSpecific(s ? atoi(s) : -1);
254  }
255 }
256 
257 inline const char* DtRangedObjectType::rangedSpecific() const
258 {
259  return myElements[5];
260 }
261 
262 inline void DtRangedObjectType::setRangedExtra(const char* s)
263 {
264  if (isRange(s))
265  {
266  myElements[6] = s;
267  }
268  else
269  {
270  setExtra(s ? atoi(s) : -1);
271  }
272 }
273 
274 inline const char* DtRangedObjectType::rangedExtra() const
275 {
276  return myElements[6];
277 }
278 
279 #endif
280 

Document ID: Generated on Tue Jan 29 18:21:16 EST 2013 from SVN revision 123193
Copyright © 2005-2013 VT MÄK Inc. All Rights Reserved (www.mak.com)