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

  1 mike  1.8 //%/////////////////////////////////////////////////////////////////////////////
  2           //
  3 kumpf 1.15 // Copyright (c) 2000, 2001, 2002 BMC Software, Hewlett-Packard Company, IBM,
  4            // The Open Group, Tivoli Systems
  5 mike  1.8  //
  6            // Permission is hereby granted, free of charge, to any person obtaining a copy
  7 kumpf 1.15 // 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 mike  1.8  // 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 kumpf 1.15 // THE ABOVE COPYRIGHT NOTICE AND THIS PERMISSION NOTICE SHALL BE INCLUDED IN
 14 mike  1.8  // 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 kumpf 1.15 // 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 mike  1.8  // 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            //==============================================================================
 23            //
 24            // Author: Mike Brasher (mbrasher@bmc.com)
 25            //
 26 kumpf 1.14 // Modified By: Roger Kumpf, Hewlett-Packard Company (roger_kumpf@hp.com)
 27 kumpf 1.16 //              Carol Ann Krug Graves, Hewlett-Packard Company
 28            //                (carolann_graves@hp.com)
 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                //  Test that no undefined bits are set 
 66                //
 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                //  That is corrected later when a CIMQualifierDecl object is constructed 
 72                //  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                return ((this->cimFlavor & flavor.cimFlavor) == flavor.cimFlavor) ? 
 96                    true : false;
 97            }
 98            
 99            Boolean CIMFlavor::equal (const CIMFlavor & flavor) const
100            {
101                return (this->cimFlavor == flavor.cimFlavor) ? true : false;
102            }
103            
104 kumpf 1.17 CIMFlavor CIMFlavor::operator+ (const CIMFlavor & flavor) const
105            {
106                return CIMFlavor(this->cimFlavor | flavor.cimFlavor);
107            }
108            
109 kumpf 1.16 String CIMFlavor::toString () const
110            {
111                String tmp;
112            
113                if (this->hasFlavor (CIMFlavor::OVERRIDABLE))
114 kumpf 1.20 	tmp.append("OVERRIDABLE ");
115 kumpf 1.16 
116                if (this->hasFlavor (CIMFlavor::TOSUBCLASS))
117 kumpf 1.20 	tmp.append("TOSUBCLASS ");
118 kumpf 1.16 
119                if (this->hasFlavor (CIMFlavor::TOINSTANCE))
120 kumpf 1.20 	tmp.append("TOINSTANCE ");
121 kumpf 1.16 
122                if (this->hasFlavor (CIMFlavor::TRANSLATABLE))
123 kumpf 1.20 	tmp.append("TRANSLATABLE ");
124 kumpf 1.16 
125                if (this->hasFlavor (CIMFlavor::DISABLEOVERRIDE))
126 kumpf 1.20 	tmp.append("DISABLEOVERRIDE ");
127 kumpf 1.16 
128                if (this->hasFlavor (CIMFlavor::RESTRICTED))
129 kumpf 1.20 	tmp.append("RESTRICTED ");
130 kumpf 1.16 
131                if (tmp.size ())
132            	tmp.remove (tmp.size () - 1);
133            
134                return tmp;
135            }
136 mike  1.8  
137            PEGASUS_NAMESPACE_END

No CVS admin address has been configured
Powered by
ViewCVS 0.9.2