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

  1 martin 1.27 //%LICENSE////////////////////////////////////////////////////////////////
  2             // 
  3             // 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             // 
 10             // 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             // 
 17             // The above copyright notice and this permission notice shall be included
 18             // in all copies or substantial portions of the Software.
 19             // 
 20             // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
 21             // 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 mike   1.8  // 
 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             const CIMFlavor CIMFlavor::TOSUBELEMENTS = TOSUBCLASS + TOINSTANCE;
 44             const CIMFlavor CIMFlavor::DISABLEOVERRIDE = 16;
 45             const CIMFlavor CIMFlavor::RESTRICTED = 32;
 46             const CIMFlavor CIMFlavor::DEFAULTS = OVERRIDABLE + TOSUBCLASS;
 47 karl   1.13 // ATTN: P1 KS 24 March 2002 Change here to make TOINSTANCE part of the defaults
 48 kumpf  1.17 //const CIMFlavor CIMFlavor::DEFAULTS = OVERRIDABLE + TOSUBCLASS + TOINSTANCE;
 49 kumpf  1.16 
 50             
 51             CIMFlavor::CIMFlavor ()
 52 kumpf  1.17     : cimFlavor (CIMFlavor::NONE.cimFlavor)
 53 kumpf  1.16 {
 54             }
 55             
 56             CIMFlavor::CIMFlavor (const CIMFlavor & flavor)
 57                 : cimFlavor (flavor.cimFlavor)
 58             {
 59             }
 60             
 61             CIMFlavor::CIMFlavor (const Uint32 flavor)
 62                 : cimFlavor (flavor)
 63             {
 64 kumpf  1.17     //
 65 kumpf  1.25     //  Test that no undefined bits are set
 66 kumpf  1.17     //
 67                 //  Note that conflicting bits may be set in the Uint32 flavor
 68                 //  For example, OVERRIDABLE and DISABLEOVERRIDE may both be set
 69                 //  or TOSUBCLASS and RESTRICTED may both be set
 70                 //  Currently, the flavor is not checked for these conflicts
 71 kumpf  1.25     //  That is corrected later when a CIMQualifierDecl object is constructed
 72 kumpf  1.17     //  with the CIMFlavor object
 73                 //
 74                 PEGASUS_ASSERT (flavor < 64);
 75 kumpf  1.16 }
 76             
 77             CIMFlavor & CIMFlavor::operator= (const CIMFlavor & flavor)
 78             {
 79                 this->cimFlavor = flavor.cimFlavor;
 80                 return *this;
 81             }
 82             
 83             void CIMFlavor::addFlavor (const CIMFlavor & flavor)
 84             {
 85                 this->cimFlavor |= flavor.cimFlavor;
 86             }
 87             
 88 kumpf  1.17 void CIMFlavor::removeFlavor (const CIMFlavor & flavor)
 89 kumpf  1.16 {
 90 kumpf  1.17     this->cimFlavor &= (~flavor.cimFlavor);
 91 kumpf  1.16 }
 92             
 93             Boolean CIMFlavor::hasFlavor (const CIMFlavor & flavor) const
 94             {
 95 kumpf  1.26     return (this->cimFlavor & flavor.cimFlavor) == flavor.cimFlavor;
 96 kumpf  1.16 }
 97             
 98             Boolean CIMFlavor::equal (const CIMFlavor & flavor) const
 99             {
100 kumpf  1.26     return this->cimFlavor == flavor.cimFlavor;
101 kumpf  1.16 }
102             
103 kumpf  1.17 CIMFlavor CIMFlavor::operator+ (const CIMFlavor & flavor) const
104             {
105                 return CIMFlavor(this->cimFlavor | flavor.cimFlavor);
106             }
107             
108 kumpf  1.16 String CIMFlavor::toString () const
109             {
110                 String tmp;
111             
112                 if (this->hasFlavor (CIMFlavor::OVERRIDABLE))
113 kumpf  1.25         tmp.append("OVERRIDABLE ");
114 kumpf  1.16 
115                 if (this->hasFlavor (CIMFlavor::TOSUBCLASS))
116 kumpf  1.25         tmp.append("TOSUBCLASS ");
117 kumpf  1.16 
118                 if (this->hasFlavor (CIMFlavor::TOINSTANCE))
119 kumpf  1.25         tmp.append("TOINSTANCE ");
120 kumpf  1.16 
121                 if (this->hasFlavor (CIMFlavor::TRANSLATABLE))
122 kumpf  1.25         tmp.append("TRANSLATABLE ");
123 kumpf  1.16 
124                 if (this->hasFlavor (CIMFlavor::DISABLEOVERRIDE))
125 kumpf  1.25         tmp.append("DISABLEOVERRIDE ");
126 kumpf  1.16 
127                 if (this->hasFlavor (CIMFlavor::RESTRICTED))
128 kumpf  1.25         tmp.append("RESTRICTED ");
129 kumpf  1.16 
130                 if (tmp.size ())
131 kumpf  1.25         tmp.remove (tmp.size () - 1);
132 kumpf  1.16 
133                 return tmp;
134             }
135 mike   1.8  
136             PEGASUS_NAMESPACE_END

No CVS admin address has been configured
Powered by
ViewCVS 0.9.2