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

  1 martin 1.27 //%LICENSE////////////////////////////////////////////////////////////////
  2 martin 1.28 //
  3 martin 1.27 // Licensed to The Open Group (TOG) under one or more contributor license
  4             // agreements.  Refer to the OpenPegasusNOTICE.txt file distributed with
  5             // this work for additional information regarding copyright ownership.
  6             // Each contributor licenses this file to you under the OpenPegasus Open
  7             // Source License; you may not use this file except in compliance with the
  8             // License.
  9 martin 1.28 //
 10 martin 1.27 // Permission is hereby granted, free of charge, to any person obtaining a
 11             // copy of this software and associated documentation files (the "Software"),
 12             // to deal in the Software without restriction, including without limitation
 13             // the rights to use, copy, modify, merge, publish, distribute, sublicense,
 14             // and/or sell copies of the Software, and to permit persons to whom the
 15             // Software is furnished to do so, subject to the following conditions:
 16 martin 1.28 //
 17 martin 1.27 // The above copyright notice and this permission notice shall be included
 18             // in all copies or substantial portions of the Software.
 19 martin 1.28 //
 20 martin 1.27 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
 21 martin 1.28 // OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
 22 martin 1.27 // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
 23             // IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
 24             // CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
 25             // TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
 26             // SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
 27 martin 1.28 //
 28 martin 1.27 //////////////////////////////////////////////////////////////////////////
 29 mike   1.8  //
 30             //%/////////////////////////////////////////////////////////////////////////////
 31             
 32             #include "CIMFlavor.h"
 33 kumpf  1.18 #include <Pegasus/Common/InternalException.h>
 34 mike   1.8  
 35             PEGASUS_NAMESPACE_BEGIN
 36             
 37 kumpf  1.17 const CIMFlavor CIMFlavor::NONE = 0;
 38             const CIMFlavor CIMFlavor::OVERRIDABLE = 1;
 39             const CIMFlavor CIMFlavor::ENABLEOVERRIDE = 1;
 40             const CIMFlavor CIMFlavor::TOSUBCLASS = 2;
 41             const CIMFlavor CIMFlavor::TOINSTANCE = 4;
 42             const CIMFlavor CIMFlavor::TRANSLATABLE = 8;
 43 kumpf  1.29 const CIMFlavor CIMFlavor::TOSUBELEMENTS = TOSUBCLASS;
 44 kumpf  1.17 const CIMFlavor CIMFlavor::DISABLEOVERRIDE = 16;
 45             const CIMFlavor CIMFlavor::RESTRICTED = 32;
 46             const CIMFlavor CIMFlavor::DEFAULTS = OVERRIDABLE + TOSUBCLASS;
 47 kumpf  1.16 
 48             
 49             CIMFlavor::CIMFlavor ()
 50 kumpf  1.17     : cimFlavor (CIMFlavor::NONE.cimFlavor)
 51 kumpf  1.16 {
 52             }
 53             
 54             CIMFlavor::CIMFlavor (const CIMFlavor & flavor)
 55                 : cimFlavor (flavor.cimFlavor)
 56             {
 57             }
 58             
 59             CIMFlavor::CIMFlavor (const Uint32 flavor)
 60                 : cimFlavor (flavor)
 61             {
 62 kumpf  1.17     //
 63 kumpf  1.25     //  Test that no undefined bits are set
 64 kumpf  1.17     //
 65                 //  Note that conflicting bits may be set in the Uint32 flavor
 66                 //  For example, OVERRIDABLE and DISABLEOVERRIDE may both be set
 67                 //  or TOSUBCLASS and RESTRICTED may both be set
 68                 //  Currently, the flavor is not checked for these conflicts
 69 kumpf  1.25     //  That is corrected later when a CIMQualifierDecl object is constructed
 70 kumpf  1.17     //  with the CIMFlavor object
 71                 //
 72                 PEGASUS_ASSERT (flavor < 64);
 73 kumpf  1.16 }
 74             
 75             CIMFlavor & CIMFlavor::operator= (const CIMFlavor & flavor)
 76             {
 77                 this->cimFlavor = flavor.cimFlavor;
 78                 return *this;
 79             }
 80             
 81             void CIMFlavor::addFlavor (const CIMFlavor & flavor)
 82             {
 83                 this->cimFlavor |= flavor.cimFlavor;
 84             }
 85             
 86 kumpf  1.17 void CIMFlavor::removeFlavor (const CIMFlavor & flavor)
 87 kumpf  1.16 {
 88 kumpf  1.17     this->cimFlavor &= (~flavor.cimFlavor);
 89 kumpf  1.16 }
 90             
 91             Boolean CIMFlavor::hasFlavor (const CIMFlavor & flavor) const
 92             {
 93 kumpf  1.26     return (this->cimFlavor & flavor.cimFlavor) == flavor.cimFlavor;
 94 kumpf  1.16 }
 95             
 96             Boolean CIMFlavor::equal (const CIMFlavor & flavor) const
 97             {
 98 kumpf  1.26     return this->cimFlavor == flavor.cimFlavor;
 99 kumpf  1.16 }
100             
101 kumpf  1.17 CIMFlavor CIMFlavor::operator+ (const CIMFlavor & flavor) const
102             {
103                 return CIMFlavor(this->cimFlavor | flavor.cimFlavor);
104             }
105             
106 kumpf  1.16 String CIMFlavor::toString () const
107             {
108                 String tmp;
109             
110                 if (this->hasFlavor (CIMFlavor::OVERRIDABLE))
111 kumpf  1.25         tmp.append("OVERRIDABLE ");
112 kumpf  1.16 
113                 if (this->hasFlavor (CIMFlavor::TOSUBCLASS))
114 kumpf  1.25         tmp.append("TOSUBCLASS ");
115 kumpf  1.16 
116                 if (this->hasFlavor (CIMFlavor::TOINSTANCE))
117 kumpf  1.25         tmp.append("TOINSTANCE ");
118 kumpf  1.16 
119                 if (this->hasFlavor (CIMFlavor::TRANSLATABLE))
120 kumpf  1.25         tmp.append("TRANSLATABLE ");
121 kumpf  1.16 
122                 if (this->hasFlavor (CIMFlavor::DISABLEOVERRIDE))
123 kumpf  1.25         tmp.append("DISABLEOVERRIDE ");
124 kumpf  1.16 
125                 if (this->hasFlavor (CIMFlavor::RESTRICTED))
126 kumpf  1.25         tmp.append("RESTRICTED ");
127 kumpf  1.16 
128                 if (tmp.size ())
129 kumpf  1.25         tmp.remove (tmp.size () - 1);
130 kumpf  1.16 
131                 return tmp;
132             }
133 mike   1.8  
134             PEGASUS_NAMESPACE_END

No CVS admin address has been configured
Powered by
ViewCVS 0.9.2