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 r.kieninger 1.34 CIMName n("name");
|
162 david.dillard 1.32 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 r.kieninger 1.34 #ifdef PEGASUS_USE_EXPERIMENTAL_INTERFACES
203
204 Boolean equal(const char* name) const;
205
206 CIMName& operator=(const char* name);
207
208 #endif /* PEGASUS_USE_EXPERIMENTAL_INTERFACES */
209
|
210 mike 1.11 private:
|
211 kumpf 1.17 String cimName;
|
212 r.kieninger 1.34 friend class CIMNameUnchecked;
|
213 kumpf 1.17 };
214
|
215 david.dillard 1.32 /**
216 Compares two CIMNames to determine if they are equal.
217
218 @param name1 One name to compare.
219 @param name2 Another name to compare
220 @return Returns true if the names are equal, false if they are not.
221
222 CIMNames are not case sensitive, therefore the output of the
223 following example is "Equal".
224
225 <pre>
226 CIMName lowerCaseName("this_is_a_name");
227 CIMName upperCaseName("THIS_IS_A_NAME");
228
229 if (lowerCaseName == upperCaseName)
230 {
231 puts("Equal");
232 }
233 else
234 {
235 puts("Not equal");
236 david.dillard 1.32 }
237 </pre>
238 */
|
239 kumpf 1.18 PEGASUS_COMMON_LINKAGE Boolean operator==(
240 const CIMName& name1,
241 const CIMName& name2);
|
242 kumpf 1.17
|
243 david.dillard 1.32 /**
244 Compares two CIMNames to determine if they are not equal.
245
246 @param name1 One name to compare.
247 @param name2 Another name to compare
248 @return Returns true if the names are not equal, false if they are.
249
250 The output of the following example is "Not equal".
251
252 <pre>
253 CIMName name1("this_is_a_name");
254 CIMName name2("this is another_name");
255
256 if (name1 != name2)
257 {
258 puts("Not equal");
259 }
260 else
261 {
262 puts("Equal");
263 }
264 david.dillard 1.32 </pre>
265 */
|
266 david.dillard 1.31 PEGASUS_COMMON_LINKAGE Boolean operator!=(
267 const CIMName& name1,
268 const CIMName& name2);
269
|
270 kumpf 1.17 #define PEGASUS_ARRAY_T CIMName
271 # include "ArrayInter.h"
272 #undef PEGASUS_ARRAY_T
273
274
275 ////////////////////////////////////////////////////////////////////////////////
276 //
277 // CIMNamespaceName
278 //
279 ////////////////////////////////////////////////////////////////////////////////
280
281 /**
|
282 kumpf 1.19 The CIMNamespaceName class defines methods for handling CIM namespace names.
|
283 kumpf 1.17 <p>
284 A CIM namespace name must match the following expression:
285 <PRE>
|
286 karl 1.24 <CIMName>[ / <CIMName> ]*
|
287 kumpf 1.17 </PRE>
|
288 kumpf 1.22 </p>
|
289 karl 1.23 <B>Examples</B>
290 <UL>
291 <LI>root
292 <LI>root/test
293 </UL>
294 NOTE: Pegasus uses namespaces starting with the top level name (ex. root). It does
|
295 karl 1.24 not use the form /root/test with a leading slash. The legal() test method in this class
|
296 karl 1.23 allows that form as a legal entity however.
|
297 kumpf 1.17 */
298 class PEGASUS_COMMON_LINKAGE CIMNamespaceName
299 {
300 public:
301
|
302 karl 1.23 /** Default constructor sets object Null. The Null state
|
303 david.dillard 1.32 indicates that there is no name assigned to this object.
304 The Null state can be tested with the isNull() method and
305 set with the clear() method.
306 */
|
307 kumpf 1.17 CIMNamespaceName();
|
308 karl 1.23
309 /** Constructor builds namespace from input String.
|
310 david.dillard 1.32 The String input must be a legal namespace name.
311 @param String from which the namespace object is built.
312 This must be a legal namespace name.
313 @exeception InvalidNamespaceName exception thrown if
314 the namespace name input is illegal.
315 */
|
316 kumpf 1.17 CIMNamespaceName(const String& name);
|
317 karl 1.23
318 /** Constructor builds namespace from input char*.
|
319 david.dillard 1.32 The String input must be a legal namespace name.
320 @param char* from which the namespace object is built.
321 This must be a legal namespace name.
322 @exeception InvalidNamespaceName exception thrown if
323 the namespace name input parameter is illegal.
324 */
|
325 kumpf 1.17 CIMNamespaceName(const char* name);
326
|
327 karl 1.23 /** Assign one namespace object to another.
|
328 david.dillard 1.32 @param CIMNamespaceName to assign to the object.
329 */
|
330 kumpf 1.17 CIMNamespaceName& operator=(const CIMNamespaceName& name);
|
331 karl 1.23
332 /** Assign a String object to a CIMNamespaceName object.
|
333 david.dillard 1.32 @param CIMNamespaceName to assign
334 @exeception InvalidNamespaceName exception thrown if
335 the namespace name input parameter is illegal.
336 <pre>
337 String s = "root/test";
338 CIMNamespacename ns;
339 ns = s;
340 </pre>
341 */
|
342 kumpf 1.17 CIMNamespaceName& operator=(const String& name);
|
343 kumpf 1.20
|
344 karl 1.23 /** Extracts the String value of the CIMNamespaceName
|
345 david.dillard 1.32 from the object.
346 @return String containing the name.
347 <pre>
348 CIMNamespaceName ns("root/test");
349 String s = ns.getString();
350 </pre>
351 */
|
352 kumpf 1.20 const String& getString() const;
|
353 kumpf 1.17
|
354 karl 1.23 /** Tests the CIMNamespaceName for NULL attribute. Returns
|
355 david.dillard 1.32 true if Null. New objects without parameter and objects
356 set with clear() are Null. When a name is set into the
357 object is is set to nonnull. When the object is Null, it
358 returns empty string.
359 @return true if Null or false if not Null.
360 <pre>
361 CIMName n;
362 assert(n.isNull());
363 n = "name";
364 assert(!n.isNull());
365 </pre>
366 */
|
367 kumpf 1.17 Boolean isNull() const;
368
|
369 karl 1.23 /** Clears the CIMNamespaceName and sets it to Null. A Null
|
370 david.dillard 1.32 object contains no name so that accessing it with getString
371 should return an empty String
372 <pre>
|
373 r.kieninger 1.34 CIMNamespaceName ns("root/test");
|
374 david.dillard 1.32 ns.clear();
375 assert(ns.isNull());
376 </pre>
377 */
|
378 kumpf 1.17 void clear();
379
|
380 karl 1.23 /** Compares two CIMNamespace objects for equality.
|
381 david.dillard 1.32 @return true if the name passed is equal to the name in this
|
382 kumpf 1.22 class. CIM names are case insensitive and so is this method.
|
383 david.dillard 1.32 <pre>
|
384 r.kieninger 1.34 CIMNamespaceName ns("root/test");
385 CIMNamespaceName ns1("root/test");
|
386 david.dillard 1.32 assert( ns.equal(ns1);
387 </pre>
|
388 kumpf 1.17 */
389 Boolean equal(const CIMNamespaceName& name) const;
|
390 mike 1.11
|
391 kumpf 1.22 /** Determines if the name string input is legal as
|
392 david.dillard 1.32 defined in the CIMNamespaceName class definition.
393 @param name String to test for legality.
394 @return true if the given name is legal, false otherwise.
395 <pre>
396 assert(CIMNamespaceName::legal("root/test"));
397 </pre>
|
398 kumpf 1.17 */
|
399 kumpf 1.21 static Boolean legal(const String& name);
|
400 kumpf 1.17
|
401 r.kieninger 1.34 #ifdef PEGASUS_USE_EXPERIMENTAL_INTERFACES
402
403 Boolean equal(const char* name) const;
404
405 CIMNamespaceName& operator=(const char* name);
406
407 #endif /* PEGASUS_USE_EXPERIMENTAL_INTERFACES */
408
|
409 kumpf 1.17 private:
410 String cimNamespaceName;
|
411 mike 1.11 };
|
412 kumpf 1.20
413 PEGASUS_COMMON_LINKAGE Boolean operator==(
414 const CIMNamespaceName& name1,
415 const CIMNamespaceName& name2);
416
|
417 david.dillard 1.31 PEGASUS_COMMON_LINKAGE Boolean operator!=(
418 const CIMNamespaceName& name1,
419 const CIMNamespaceName& name2);
420
|
421 kumpf 1.20 #define PEGASUS_ARRAY_T CIMNamespaceName
422 # include "ArrayInter.h"
423 #undef PEGASUS_ARRAY_T
|
424 mike 1.11
425 PEGASUS_NAMESPACE_END
426
|
427 r.kieninger 1.34 #ifdef PEGASUS_INTERNALONLY
428 # include "CIMNameInline.h"
429 #endif
430
|
431 mike 1.11 #endif /* Pegasus_Name_h */
|