(file) Return to CIMName.h CVS log (file) (dir) Up to [Pegasus] / pegasus / src / Pegasus / Common

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

No CVS admin address has been configured
Powered by
ViewCVS 0.9.2