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

  1 david 1.1.2.1 //%2004////////////////////////////////////////////////////////////////////////
  2               //
  3               // Copyright (c) 2004 BMC Software; Hewlett-Packard Development Company, L. P.;
  4               // IBM Corp.; EMC Corporation, The Open Group.
  5               //
  6               // Permission is hereby granted, free of charge, to any person obtaining a copy
  7               // of this software and associated documentation files (the "Software"), to
  8               // deal in the Software without restriction, including without limitation the
  9               // rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
 10               // sell copies of the Software, and to permit persons to whom the Software is
 11               // furnished to do so, subject to the following conditions:
 12               // 
 13               // THE ABOVE COPYRIGHT NOTICE AND THIS PERMISSION NOTICE SHALL BE INCLUDED IN
 14               // ALL COPIES OR SUBSTANTIAL PORTIONS OF THE SOFTWARE. THE SOFTWARE IS PROVIDED
 15               // "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT
 16               // LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
 17               // PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
 18               // HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
 19               // ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
 20               // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
 21               //
 22 david 1.1.2.1 //==============================================================================
 23               //
 24               // Author: Dave Rosckes (rosckes@us.ibm.com)
 25               //
 26               // Modified By:
 27               //
 28               //%/////////////////////////////////////////////////////////////////////////////
 29               
 30               #ifndef PEGASUS_CQLVALUEREP_H
 31               #define PEGASUS_CQLVALUEREP_H
 32               
 33               
 34               #include <Pegasus/Common/Config.h>
 35               #include <Pegasus/Common/CIMInstance.h>
 36               #include <Pegasus/Common/String.h>
 37               #include <Pegasus/CQL/QueryContext.h>
 38               #include <Pegasus/Common/CIMObjectPath.h>
 39               #include <Pegasus/CQL/CQLChainedIdentifier.h>
 40               #include <Pegasus/CQL/CQLScope.h>
 41               #include <Pegasus/CQL/Linkage.h>
 42               
 43 david 1.1.2.1 PEGASUS_NAMESPACE_BEGIN
 44               class PEGASUS_CQL_LINKAGE CQLFactory;
 45                   enum NumericType { Hex, Binary,  Decimal, Real};
 46                   enum CQLValueType { Null_type, Sint64_type, Uint64_type, Real_type, String_type,
 47                                       CIMDateTime_type,  CIMReference_type, CQLIdentifier_type,
 48                                       CIMInstance_type, CQLIgnore_type, Boolean_type, 
 49                                       CIMClass_type};
 50               
 51               /** The CQLValueRep class encapulates a value
 52                    that is a CQL value.  The possible CQLValue
 53                    types are the following:
 54               
 55                        Sint64
 56                        Uint64
 57                        String
 58                        CIMDateTime
 59                        CIMReference
 60                        CQLIdentifier
 61               
 62               
 63                    This class can resolve an identifier to a primitive 
 64 david 1.1.2.1      value such as Sint64, Uint64 or String, CIMDateTime,
 65                    and CIMReference.  
 66               
 67                   This class overloads and performs type checking
 68                    on the following operators:
 69                        <, >, =, >=. <=. <>
 70               
 71                   This class overloads, performs type checking and
 72                    uint64 handling on the following operators:
 73                          +. -. *, /
 74               
 75                   NOTE:  the CQLValue class assumes a symbolic constant
 76                               is fully qualified.
 77               
 78                 */
 79               
 80               class PEGASUS_CQL_LINKAGE CQLValueRep
 81               {
 82                 public:
 83                   /**  Initializes object as a string.
 84                      */
 85 david 1.1.2.1 
 86 humberto 1.1.2.3     CQLValueRep();
 87 david    1.1.2.1     ~CQLValueRep();
 88                      CQLValueRep(const CQLValueRep* val);
 89                      CQLValueRep(String inString, NumericType inValueType,
 90                          Boolean inSign = true);
 91                  
 92                      /**  Initializes object as a CQLIdentifier.
 93                         */
 94                      CQLValueRep(CQLChainedIdentifier inCQLIdent);
 95                  
 96                     /**  Initializes object as a CIMObjectPath.
 97                         */
 98                      CQLValueRep(CIMObjectPath inObjPath);
 99                  
100                     /**  Initializes object as a CIMDateTime.
101                         */
102                      CQLValueRep(CIMDateTime inDateTime);
103                  
104                      /**  Initializes object as a literal string (non-numeric).
105                         */
106                      CQLValueRep(String inString);
107                  
108 david    1.1.2.1    CQLValueRep(Sint64 inSint);
109                     CQLValueRep(Uint64 inUint);
110                     CQLValueRep(Real64 inReal);
111                     CQLValueRep(CIMInstance inInstance);
112                     CQLValueRep(Boolean inBool);
113                     CQLValueRep(CIMClass inClass);
114                  
115                      /**  This method is used to ask an identifier to resolve itself to 
116                             a number or string (primitive value).
117                      
118                            Resolves:
119                             - symbolic constants
120                             - indexing an array
121                             - decoding identifier
122                                  * URI reference
123                                  * embedded object (e.g. myclass.embeddedobject.prop1)
124                                      and this is recursive
125                             - class aliasing
126                       */
127                  
128                      void resolve(CIMInstance CI, QueryContext& inQueryCtx);
129 david    1.1.2.1 
130                      CQLValueRep& operator=(const CQLValueRep& rhs);
131                  
132                      /** operator == compares two CQLValue objects for equality and
133                                              performs type checking.
134                          @param x - First CQLValue to compare
135                          @param y - Second CQLValue to compare
136                          @return true if they are identical in type, attribute and value,
137                          false otherwise.
138                      */
139                  
140                      Boolean operator==(const CQLValueRep& x);
141                  
142                      /** operator == compares two CQLValue objects for inequality and
143                                              performs type checking.
144                          @param x - First CQLValue to compare
145                          @param y - Second CQLValue to compare
146                          @return true if they are NOT identical in type, attribute and value,
147                          false otherwise.
148                      */
149                  
150 david    1.1.2.1     Boolean operator!=(const CQLValueRep& x);
151                  
152                      /** operator <= compares two CQLValue objects to see if x is less than or
153                                              equal to y and performs type checking.
154                          @param x - First CQLValue to compare
155                          @param y - Second CQLValue to compare
156                          @return true if x is less than or equal to y,
157                          false otherwise.
158                      */
159                  
160                      Boolean operator<=(const CQLValueRep& x);
161                  
162                      /** operator >= compares two CQLValue objects to see if x is greater than or
163                                              equal to y and performs type checking.
164                          @param x - First CQLValue to compare
165                          @param y - Second CQLValue to compare
166                          @return true if x is greater than or equal to y,
167                          false otherwise.
168                      */
169                  
170                      Boolean operator>=(const CQLValueRep& x);
171 david    1.1.2.1 
172                      /** The overload operator (<) compares CQLValue obects and
173                            performs type checking.
174                          <pre>
175                              CQLValue   val1 = "def";
176                              CQLValue   val2 = "a";
177                              assert (val2 < val1);
178                          </pre>
179                      */
180                  
181                      Boolean operator<(const CQLValueRep& val1);
182                  
183                      /** The overload operator (>) compares CQLValue obects and
184                            performs type checking.
185                          <pre>
186                              CQLValue   val1 = "def";
187                              CQLValue   val2 = "a";
188                              assert (val2 < val1);
189                          </pre>
190                      */
191                  
192 david    1.1.2.1     Boolean operator>(const CQLValueRep& val1);
193                  
194                      /** This overload operator (+) concatenates or adds the value of
195                      CQLValue objects and performs type checking and Uint64 handling.
196                            For example, 
197                          <pre>
198                              CQLValue  t1 = "abc";  // it's a string type
199                              CQLValue  t2 = "def";   // it's another string type
200                              CQLValue   t3 = t1 + t2;
201                              assert(t3 == "abcdef");
202                          </pre>
203                      */
204                   
205                      CQLValueRep operator+(const CQLValueRep x);
206                  
207                      /** This overload operator (-) subtracts the value of CQLValue
208                            objects and performs type checking and Uint64 handling.
209                            For example, 
210                          <pre>
211                              CQLValue  t1 = 5;  
212                              CQLValue  t2 = 2;   
213 david    1.1.2.1             CQLValue   t3 = t1 - t2;
214                              assert(t3 == 3);
215                          </pre>
216                      */
217                   
218                      CQLValueRep operator-(const CQLValueRep& x);
219                  
220                      /** This overload operator (*) multiplies the values of CQLValue
221                            objects and performs type checking and Uint64 handling.
222                            For example, 
223                          <pre>
224                              CQLValue  t1 = 3;  
225                              CQLValue  t2 = 2;   
226                              CQLValue   t3 = t1 *  t2;
227                              assert(t3 == 6);
228                          </pre>
229                      */
230                  
231                      CQLValueRep operator*(const CQLValueRep& x);
232                  
233                      /** This overload operator (*) divides the values of CQLValue
234 david    1.1.2.1           objects and performs type checking and Uint64 handling.
235                            For example, 
236                          <pre>
237                              CQLValue  t1 = 6;  
238                              CQLValue  t2 = 2;   
239                              CQLValue   t3 = t1 /  t2;
240                              assert(t3 == 2);
241                          </pre>
242                      */
243                  
244                      CQLValueRep operator/(const CQLValueRep& x);
245                  
246                      /** Accessor for getting the type of the CQLValue.
247                      
248                      TODO:  do we need this method?
249                        */
250                  
251                      CQLValueType getValueType();
252                  
253                      /** Clears this object and sets its type to NULL_VALUE
254                        */
255 david    1.1.2.1 
256                      void setNull();
257                  
258                      /** Returns whether the value has been resolved to a primitive.
259                        */
260                  
261                      Boolean isResolved();
262                  
263                      /** Returns whether the CQLValue is null.
264                        */
265                  
266                      Boolean isNull();
267                  
268                      /** Tests to see if this "isa" the input string.
269                      */
270                  
271                      Boolean isa(const CQLValueRep& inVal, QueryContext& QueryCtx);
272                  
273                      /** Tests to see if this "like" the input string.
274                            Both sides of the LIKE comparison must have a String type:
275                            the result is a Boolean type.
276 david    1.1.2.1     
277                           The LIKE comparison allows a string to be tested by pattern-matching,
278                            using special characters n the right-hand-side string.
279                            See the DMTF CQL Specification for details.
280                      
281                            For Basic Query, the left-hand expression (this) may be restricted to
282                      chain, and 
283                            the right-hand expression may be restricted to be a literal-string.
284                      */
285                  
286                      Boolean like(const CQLValueRep& inVal);
287                     
288                     void invert();
289                     CQLChainedIdentifier getChainedIdentifier()const;
290                     Uint64 getUint()const;
291                     Sint64 getSint()const;
292                     Real64 getReal()const;
293                     String getString()const;
294                     Boolean getBool()const;
295                     CIMDateTime getDateTime()const;
296                     CIMObjectPath getReference()const;
297 david    1.1.2.1    CIMInstance getInstance()const;
298                     CIMClass getClass()const;
299                     String toString()const;
300 humberto 1.1.2.2    void applyContext(QueryContext& _ctx);
301 david    1.1.2.1    void applyScopes(Array<CQLScope> inScopes);
302                     friend class CQLFactory; 
303                     friend class CQLValue;
304                    private:
305                      Boolean _areClassesInline(CIMClass c1,CIMClass c2, QueryContext& in);
306                     Boolean _validate(const CQLValueRep& x);
307                     
308                     void _setValue(CIMValue cv, Uint64 Index = 0);
309                  
310                     union TheValue
311                      {
312                        Boolean _B;
313                        Sint64 _S64;
314                        Uint64 _U64;
315                        Real64 _R64;
316                        String* _S;
317                        CIMDateTime* _DT;
318                        CIMObjectPath* _OP;
319                        CIMInstance* _IN;
320                        CIMClass* _CL;
321                      } _theValue;
322 david    1.1.2.1 
323                  
324                      CQLChainedIdentifier _CQLChainId;
325                  
326                      Boolean _isResolved;
327                  
328                      NumericType Num_Type;
329                  
330                     CQLValueType _valueType;
331                  
332                  
333                  
334                  };
335                  
336                  #ifndef PEGASUS_ARRAY_T
337                  #define PEGASUS_ARRAY_T CQLValueRep
338                  #include <Pegasus/Common/ArrayInter.h>
339                  #undef PEGASUS_ARRAY_T
340                  #endif
341                  
342                  PEGASUS_NAMESPACE_END
343 david    1.1.2.1 
344                  #endif /* CQLVALUEREP_H */

No CVS admin address has been configured
Powered by
ViewCVS 0.9.2