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

File: [Pegasus] / pegasus / src / Pegasus / CQL / CQLValue.h (download)
Revision: 1.3, Mon Nov 29 21:26:24 2004 UTC (19 years, 7 months ago) by david
Branch: MAIN
CVS Tags: pegasus25BeforeLicenseUpdate, SLPPERFINST-root, SLPPERFINST-branch, PEP213_SIZE_OPTIMIZATIONS
Changes since 1.2: +251 -123 lines
PEP#: 193
TITLE: CQL Updates

DESCRIPTION: CQL Updates

//%2003////////////////////////////////////////////////////////////////////////
//
// Copyright (c) 2000, 2001, 2002  BMC Software, Hewlett-Packard Development
// Company, L. P., IBM Corp., The Open Group, Tivoli Systems.
// Copyright (c) 2003 BMC Software; Hewlett-Packard Development Company, L. P.;
// IBM Corp.; EMC Corporation, The Open Group.
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to
// deal in the Software without restriction, including without limitation the
// rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
// sell copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
// 
// THE ABOVE COPYRIGHT NOTICE AND THIS PERMISSION NOTICE SHALL BE INCLUDED IN
// ALL COPIES OR SUBSTANTIAL PORTIONS OF THE SOFTWARE. THE SOFTWARE IS PROVIDED
// "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT
// LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
// PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
// HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
// ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
//==============================================================================
//
// Author: Dave Rosckes (rosckes@us.ibm.com)
//
// Modified By:
//
//%/////////////////////////////////////////////////////////////////////////////

#ifndef PEGASUS_CQLVALUE_H
#define PEGASUS_CQLVALUE_H


#include <Pegasus/Common/Config.h>

#include <Pegasus/Common/CIMInstance.h>
#include <Pegasus/Common/ArrayInternal.h>
#include <Pegasus/Common/String.h>
#include <Pegasus/Query/QueryCommon/QueryContext.h>
#include <Pegasus/Common/CIMObjectPath.h>
#include <Pegasus/CQL/CQLChainedIdentifier.h>

#include <Pegasus/CQL/Linkage.h>

#ifdef PEGASUS_USE_EXPERIMENTAL_INTERFACES

PEGASUS_NAMESPACE_BEGIN
class PEGASUS_CQL_LINKAGE CQLFactory;
class PEGASUS_CQL_LINKAGE CQLValueRep;

/** The CQLValue class encapulates a value
    that is a CQL value.  The possible CQLValue
    types are the following:
    
    Sint64
    Uint64
    String
    CIMDateTime
    CIMReference
    CQLIdentifier
    
    
    This class can resolve an identifier to a primitive 
    value such as Sint64, Uint64 or String, CIMDateTime,
    and CIMReference.  
    
    This class overloads and performs type checking
    on the following operators:
    <, >, =, >=. <=. <>

    
    NOTE:  the CQLValue class assumes a symbolic constant
    is fully qualified.
    
*/

class PEGASUS_CQL_LINKAGE CQLValue
{
 public:

  enum NumericType  { Hex, Binary,  Decimal, Real};
  enum CQLValueType { Null_type, Sint64_type, Uint64_type, Real_type, String_type,
		      CIMDateTime_type,  CIMReference_type, CQLIdentifier_type,
		      CIMObject_type, Boolean_type};

  /** 
      Contructs CQLValue default object.
      
      @param  - None.
      @return - None.
      @throw  - None.
      <I><B>Experimental Interface</B></I><BR>
  */
  CQLValue();

  /** 
      Destroys CQLValue object.
      
      @param  - None.
      @return - None.
      @throw  - None.
      <I><B>Experimental Interface</B></I><BR>
  */
  ~CQLValue()

  /** 
      Contructs CQLValue object (Copy-Constructor).
      
      @param  - None.
      @return - None.
      @throw  - None.
      <I><B>Experimental Interface</B></I><BR>
  */;
  CQLValue(const CQLValue& val);

  /** 
      Contructs CQLValue object given a string and a numbericType
      
      @param  - inString - the string representation of a number
      @param  - inValueType - the NumericType
      @return - None.
      @throw  - None.
      <I><B>Experimental Interface</B></I><BR>
  */
  CQLValue(String inString, NumericType inValueType,
	   Boolean inSign = true);
  
  /**  
      Contructs CQLValue object via CQLChainedIdentifier.
      
      @param  - inCQLIdent - The CQLChained Identifer used to create the object
      @return - None.
      @throw  - None.
      <I><B>Experimental Interface</B></I><BR>
  */
  CQLValue(CQLChainedIdentifier inCQLIdent);
  
  /**
      Initializes object as a CIMObjectPath.

      @param  - inObjPath - CIMObjectPath use to construct object.
      @return - None.
      @throw  - None.
      <I><B>Experimental Interface</B></I><BR>
  */
  CQLValue(CIMObjectPath inObjPath);
  
  /**
      Initializes object as a CIMDateTime.

      @param  - inDateTime - used to construct object.
      @return - None.
      @throw  - None.
      <I><B>Experimental Interface</B></I><BR>
  */
  CQLValue(CIMDateTime inDateTime);
  
  /**  
      Initializes object as a literal string (non-numeric).

      @param  - inString - String used to construct object.
      @return - None.
      @throw  - None.
      <I><B>Experimental Interface</B></I><BR>
  */
  CQLValue(String inString);
  
  /** 
      Initializes object as an Sint64.
      
      @param  - inSint - Sint64 used to contruct object.
      @return - None.
      @throw  - None.
      <I><B>Experimental Interface</B></I><BR>
  */
  CQLValue(Sint64 inSint);

  /** 
      Initializes object as a Uint64
      
      @param  - inUint - Uint64 used to construct object.
      @return - None.
      @throw  - None.
      <I><B>Experimental Interface</B></I><BR>
  */
  CQLValue(Uint64 inUint);

  /** 
      Initializes object as a Real64
      
      @param  - inReal - Real64 used to construct object.
      @return - None.
      @throw  - None.
      <I><B>Experimental Interface</B></I><BR>
  */
  CQLValue(Real64 inReal);
  
  /** 
      Initializes object as a CIMInstance
      
      @param  - inInstance - CIMInstance used to construct object.
      @return - None.
      @throw  - None.
      <I><B>Experimental Interface</B></I><BR>
  */
  CQLValue(CIMInstance inInstance);

  /** 
      Initializes object as a Boolean
      
      @param  - inBool - inBool used to construct object.
      @return - None.
      @throw  - None.
      <I><B>Experimental Interface</B></I><BR>
  */
  CQLValue(Boolean inBool);

  /** 
      Initializes object as a inClass
      
      @param  - inClass - CIMClass used to construct object.
      @return - None.
      @throw  - None.
      <I><B>Experimental Interface</B></I><BR>
  */
  CQLValue(CIMClass inClass);

  /** 
      Initializes object as a CQLValueRep
      
      @param  - rhs - CQLValueRep used to construct object.
      @return - None.
      @throw  - None.
      <I><B>Experimental Interface</B></I><BR>
  */
  CQLValue(CQLValueRep rhs);

  /** 
      Initializes object as a CIMObject
      
      @param  - inObject - CIMObject used to construct object.
      @return - None.
      @throw  - None.
      <I><B>Experimental Interface</B></I><BR>
  */
  CQLValue(CIMObject inObject);

  /** 
      Initializes object as a CIMValue
      
      @param  - inVal - CIMValue used to construct object.
      @return - None.
      @throw  - None.
      <I><B>Experimental Interface</B></I><BR>
  */
  CQLValue(CIMValue inVal);
  
  /**  This method is used to ask an identifier to resolve itself to 
       a primitive value.
       
       Resolves:
       - symbolic constants
       - indexing an array
       - decoding identifier
       * embedded object (e.g. myclass.embeddedobject.prop1)
       and this is recursive
       - class aliasing

      @param  - CI - CIMInstance where information is retrieved.
      @param  - inQueryCtx - QueryContext contains query data.
      @return - None.
      @throw  - CQLRuntimeException.
      <I><B>Experimental Interface</B></I><BR>
  */
  void resolve(const CIMInstance& CI,const  QueryContext& inQueryCtx);
  
  /** 
      Assignment operator.
      
      @param  - rhs - right hand side of operator.
      @return - CQLValue.
      @throw  - None.
      <I><B>Experimental Interface</B></I><BR>
  */
  CQLValue& operator=(const CQLValue& rhs);
  
  /** 
      operator == compares two CQLValue objects for equality and
      performs type checking.
      
      @param  - rhs - right hand side of operator.
      @return - Boolean.
      @throw  - None.
      <I><B>Experimental Interface</B></I><BR>
  */

  
  Boolean operator==(const CQLValue& x);
  
  /** 
      operator != compares two CQLValue objects for inequality and
      performs type checking.
      
      @param  - x - right hand side of operator.
      @return - Boolean.
      @throw  - None.
      <I><B>Experimental Interface</B></I><BR>
  */
  Boolean operator!=(const CQLValue& x);
  
  /** 
      operator <= compares two CQLValue objects to see if leftside is less than or
      equal to right side and performs type checking.

      @param  - x - right hand side of operator.
      @return - Boolean.
      @throw  - None.
      <I><B>Experimental Interface</B></I><BR>
  */
  Boolean operator<=(const CQLValue& x);
  
  /** 
      operator >= compares two CQLValue objects to see if leftside is greater than or
      equal to rightside and performs type checking.

      @param  - x - right hand side of operator.
      @return - Boolean.
      @throw  - None.
      <I><B>Experimental Interface</B></I><BR>
  */
  
  Boolean operator>=(const CQLValue& x);
  
  /** 
      The overload operator < compares CQLValue obects and
      performs type checking.

      @param  - val1 - right hand side of operator.
      @return - Boolean.
      @throw  - None.
      <I><B>Experimental Interface</B></I><BR>
  */
  Boolean operator<(const CQLValue& val1);
  
  /** 
      The overload operator > compares CQLValue obects and
      performs type checking.

      @param  - val1 - right hand side of operator.
      @return - Boolean.
      @throw  - None.
      <I><B>Experimental Interface</B></I><BR>
  */
  Boolean operator>(const CQLValue& val1);
  
  /** This overload operator (+) concatenates the value of
      CQLValue objects and performs type checking. 
      (Currently supports only CQLValue of String type.)

      @param  - x - right hand side of operator.
      @return - Boolean.
      @throw  - None.
      <I><B>Experimental Interface</B></I><BR>
  */
  CQLValue operator+(const CQLValue& x);  
  
  /** 
      Accessor for getting the type of the CQLValue.

      @param  - None.
      @return - CQLValueType.
      @throw  - None.
      <I><B>Experimental Interface</B></I><BR>
  */   
  CQLValueType getValueType();
  
  /** 
      Clears this object and sets its type to NULL_VALUE

      @param  - None.
      @return - None.
      @throw  - None.
      <I><B>Experimental Interface</B></I><BR>
  */   
  void setNull();
  
  /** 
      Returns whether the value has been resolved to a primitive.

      @param  - None.
      @return - true when value is a primitive.
      @throw  - None.
      <I><B>Experimental Interface</B></I><BR>
  */     
  Boolean isResolved();
  
  /** 
      Returns whether the CQLValue is null.

      @param  - None.
      @return - true if CQLValue primitive value is NULL.
      @throw  - None.
      <I><B>Experimental Interface</B></I><BR>
  */ 
  Boolean isNull();
  
  /** This will test to determine if the CQLValue isa String contained in the cid,
      that identifies a class. The CQLValue must be of a type Instance or Class; Also
      the cid must contain a String that is a valid class name.

      @param  - cid - Contains the class name.
      @param  - QueryCtx - contains query related data.
      @return - true CQLValue isa class identified by cid.
      @throw  - None.
      <I><B>Experimental Interface</B></I><BR>
  */ 
  
  Boolean isa(const CQLChainedIdentifier& cid, QueryContext& QueryCtx);
  
  /** Tests to see if this "like" the input string.
      Both sides of the LIKE comparison must have a String type:
      the result is a Boolean type.
      
      The LIKE comparison allows a string to be tested by pattern-matching,
      using special characters n the right-hand-side string.
      See the DMTF CQL Specification for details.
      
      For Basic Query, the left-hand expression (this) may be restricted to
      chain, and 
      the right-hand expression may be restricted to be a literal-string.

      @param  - inVal - CQLValue to be compared.
      @return - true CQLValue is like the passed in CQLValue.
      @throw  - None.
      <I><B>Experimental Interface</B></I><BR>
  */
  Boolean like(const CQLValue& inVal);
 
  /** 
      Get the ChainedIdentifier. Primitive from CQLValue

      @param  - None.
      @return - ChainedIdentifier.
      @throw  - CQLRuntimeException.
      <I><B>Experimental Interface</B></I><BR>
  */
  CQLChainedIdentifier getChainedIdentifier()const;

  /** 
      Get the Uint64.  Primitive from CQLValue

      @param  - None.
      @return - Uint64.
      @throw  - CQLRuntimeException.
      <I><B>Experimental Interface</B></I><BR>
  */
  Uint64 getUint()const;

  /** 
      Get the Sint64. Primitive from CQLValue.

      @param  - None.
      @return - Sint64.
      @throw  - CQLRuntimeException.
      <I><B>Experimental Interface</B></I><BR>
  */
  Sint64 getSint()const;

  /** 
      Get the Real64. Primitive from CQLValue.

      @param  - None.
      @return - Real64.
      @throw  - CQLRuntimeException.
      <I><B>Experimental Interface</B></I><BR>
  */
  Real64 getReal()const;

  /** 
      Get the String. Primitive from CQLValue

      @param  - None.
      @return - String.
      @throw  - CQLRuntimeException.
      <I><B>Experimental Interface</B></I><BR>
  */
  String getString()const;

  /** 
      Get the Boolean. Primitive from CQLValue

      @param  - None.
      @return - Boolean
      @throw  - CQLRuntimeException.
      <I><B>Experimental Interface</B></I><BR>
  */
  Boolean getBool()const;

  /** 
      Get the CIMDateTime. Primitive from CQLValue.

      @param  - None.
      @return - CIMDateTime
      @throw  - CQLRuntimeException.
      <I><B>Experimental Interface</B></I><BR>
  */
  CIMDateTime getDateTime()const;

  /** 
      Get the CIMObjectPath. Primitive from CQLValue.

      @param  - None.
      @return - Reference.
      @throw  - CQLRuntimeException.
      <I><B>Experimental Interface</B></I><BR>
  */
  CIMObjectPath getReference()const;

  /** 
      Get the CIMObject. Primitive from CQLValue.

      @param  - None.
      @return - CIMObject.
      @throw  - CQLRuntimeException.
      <I><B>Experimental Interface</B></I><BR>
  */
  CIMObject getObject()const;

  /** 
      Return String representation of object.

      @param  - None.
      @return - String
      @throw  - None.
      <I><B>Experimental Interface</B></I><BR>
  */
  String toString()const;

  /** 
      Apply scope and class to CQLValue's chainedIdentifier.

      @param  - None.
      @return - None.
      @throw  - None.
      <I><B>Experimental Interface</B></I><BR>
  */
  void applyContext(QueryContext& _ctx,
		    CQLChainedIdentifier& inCid);

  friend class CQLFactory; 
  
 private:
  
  
  CQLValueRep *_rep;
};

/*
#ifndef PEGASUS_ARRAY_T
#define PEGASUS_ARRAY_T CQLValue
#include <Pegasus/Common/ArrayInter.h>
#undef PEGASUS_ARRAY_T
#endif
*/

PEGASUS_NAMESPACE_END
#endif
#endif /* CQLVALUE_H */

No CVS admin address has been configured
Powered by
ViewCVS 0.9.2