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