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

  1 karl  1.23 //%2005////////////////////////////////////////////////////////////////////////
  2 mike  1.8  //
  3 karl  1.22 // Copyright (c) 2000, 2001, 2002 BMC Software; Hewlett-Packard Development
  4            // Company, L.P.; IBM Corp.; The Open Group; Tivoli Systems.
  5            // Copyright (c) 2003 BMC Software; Hewlett-Packard Development Company, L.P.;
  6 karl  1.21 // IBM Corp.; EMC Corporation, The Open Group.
  7 karl  1.22 // Copyright (c) 2004 BMC Software; Hewlett-Packard Development Company, L.P.;
  8            // IBM Corp.; EMC Corporation; VERITAS Software Corporation; The Open Group.
  9 karl  1.23 // Copyright (c) 2005 Hewlett-Packard Development Company, L.P.; IBM Corp.;
 10            // EMC Corporation; VERITAS Software Corporation; The Open Group.
 11 mike  1.8  //
 12            // Permission is hereby granted, free of charge, to any person obtaining a copy
 13 kumpf 1.15 // of this software and associated documentation files (the "Software"), to
 14            // deal in the Software without restriction, including without limitation the
 15            // rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
 16 mike  1.8  // sell copies of the Software, and to permit persons to whom the Software is
 17            // furnished to do so, subject to the following conditions:
 18            // 
 19 kumpf 1.15 // THE ABOVE COPYRIGHT NOTICE AND THIS PERMISSION NOTICE SHALL BE INCLUDED IN
 20 mike  1.8  // ALL COPIES OR SUBSTANTIAL PORTIONS OF THE SOFTWARE. THE SOFTWARE IS PROVIDED
 21            // "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT
 22 kumpf 1.15 // LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
 23            // PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
 24            // HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
 25 mike  1.8  // ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
 26            // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
 27            //
 28            //==============================================================================
 29            //
 30            // Author: Mike Brasher (mbrasher@bmc.com)
 31            //
 32 kumpf 1.14 // Modified By: Roger Kumpf, Hewlett-Packard Company (roger_kumpf@hp.com)
 33 kumpf 1.16 //              Carol Ann Krug Graves, Hewlett-Packard Company
 34            //                (carolann_graves@hp.com)
 35 mike  1.8  //
 36            //%/////////////////////////////////////////////////////////////////////////////
 37            
 38            #include "CIMFlavor.h"
 39 kumpf 1.18 #include <Pegasus/Common/InternalException.h>
 40 mike  1.8  
 41            PEGASUS_NAMESPACE_BEGIN
 42            
 43 kumpf 1.17 const CIMFlavor CIMFlavor::NONE = 0;
 44            const CIMFlavor CIMFlavor::OVERRIDABLE = 1;
 45            const CIMFlavor CIMFlavor::ENABLEOVERRIDE = 1;
 46            const CIMFlavor CIMFlavor::TOSUBCLASS = 2;
 47            const CIMFlavor CIMFlavor::TOINSTANCE = 4;
 48            const CIMFlavor CIMFlavor::TRANSLATABLE = 8;
 49            const CIMFlavor CIMFlavor::TOSUBELEMENTS = TOSUBCLASS + TOINSTANCE;
 50            const CIMFlavor CIMFlavor::DISABLEOVERRIDE = 16;
 51            const CIMFlavor CIMFlavor::RESTRICTED = 32;
 52            const CIMFlavor CIMFlavor::DEFAULTS = OVERRIDABLE + TOSUBCLASS;
 53 karl  1.13 // ATTN: P1 KS 24 March 2002 Change here to make TOINSTANCE part of the defaults
 54 kumpf 1.17 //const CIMFlavor CIMFlavor::DEFAULTS = OVERRIDABLE + TOSUBCLASS + TOINSTANCE;
 55 kumpf 1.16 
 56            
 57            CIMFlavor::CIMFlavor ()
 58 kumpf 1.17     : cimFlavor (CIMFlavor::NONE.cimFlavor)
 59 kumpf 1.16 {
 60            }
 61            
 62            CIMFlavor::CIMFlavor (const CIMFlavor & flavor)
 63                : cimFlavor (flavor.cimFlavor)
 64            {
 65            }
 66            
 67            CIMFlavor::CIMFlavor (const Uint32 flavor)
 68                : cimFlavor (flavor)
 69            {
 70 kumpf 1.17     //
 71                //  Test that no undefined bits are set 
 72                //
 73                //  Note that conflicting bits may be set in the Uint32 flavor
 74                //  For example, OVERRIDABLE and DISABLEOVERRIDE may both be set
 75                //  or TOSUBCLASS and RESTRICTED may both be set
 76                //  Currently, the flavor is not checked for these conflicts
 77                //  That is corrected later when a CIMQualifierDecl object is constructed 
 78                //  with the CIMFlavor object
 79                //
 80                PEGASUS_ASSERT (flavor < 64);
 81 kumpf 1.16 }
 82            
 83            CIMFlavor & CIMFlavor::operator= (const CIMFlavor & flavor)
 84            {
 85                this->cimFlavor = flavor.cimFlavor;
 86                return *this;
 87            }
 88            
 89            void CIMFlavor::addFlavor (const CIMFlavor & flavor)
 90            {
 91                this->cimFlavor |= flavor.cimFlavor;
 92            }
 93            
 94 kumpf 1.17 void CIMFlavor::removeFlavor (const CIMFlavor & flavor)
 95 kumpf 1.16 {
 96 kumpf 1.17     this->cimFlavor &= (~flavor.cimFlavor);
 97 kumpf 1.16 }
 98            
 99            Boolean CIMFlavor::hasFlavor (const CIMFlavor & flavor) const
100            {
101                return ((this->cimFlavor & flavor.cimFlavor) == flavor.cimFlavor) ? 
102                    true : false;
103            }
104            
105            Boolean CIMFlavor::equal (const CIMFlavor & flavor) const
106            {
107                return (this->cimFlavor == flavor.cimFlavor) ? true : false;
108            }
109            
110 kumpf 1.17 CIMFlavor CIMFlavor::operator+ (const CIMFlavor & flavor) const
111            {
112                return CIMFlavor(this->cimFlavor | flavor.cimFlavor);
113            }
114            
115 kumpf 1.16 String CIMFlavor::toString () const
116            {
117                String tmp;
118            
119                if (this->hasFlavor (CIMFlavor::OVERRIDABLE))
120 kumpf 1.20 	tmp.append("OVERRIDABLE ");
121 kumpf 1.16 
122                if (this->hasFlavor (CIMFlavor::TOSUBCLASS))
123 kumpf 1.20 	tmp.append("TOSUBCLASS ");
124 kumpf 1.16 
125                if (this->hasFlavor (CIMFlavor::TOINSTANCE))
126 kumpf 1.20 	tmp.append("TOINSTANCE ");
127 kumpf 1.16 
128                if (this->hasFlavor (CIMFlavor::TRANSLATABLE))
129 kumpf 1.20 	tmp.append("TRANSLATABLE ");
130 kumpf 1.16 
131                if (this->hasFlavor (CIMFlavor::DISABLEOVERRIDE))
132 kumpf 1.20 	tmp.append("DISABLEOVERRIDE ");
133 kumpf 1.16 
134                if (this->hasFlavor (CIMFlavor::RESTRICTED))
135 kumpf 1.20 	tmp.append("RESTRICTED ");
136 kumpf 1.16 
137                if (tmp.size ())
138            	tmp.remove (tmp.size () - 1);
139            
140                return tmp;
141            }
142 mike  1.8  
143            PEGASUS_NAMESPACE_END

No CVS admin address has been configured
Powered by
ViewCVS 0.9.2