(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            //%/////////////////////////////////////////////////////////////////////////////
 27            
 28            #ifndef Pegasus_Name_h
 29            #define Pegasus_Name_h
 30            
 31            #include <Pegasus/Common/Config.h>
 32 kumpf 1.17 #include <Pegasus/Common/Linkage.h>
 33 mike  1.11 #include <Pegasus/Common/String.h>
 34 kumpf 1.17 #include <Pegasus/Common/Array.h>
 35            #include <Pegasus/Common/Exception.h>
 36 mike  1.11 
 37            PEGASUS_NAMESPACE_BEGIN
 38            
 39 kumpf 1.17 ////////////////////////////////////////////////////////////////////////////////
 40            //
 41            // CIMName
 42            //
 43            ////////////////////////////////////////////////////////////////////////////////
 44            
 45 mike  1.11 /**
 46 kumpf 1.17     The CIMName class defines methods for handling CIM names.
 47 kumpf 1.14     <p>
 48 mike  1.11     The names of classes, properties, qualifiers, and methods are all
 49                CIM names. A CIM name must match the following regular
 50                expression:
 51                <PRE>
 52            	[A-Z-a-z_][A-Za-z_0-9]*
 53                </PRE>
 54 karl  1.23     <B>Examples:</B>
 55                <ul>
 56                <li>name - legal name
 57                <li>Type - legal name
 58                <li>3types - Illegal CIMName.
 59                </ul>
 60                The CIMName object includes the attribute Null which is required
 61                by the DMTF operations definitions.  Note that this and the regular
 62                expression limits on CIMName are what separate this from the String
 63                class. This allows the names in CIM operations such as getClass to 
 64                provide pattern matching tests for the classname parameter as well as
 65                separate the concept of empty from Null.
 66                
 67 mike  1.11 */
 68            class PEGASUS_COMMON_LINKAGE CIMName
 69            {
 70            public:
 71            
 72 karl  1.23     /** Default constructor (sets isNull to true).
 73                */
 74 kumpf 1.17     CIMName();
 75 karl  1.23 
 76            	/** Constructor creates a new CIMName object from
 77            	    the String provided as input. The String must
 78            	    be a legal name.
 79            	    @param String defining the CIMName
 80            	    @Exception InvalidNameException if the input String is 
 81            	    not a legal CIMName
 82                */
 83 kumpf 1.17     CIMName(const String& name);
 84 karl  1.23     /**
 85            	Constructor creates a new CIMName object from
 86            			the String provided as input. The String must
 87            			be a legal name.
 88            			@param char* defining the CIMName text.
 89            			@Exception InvalidNameException if the input String is 
 90            			not a legal CIMName
 91            	*/
 92 kumpf 1.17     CIMName(const char* name);
 93            
 94 karl  1.23     /**	Copy Constructor for CIMName object
 95            	*/
 96 kumpf 1.17     CIMName& operator=(const CIMName& name);
 97 karl  1.23     /**	Copy constructor String object. Allows copying
 98            	    String value into a CIMName.
 99            	    @param String to be copied into CIMName
100            	    @exception InvalidNameException if the input String
101            	    is not a legal CIMName
102            	    <pre>
103            			CIMName n;
104            			String type = "type";
105            			n = type;
106            	    </pre>
107            	*/
108 kumpf 1.17     CIMName& operator=(const String& name);
109 kumpf 1.20 
110 karl  1.23     /** Extracts the String value of the CIMName
111            	    from the CIMName object.
112            	    @return String containing the name.
113            	    <pre>
114            			CIMName n("name");
115            			String s = n.getString();
116            	    </pre>
117            	*/
118 kumpf 1.20     const String& getString() const;
119 kumpf 1.17 
120 karl  1.23     /**	Tests the CIMName for NULL attribute.
121            	    @return true if Null or false if not Null.
122            	    <pre>
123            			CIMName n;
124            			assert(n.isNull());
125            			n = "name";
126            			assert(!n.isNull());
127            	    </pre>
128            	*/
129 kumpf 1.17     Boolean isNull() const;
130            
131 karl  1.23     /**	Clears the CIMName and sets it to Null.
132            	    <pre>
133            		CIMMame n("name");
134            		n.clear();
135            		assert(n.isNull());
136            	    </pre>
137            	*/
138 kumpf 1.17     void clear();
139            
140 karl  1.23     /** Compares the CIMName object against another CIMName object for equality.
141            	    @param CIMName to compare.
142            		@return true if the name passed is equal to the name in this
143 kumpf 1.22         class. CIM names are case insensitive and so is this method.
144 karl  1.23 	    <pre>
145            	    CIMName n1 = "name";
146            	    CIMName n2 = "InstanceID";
147            	    if( n1.equal(n2) )
148            		    ...						// Should never get here
149            	    else
150            		    ...
151            	    </pre>
152 kumpf 1.17     */
153                Boolean equal(const CIMName& name) const;
154            
155 kumpf 1.22     /** Determines if the name string input is legal as
156 karl  1.23 		defined in the CIMName class definition. This is a static
157            		method used to test String values to determine if they are
158            		legal names.
159            		@param name String to test for legality.
160            		@return true if the given name is legal, false otherwise.
161            	<pre>
162            	    assert(CIMName::legal("name"));
163            	    assert(!CIMName::legal("3types"));
164            	</pre>
165 mike  1.11     */
166 kumpf 1.21     static Boolean legal(const String& name);
167 mike  1.11 
168            private:
169 kumpf 1.17     String cimName;
170            };
171            
172 kumpf 1.18 PEGASUS_COMMON_LINKAGE Boolean operator==(
173                const CIMName& name1,
174                const CIMName& name2);
175 kumpf 1.17 
176            #define PEGASUS_ARRAY_T CIMName
177            # include "ArrayInter.h"
178            #undef PEGASUS_ARRAY_T
179            
180            
181            ////////////////////////////////////////////////////////////////////////////////
182            //
183            // CIMNamespaceName
184            //
185            ////////////////////////////////////////////////////////////////////////////////
186            
187            /**
188 kumpf 1.19     The CIMNamespaceName class defines methods for handling CIM namespace names.
189 kumpf 1.17     <p>
190                A CIM namespace name must match the following expression:
191                <PRE>
192 karl  1.24         &lt;CIMName&gt;[ / &lt;CIMName&gt; ]*
193 kumpf 1.17     </PRE>
194 kumpf 1.22     </p>
195 karl  1.23     <B>Examples</B>
196                <UL>
197                <LI>root
198                <LI>root/test
199                </UL>
200                NOTE: Pegasus uses namespaces starting with the top level name (ex. root).  It does
201 karl  1.24     not use the form /root/test with a leading slash.  The legal() test method in this class
202 karl  1.23     allows that form as a legal entity however.
203 kumpf 1.17 */
204            class PEGASUS_COMMON_LINKAGE CIMNamespaceName
205            {
206            public:
207            
208 karl  1.23     /** Default constructor sets object Null. The Null state
209            	    indicates that there is no name assigned to this object.
210            	    The Null state can be tested with the isNull() method and
211            	    set with the clear() method.
212            	*/
213 kumpf 1.17     CIMNamespaceName();
214 karl  1.23 
215                /** Constructor builds namespace from input String.
216            	    The String input must be a legal namespace name.
217            	    @param String from which the namespace object is built.
218            	    This must be a legal namespace name.
219            	    @exeception InvalidNamespaceName exception thrown if
220            	    the namespace name input is illegal.
221            	*/
222 kumpf 1.17     CIMNamespaceName(const String& name);
223 karl  1.23 
224                /** Constructor builds namespace from input char*.
225            	    The String input must be a legal namespace name.
226            	    @param char* from which the namespace object is built.
227            	    This must be a legal namespace name.
228            	    @exeception InvalidNamespaceName exception thrown if
229            	    the namespace name input parameter is illegal.
230            	*/    
231 kumpf 1.17     CIMNamespaceName(const char* name);
232            
233 karl  1.23     /** Assign one namespace object to another.
234            		@param CIMNamespaceName to assign to the object.
235            	*/
236 kumpf 1.17     CIMNamespaceName& operator=(const CIMNamespaceName& name);
237 karl  1.23 
238                /** Assign a String object to a CIMNamespaceName object.
239            		@param CIMNamespaceName to assign
240            		@exeception InvalidNamespaceName exception thrown if
241            		the namespace name input parameter is illegal.
242            	    <pre>
243            			String s = "root/test";
244            			CIMNamespacename ns;
245            			ns = s;
246            	    </pre>
247            	*/
248 kumpf 1.17     CIMNamespaceName& operator=(const String& name);
249 kumpf 1.20 
250 karl  1.23     /** Extracts the String value of the CIMNamespaceName
251            	    from the object.
252            	    @return String containing the name.
253            	    <pre>
254            			CIMNamespaceName ns("root/test");
255            			String s = ns.getString();
256            	    </pre>
257            	*/
258 kumpf 1.20     const String& getString() const;
259 kumpf 1.17 
260 karl  1.23     /**	Tests the CIMNamespaceName for NULL attribute. Returns
261            	    true if Null.  New objects without parameter and objects
262            	    set with clear() are Null.  When a name is set into the
263            	    object is is set to nonnull.  When the object is Null, it
264            	    returns empty string.
265            	    @return true if Null or false if not Null.
266            	    <pre>
267            			CIMName n;
268            			assert(n.isNull());
269            			n = "name";
270            			assert(!n.isNull());
271            	    </pre>
272            	*/
273 kumpf 1.17     Boolean isNull() const;
274            
275 karl  1.23     /**	Clears the CIMNamespaceName and sets it to Null. A Null
276            	    object contains no name so that accessing it with getString
277            	    should return an empty String
278            	    <pre>
279            			CIMMamespaceName ns("root/test");
280            			ns.clear();
281            			assert(ns.isNull());
282            	    </pre>
283            	*/
284 kumpf 1.17     void clear();
285            
286 karl  1.23     /** Compares two CIMNamespace objects for equality.
287            		@return true if the name passed is equal to the name in this
288 kumpf 1.22         class. CIM names are case insensitive and so is this method.
289 karl  1.23 		<pre>
290            		CIMMamespaceName ns("root/test");
291            		CIMMamespaceName ns1("root/test");
292            		assert( ns.equal(ns1);
293            	    </pre>
294 kumpf 1.17     */
295                Boolean equal(const CIMNamespaceName& name) const;
296 mike  1.11 
297 kumpf 1.22     /** Determines if the name string input is legal as
298 karl  1.23 	defined in the CIMNamespaceName class definition.
299 kumpf 1.22 	@param name String to test for legality.
300            	@return true if the given name is legal, false otherwise.
301 karl  1.23 	<pre>
302            		assert(CIMNamespaceName::legal("root/test"));
303            	</pre>
304 kumpf 1.17     */
305 kumpf 1.21     static Boolean legal(const String& name);
306 kumpf 1.17 
307            private:
308                String cimNamespaceName;
309 mike  1.11 };
310 kumpf 1.20 
311            PEGASUS_COMMON_LINKAGE Boolean operator==(
312                const CIMNamespaceName& name1,
313                const CIMNamespaceName& name2);
314            
315            #define PEGASUS_ARRAY_T CIMNamespaceName
316            # include "ArrayInter.h"
317            #undef PEGASUS_ARRAY_T
318 mike  1.11 
319            PEGASUS_NAMESPACE_END
320            
321            #endif /* Pegasus_Name_h */

No CVS admin address has been configured
Powered by
ViewCVS 0.9.2