1 karl 1.30 //%2005////////////////////////////////////////////////////////////////////////
|
2 mike 1.11 //
|
3 karl 1.29 // Copyright (c) 2000, 2001, 2002 BMC Software; Hewlett-Packard Development
4 // Company, L.P.; IBM Corp.; The Open Group; Tivoli Systems.
5 // Copyright (c) 2003 BMC Software; Hewlett-Packard Development Company, L.P.;
|
6 karl 1.25 // IBM Corp.; EMC Corporation, The Open Group.
|
7 karl 1.29 // Copyright (c) 2004 BMC Software; Hewlett-Packard Development Company, L.P.;
8 // IBM Corp.; EMC Corporation; VERITAS Software Corporation; The Open Group.
|
9 karl 1.30 // Copyright (c) 2005 Hewlett-Packard Development Company, L.P.; IBM Corp.;
10 // EMC Corporation; VERITAS Software Corporation; The Open Group.
|
11 mike 1.11 //
12 // Permission is hereby granted, free of charge, to any person obtaining a copy
|
13 kumpf 1.13 // of this software and associated documentation files (the "Software"), to
14 // deal in the Software without restriction, including without limitation the
15 // rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
|
16 mike 1.11 // sell copies of the Software, and to permit persons to whom the Software is
17 // furnished to do so, subject to the following conditions:
18 //
|
19 kumpf 1.13 // THE ABOVE COPYRIGHT NOTICE AND THIS PERMISSION NOTICE SHALL BE INCLUDED IN
|
20 mike 1.11 // ALL COPIES OR SUBSTANTIAL PORTIONS OF THE SOFTWARE. THE SOFTWARE IS PROVIDED
21 // "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT
|
22 kumpf 1.13 // LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
23 // PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
24 // HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
|
25 mike 1.11 // ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
26 // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
27 //
28 //==============================================================================
29 //
30 //%/////////////////////////////////////////////////////////////////////////////
31
32 #ifndef Pegasus_Name_h
33 #define Pegasus_Name_h
34
35 #include <Pegasus/Common/Config.h>
|
36 kumpf 1.17 #include <Pegasus/Common/Linkage.h>
|
37 mike 1.11 #include <Pegasus/Common/String.h>
|
38 kumpf 1.17 #include <Pegasus/Common/Array.h>
39 #include <Pegasus/Common/Exception.h>
|
40 mike 1.11
41 PEGASUS_NAMESPACE_BEGIN
42
|
43 kumpf 1.17 ////////////////////////////////////////////////////////////////////////////////
44 //
45 // CIMName
46 //
47 ////////////////////////////////////////////////////////////////////////////////
48
|
49 mike 1.11 /**
|
50 kumpf 1.17 The CIMName class defines methods for handling CIM names.
|
51 kumpf 1.14 <p>
|
52 mike 1.11 The names of classes, properties, qualifiers, and methods are all
53 CIM names. A CIM name must match the following regular
54 expression:
55 <PRE>
|
56 david.dillard 1.32 [A-Z-a-z_][A-Za-z_0-9]*
|
57 mike 1.11 </PRE>
|
58 karl 1.23 <B>Examples:</B>
59 <ul>
60 <li>name - legal name
61 <li>Type - legal name
62 <li>3types - Illegal CIMName.
63 </ul>
|
64 david.dillard 1.32 The CIMName class includes the attribute Null which is required
|
65 karl 1.23 by the DMTF operations definitions. Note that this and the regular
66 expression limits on CIMName are what separate this from the String
|
67 david.dillard 1.32 class. This allows the names in CIM operations, such as getClass, to
|
68 karl 1.23 provide pattern matching tests for the classname parameter as well as
69 separate the concept of empty from Null.
70
|
71 mike 1.11 */
72 class PEGASUS_COMMON_LINKAGE CIMName
73 {
74 public:
75
|
76 david.dillard 1.32 /**
77 Constructs an object with no name. A call to isNull() immediately
78 after constructing the object will return true.
79
80 @exception bad_alloc Thrown if there is insufficient memory.
|
81 karl 1.23 */
|
82 kumpf 1.17 CIMName();
|
83 karl 1.23
|
84 david.dillard 1.32 /**
85 Constructor creates a new CIMName object from the String
86 provided as input. The String must be a legal name.
87
88 @param name defining the CIMName
89 @exception InvalidNameException if the input String is
90 not a legal CIMName
91 @exception bad_alloc Thrown if there is insufficient memory.
|
92 karl 1.23 */
|
93 kumpf 1.17 CIMName(const String& name);
|
94 david.dillard 1.32
|
95 karl 1.23 /**
|
96 david.dillard 1.32 Constructor creates a new CIMName object from string
97 provided as input. The string must be a legal name.
98
99 @param char* defining the CIMName text.
100 @exception InvalidNameException if the input String is
101 not a legal CIMName
102 @exception bad_alloc Thrown if there is insufficient memory.
103 */
|
104 kumpf 1.17 CIMName(const char* name);
105
|
106 david.dillard 1.32 /**
107 Assigns one CIMName to another.
108
109 @param name Source CIMName object to copy.
110 @exception bad_alloc Thrown if there is insufficient memory.
111 */
|
112 kumpf 1.17 CIMName& operator=(const CIMName& name);
|
113 david.dillard 1.32
114 /**
115 Sets the name of the associated object to the
116 specified String.
117
118 @param name The new name to use for the object.
119 @exception InvalidNameException if the input String
120 is not a legal CIMName.
121 @exception bad_alloc Thrown if there is insufficient memory.
122
123 <pre>
124 CIMName n;
125 String type = "type";
126 n = type;
127 </pre>
128 */
|
129 kumpf 1.17 CIMName& operator=(const String& name);
|
130 kumpf 1.20
|
131 david.dillard 1.32 /**
132 Gets a reference a String containing the name from the
133 associated object.
134
135 @return Reference to a String containing the name.
136
137 <pre>
138 CIMName n("name");
139 String s = n.getString();
140 </pre>
141 */
|
142 kumpf 1.20 const String& getString() const;
|
143 kumpf 1.17
|
144 david.dillard 1.32 /**
145 Tests if name is Null, i.e. not set.
146
147 @return true if name is Null, false if not.
148
149 <pre>
150 CIMName n;
151 assert(n.isNull());
152 n = "name";
153 assert(!n.isNull());
154 </pre>
155 */
|
156 kumpf 1.17 Boolean isNull() const;
157
|
158 david.dillard 1.32 /**
159 Clears the CIMName.
160
161 <pre>
162 CIMMame n("name");
163 n.clear();
164 assert(n.isNull());
165 </pre>
166 */
|
167 kumpf 1.17 void clear();
168
|
169 david.dillard 1.32 /**
170 Compares the CIMName object against another CIMName object for equality.
171
172 @param name Object to compare with the associated object.
173 @return true if the name passed is equal to the name in this
174
|
175 kumpf 1.22 class. CIM names are case insensitive and so is this method.
|
176 david.dillard 1.32 <pre>
177 CIMName n1 = "name";
178 CIMName n2 = "InstanceID";
179 if( n1.equal(n2) )
180 ... // Should never get here
181 else
182 ...
183 </pre>
|
184 kumpf 1.17 */
185 Boolean equal(const CIMName& name) const;
186
|
187 david.dillard 1.32 /**
188 Determines if the name string input is legal as
189 defined in the CIMName class definition. This is a static
190 method used to test String values to determine if they are
191 legal names.
192
193 @param name String to test for legality.
194 @return Returns true if the name is legal, otherwise false.
195
196 <pre>
197 assert(CIMName::legal("name"));
198 assert(!CIMName::legal("3types"));
199 </pre>
|
200 mike 1.11 */
|
201 kumpf 1.21 static Boolean legal(const String& name);
|
202 mike 1.11
203 private:
|
204 kumpf 1.17 String cimName;
205 };
206
|
207 david.dillard 1.32 /**
208 Compares two CIMNames to determine if they are equal.
209
210 @param name1 One name to compare.
211 @param name2 Another name to compare
212 @return Returns true if the names are equal, false if they are not.
213
214 CIMNames are not case sensitive, therefore the output of the
215 following example is "Equal".
216
217 <pre>
218 CIMName lowerCaseName("this_is_a_name");
219 CIMName upperCaseName("THIS_IS_A_NAME");
220
221 if (lowerCaseName == upperCaseName)
222 {
223 puts("Equal");
224 }
225 else
226 {
227 puts("Not equal");
228 david.dillard 1.32 }
229 </pre>
230 */
|
231 kumpf 1.18 PEGASUS_COMMON_LINKAGE Boolean operator==(
232 const CIMName& name1,
233 const CIMName& name2);
|
234 kumpf 1.17
|
235 david.dillard 1.32 /**
236 Compares two CIMNames to determine if they are not equal.
237
238 @param name1 One name to compare.
239 @param name2 Another name to compare
240 @return Returns true if the names are not equal, false if they are.
241
242 The output of the following example is "Not equal".
243
244 <pre>
245 CIMName name1("this_is_a_name");
246 CIMName name2("this is another_name");
247
248 if (name1 != name2)
249 {
250 puts("Not equal");
251 }
252 else
253 {
254 puts("Equal");
255 }
256 david.dillard 1.32 </pre>
257 */
|
258 david.dillard 1.31 PEGASUS_COMMON_LINKAGE Boolean operator!=(
259 const CIMName& name1,
260 const CIMName& name2);
261
|
262 kumpf 1.17 #define PEGASUS_ARRAY_T CIMName
263 # include "ArrayInter.h"
264 #undef PEGASUS_ARRAY_T
265
266
267 ////////////////////////////////////////////////////////////////////////////////
268 //
269 // CIMNamespaceName
270 //
271 ////////////////////////////////////////////////////////////////////////////////
272
273 /**
|
274 kumpf 1.19 The CIMNamespaceName class defines methods for handling CIM namespace names.
|
275 kumpf 1.17 <p>
276 A CIM namespace name must match the following expression:
277 <PRE>
|
278 karl 1.24 <CIMName>[ / <CIMName> ]*
|
279 kumpf 1.17 </PRE>
|
280 kumpf 1.22 </p>
|
281 karl 1.23 <B>Examples</B>
282 <UL>
283 <LI>root
284 <LI>root/test
285 </UL>
286 NOTE: Pegasus uses namespaces starting with the top level name (ex. root). It does
|
287 karl 1.24 not use the form /root/test with a leading slash. The legal() test method in this class
|
288 karl 1.23 allows that form as a legal entity however.
|
289 kumpf 1.17 */
290 class PEGASUS_COMMON_LINKAGE CIMNamespaceName
291 {
292 public:
293
|
294 karl 1.23 /** Default constructor sets object Null. The Null state
|
295 david.dillard 1.32 indicates that there is no name assigned to this object.
296 The Null state can be tested with the isNull() method and
297 set with the clear() method.
298 */
|
299 kumpf 1.17 CIMNamespaceName();
|
300 karl 1.23
301 /** Constructor builds namespace from input String.
|
302 david.dillard 1.32 The String input must be a legal namespace name.
303 @param String from which the namespace object is built.
304 This must be a legal namespace name.
305 @exeception InvalidNamespaceName exception thrown if
306 the namespace name input is illegal.
307 */
|
308 kumpf 1.17 CIMNamespaceName(const String& name);
|
309 karl 1.23
310 /** Constructor builds namespace from input char*.
|
311 david.dillard 1.32 The String input must be a legal namespace name.
312 @param char* from which the namespace object is built.
313 This must be a legal namespace name.
314 @exeception InvalidNamespaceName exception thrown if
315 the namespace name input parameter is illegal.
316 */
|
317 kumpf 1.17 CIMNamespaceName(const char* name);
318
|
319 karl 1.23 /** Assign one namespace object to another.
|
320 david.dillard 1.32 @param CIMNamespaceName to assign to the object.
321 */
|
322 kumpf 1.17 CIMNamespaceName& operator=(const CIMNamespaceName& name);
|
323 karl 1.23
324 /** Assign a String object to a CIMNamespaceName object.
|
325 david.dillard 1.32 @param CIMNamespaceName to assign
326 @exeception InvalidNamespaceName exception thrown if
327 the namespace name input parameter is illegal.
328 <pre>
329 String s = "root/test";
330 CIMNamespacename ns;
331 ns = s;
332 </pre>
333 */
|
334 kumpf 1.17 CIMNamespaceName& operator=(const String& name);
|
335 kumpf 1.20
|
336 karl 1.23 /** Extracts the String value of the CIMNamespaceName
|
337 david.dillard 1.32 from the object.
338 @return String containing the name.
339 <pre>
340 CIMNamespaceName ns("root/test");
341 String s = ns.getString();
342 </pre>
343 */
|
344 kumpf 1.20 const String& getString() const;
|
345 kumpf 1.17
|
346 karl 1.23 /** Tests the CIMNamespaceName for NULL attribute. Returns
|
347 david.dillard 1.32 true if Null. New objects without parameter and objects
348 set with clear() are Null. When a name is set into the
349 object is is set to nonnull. When the object is Null, it
350 returns empty string.
351 @return true if Null or false if not Null.
352 <pre>
353 CIMName n;
354 assert(n.isNull());
355 n = "name";
356 assert(!n.isNull());
357 </pre>
358 */
|
359 kumpf 1.17 Boolean isNull() const;
360
|
361 karl 1.23 /** Clears the CIMNamespaceName and sets it to Null. A Null
|
362 david.dillard 1.32 object contains no name so that accessing it with getString
363 should return an empty String
364 <pre>
365 CIMMamespaceName ns("root/test");
366 ns.clear();
367 assert(ns.isNull());
368 </pre>
369 */
|
370 kumpf 1.17 void clear();
371
|
372 karl 1.23 /** Compares two CIMNamespace objects for equality.
|
373 david.dillard 1.32 @return true if the name passed is equal to the name in this
|
374 kumpf 1.22 class. CIM names are case insensitive and so is this method.
|
375 david.dillard 1.32 <pre>
376 CIMMamespaceName ns("root/test");
377 CIMMamespaceName ns1("root/test");
378 assert( ns.equal(ns1);
379 </pre>
|
380 kumpf 1.17 */
381 Boolean equal(const CIMNamespaceName& name) const;
|
382 mike 1.11
|
383 kumpf 1.22 /** Determines if the name string input is legal as
|
384 david.dillard 1.32 defined in the CIMNamespaceName class definition.
385 @param name String to test for legality.
386 @return true if the given name is legal, false otherwise.
387 <pre>
388 assert(CIMNamespaceName::legal("root/test"));
389 </pre>
|
390 kumpf 1.17 */
|
391 kumpf 1.21 static Boolean legal(const String& name);
|
392 kumpf 1.17
393 private:
394 String cimNamespaceName;
|
395 mike 1.11 };
|
396 kumpf 1.20
397 PEGASUS_COMMON_LINKAGE Boolean operator==(
398 const CIMNamespaceName& name1,
399 const CIMNamespaceName& name2);
400
|
401 david.dillard 1.31 PEGASUS_COMMON_LINKAGE Boolean operator!=(
402 const CIMNamespaceName& name1,
403 const CIMNamespaceName& name2);
404
|
405 kumpf 1.20 #define PEGASUS_ARRAY_T CIMNamespaceName
406 # include "ArrayInter.h"
407 #undef PEGASUS_ARRAY_T
|
408 mike 1.11
409 PEGASUS_NAMESPACE_END
410
411 #endif /* Pegasus_Name_h */
|