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.33 [A-Za-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 david.dillard 1.33 <li>3types - Illegal CIM name
|
63 karl 1.23 </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 david.dillard 1.33 Constructor creates a new CIMName object from <TT>name</TT>.
86 <TT>name</TT> must be a legal CIM name.
|
87 david.dillard 1.32
|
88 david.dillard 1.33 @param name The name to use for the object.
89 @exception InvalidNameException if <TT>name</TT> is not
90 a legal CIMName
|
91 david.dillard 1.32 @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 david.dillard 1.33 @param name The name to use for the object.
100 @exception InvalidNameException if <TT>name</TT> is not
101 a legal CIMName
|
102 david.dillard 1.32 @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 david.dillard 1.33 @param name CIMName object to copy.
|
110 david.dillard 1.32 @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 david.dillard 1.33 Sets the name of the associated object to <TT>name</TT>.
|
116 david.dillard 1.32
117 @param name The new name to use for the object.
|
118 david.dillard 1.33 @exception InvalidNameException if <TT>name</TT> is not
119 a legal CIMName
|
120 david.dillard 1.32 @exception bad_alloc Thrown if there is insufficient memory.
121
122 <pre>
123 CIMName n;
124 String type = "type";
125 n = type;
126 </pre>
127 */
|
128 kumpf 1.17 CIMName& operator=(const String& name);
|
129 kumpf 1.20
|
130 david.dillard 1.32 /**
131 Gets a reference a String containing the name from the
132 associated object.
133
134 @return Reference to a String containing the name.
135
136 <pre>
137 CIMName n("name");
138 String s = n.getString();
139 </pre>
140 */
|
141 kumpf 1.20 const String& getString() const;
|
142 kumpf 1.17
|
143 david.dillard 1.32 /**
144 Tests if name is Null, i.e. not set.
145
146 @return true if name is Null, false if not.
147
148 <pre>
149 CIMName n;
150 assert(n.isNull());
151 n = "name";
152 assert(!n.isNull());
153 </pre>
154 */
|
155 kumpf 1.17 Boolean isNull() const;
156
|
157 david.dillard 1.32 /**
158 Clears the CIMName.
159
160 <pre>
161 CIMMame n("name");
162 n.clear();
163 assert(n.isNull());
164 </pre>
165 */
|
166 kumpf 1.17 void clear();
167
|
168 david.dillard 1.32 /**
|
169 david.dillard 1.33 Compares the CIMName object against another CIMName object
170 for equality.
|
171 david.dillard 1.32
|
172 david.dillard 1.33 @param name CIMName to compare with the associated object.
|
173 david.dillard 1.32 @return true if the name passed is equal to the name in this
|
174 kumpf 1.22 class. CIM names are case insensitive and so is this method.
|
175 david.dillard 1.32 <pre>
176 CIMName n1 = "name";
177 CIMName n2 = "InstanceID";
178 if( n1.equal(n2) )
179 ... // Should never get here
180 else
181 ...
182 </pre>
|
183 kumpf 1.17 */
184 Boolean equal(const CIMName& name) const;
185
|
186 david.dillard 1.32 /**
187 Determines if the name string input is legal as
188 defined in the CIMName class definition. This is a static
189 method used to test String values to determine if they are
190 legal names.
191
192 @param name String to test for legality.
193 @return Returns true if the name is legal, otherwise false.
194
195 <pre>
196 assert(CIMName::legal("name"));
197 assert(!CIMName::legal("3types"));
198 </pre>
|
199 mike 1.11 */
|
200 kumpf 1.21 static Boolean legal(const String& name);
|
201 mike 1.11
|
202 mike 1.33.2.1 ////
203 //// {New interfaces start here:
204 ////
205
206 enum UncheckedTag { UNCHECKED };
207
208 Boolean equal(const char* name) const;
209
210 CIMName& operator=(const char* name);
211
212 CIMName(const String& name, UncheckedTag);
213
214 CIMName(const char* name, UncheckedTag);
215
216 void assignUnchecked(const String& name);
217
218 void assignUnchecked(const char* name);
219
220 ////
221 //// }New interfaces end here:
222 ////
223 mike 1.33.2.1
224
|
225 mike 1.11 private:
|
226 kumpf 1.17 String cimName;
227 };
228
|
229 david.dillard 1.32 /**
230 Compares two CIMNames to determine if they are equal.
231
232 @param name1 One name to compare.
233 @param name2 Another name to compare
234 @return Returns true if the names are equal, false if they are not.
235
236 CIMNames are not case sensitive, therefore the output of the
237 following example is "Equal".
238
239 <pre>
240 CIMName lowerCaseName("this_is_a_name");
241 CIMName upperCaseName("THIS_IS_A_NAME");
242
243 if (lowerCaseName == upperCaseName)
244 {
245 puts("Equal");
246 }
247 else
248 {
249 puts("Not equal");
250 david.dillard 1.32 }
251 </pre>
252 */
|
253 kumpf 1.18 PEGASUS_COMMON_LINKAGE Boolean operator==(
254 const CIMName& name1,
255 const CIMName& name2);
|
256 kumpf 1.17
|
257 david.dillard 1.32 /**
258 Compares two CIMNames to determine if they are not equal.
259
260 @param name1 One name to compare.
261 @param name2 Another name to compare
262 @return Returns true if the names are not equal, false if they are.
263
264 The output of the following example is "Not equal".
265
266 <pre>
267 CIMName name1("this_is_a_name");
268 CIMName name2("this is another_name");
269
270 if (name1 != name2)
271 {
272 puts("Not equal");
273 }
274 else
275 {
276 puts("Equal");
277 }
278 david.dillard 1.32 </pre>
279 */
|
280 david.dillard 1.31 PEGASUS_COMMON_LINKAGE Boolean operator!=(
281 const CIMName& name1,
282 const CIMName& name2);
283
|
284 kumpf 1.17 #define PEGASUS_ARRAY_T CIMName
285 # include "ArrayInter.h"
286 #undef PEGASUS_ARRAY_T
287
288
289 ////////////////////////////////////////////////////////////////////////////////
290 //
291 // CIMNamespaceName
292 //
293 ////////////////////////////////////////////////////////////////////////////////
294
295 /**
|
296 kumpf 1.19 The CIMNamespaceName class defines methods for handling CIM namespace names.
|
297 kumpf 1.17 <p>
298 A CIM namespace name must match the following expression:
299 <PRE>
|
300 karl 1.24 <CIMName>[ / <CIMName> ]*
|
301 kumpf 1.17 </PRE>
|
302 kumpf 1.22 </p>
|
303 karl 1.23 <B>Examples</B>
304 <UL>
305 <LI>root
306 <LI>root/test
307 </UL>
308 NOTE: Pegasus uses namespaces starting with the top level name (ex. root). It does
|
309 karl 1.24 not use the form /root/test with a leading slash. The legal() test method in this class
|
310 karl 1.23 allows that form as a legal entity however.
|
311 kumpf 1.17 */
312 class PEGASUS_COMMON_LINKAGE CIMNamespaceName
313 {
314 public:
315
|
316 karl 1.23 /** Default constructor sets object Null. The Null state
|
317 david.dillard 1.32 indicates that there is no name assigned to this object.
318 The Null state can be tested with the isNull() method and
319 set with the clear() method.
320 */
|
321 kumpf 1.17 CIMNamespaceName();
|
322 karl 1.23
323 /** Constructor builds namespace from input String.
|
324 david.dillard 1.32 The String input must be a legal namespace name.
325 @param String from which the namespace object is built.
326 This must be a legal namespace name.
327 @exeception InvalidNamespaceName exception thrown if
328 the namespace name input is illegal.
329 */
|
330 kumpf 1.17 CIMNamespaceName(const String& name);
|
331 karl 1.23
332 /** Constructor builds namespace from input char*.
|
333 david.dillard 1.32 The String input must be a legal namespace name.
334 @param char* from which the namespace object is built.
335 This must be a legal namespace name.
336 @exeception InvalidNamespaceName exception thrown if
337 the namespace name input parameter is illegal.
338 */
|
339 kumpf 1.17 CIMNamespaceName(const char* name);
340
|
341 karl 1.23 /** Assign one namespace object to another.
|
342 david.dillard 1.32 @param CIMNamespaceName to assign to the object.
343 */
|
344 kumpf 1.17 CIMNamespaceName& operator=(const CIMNamespaceName& name);
|
345 karl 1.23
346 /** Assign a String object to a CIMNamespaceName object.
|
347 david.dillard 1.32 @param CIMNamespaceName to assign
348 @exeception InvalidNamespaceName exception thrown if
349 the namespace name input parameter is illegal.
350 <pre>
351 String s = "root/test";
352 CIMNamespacename ns;
353 ns = s;
354 </pre>
355 */
|
356 kumpf 1.17 CIMNamespaceName& operator=(const String& name);
|
357 kumpf 1.20
|
358 karl 1.23 /** Extracts the String value of the CIMNamespaceName
|
359 david.dillard 1.32 from the object.
360 @return String containing the name.
361 <pre>
362 CIMNamespaceName ns("root/test");
363 String s = ns.getString();
364 </pre>
365 */
|
366 kumpf 1.20 const String& getString() const;
|
367 kumpf 1.17
|
368 karl 1.23 /** Tests the CIMNamespaceName for NULL attribute. Returns
|
369 david.dillard 1.32 true if Null. New objects without parameter and objects
370 set with clear() are Null. When a name is set into the
371 object is is set to nonnull. When the object is Null, it
372 returns empty string.
373 @return true if Null or false if not Null.
374 <pre>
375 CIMName n;
376 assert(n.isNull());
377 n = "name";
378 assert(!n.isNull());
379 </pre>
380 */
|
381 kumpf 1.17 Boolean isNull() const;
382
|
383 karl 1.23 /** Clears the CIMNamespaceName and sets it to Null. A Null
|
384 david.dillard 1.32 object contains no name so that accessing it with getString
385 should return an empty String
386 <pre>
387 CIMMamespaceName ns("root/test");
388 ns.clear();
389 assert(ns.isNull());
390 </pre>
391 */
|
392 kumpf 1.17 void clear();
393
|
394 karl 1.23 /** Compares two CIMNamespace objects for equality.
|
395 david.dillard 1.32 @return true if the name passed is equal to the name in this
|
396 kumpf 1.22 class. CIM names are case insensitive and so is this method.
|
397 david.dillard 1.32 <pre>
398 CIMMamespaceName ns("root/test");
399 CIMMamespaceName ns1("root/test");
400 assert( ns.equal(ns1);
401 </pre>
|
402 kumpf 1.17 */
403 Boolean equal(const CIMNamespaceName& name) const;
|
404 mike 1.11
|
405 kumpf 1.22 /** Determines if the name string input is legal as
|
406 david.dillard 1.32 defined in the CIMNamespaceName class definition.
407 @param name String to test for legality.
408 @return true if the given name is legal, false otherwise.
409 <pre>
410 assert(CIMNamespaceName::legal("root/test"));
411 </pre>
|
412 kumpf 1.17 */
|
413 kumpf 1.21 static Boolean legal(const String& name);
|
414 kumpf 1.17
|
415 mike 1.33.2.1 ////
416 //// {New interfaces start here:
417 ////
418
419 Boolean equal(const char* name) const;
420
421 CIMNamespaceName& operator=(const char* name);
422
423 ////
424 //// }New interfaces end here:
425 ////
426
|
427 kumpf 1.17 private:
428 String cimNamespaceName;
|
429 mike 1.11 };
|
430 kumpf 1.20
431 PEGASUS_COMMON_LINKAGE Boolean operator==(
432 const CIMNamespaceName& name1,
433 const CIMNamespaceName& name2);
434
|
435 david.dillard 1.31 PEGASUS_COMMON_LINKAGE Boolean operator!=(
436 const CIMNamespaceName& name1,
437 const CIMNamespaceName& name2);
438
|
439 kumpf 1.20 #define PEGASUS_ARRAY_T CIMNamespaceName
440 # include "ArrayInter.h"
441 #undef PEGASUS_ARRAY_T
|
442 mike 1.11
443 PEGASUS_NAMESPACE_END
444
|
445 mike 1.33.2.2 #if defined(PEGASUS_INTERNALONLY) && defined(PEGASUS_USE_INTERNAL_INLINES)
|
446 mike 1.33.2.1 # define PEGASUS_CIMNAME_INLINE inline
447 # include "CIMNameInline.h"
448 # undef PEGASUS_CIMNAME_INLINE
449 #endif
450
|
451 mike 1.11 #endif /* Pegasus_Name_h */
|