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 // Author: Mike Brasher (mbrasher@bmc.com)
33 //
|
34 kumpf 1.14 // Modified By: Roger Kumpf, Hewlett-Packard Company (roger_kumpf@hp.com)
|
35 kumpf 1.16 // Carol Ann Krug Graves, Hewlett-Packard Company
36 // (carolann_graves@hp.com)
|
37 mike 1.8 //
38 //%/////////////////////////////////////////////////////////////////////////////
39
40 #include "CIMFlavor.h"
|
41 kumpf 1.18 #include <Pegasus/Common/InternalException.h>
|
42 mike 1.8
43 PEGASUS_NAMESPACE_BEGIN
44
|
45 kumpf 1.17 const CIMFlavor CIMFlavor::NONE = 0;
46 const CIMFlavor CIMFlavor::OVERRIDABLE = 1;
47 const CIMFlavor CIMFlavor::ENABLEOVERRIDE = 1;
48 const CIMFlavor CIMFlavor::TOSUBCLASS = 2;
49 const CIMFlavor CIMFlavor::TOINSTANCE = 4;
50 const CIMFlavor CIMFlavor::TRANSLATABLE = 8;
51 const CIMFlavor CIMFlavor::TOSUBELEMENTS = TOSUBCLASS + TOINSTANCE;
52 const CIMFlavor CIMFlavor::DISABLEOVERRIDE = 16;
53 const CIMFlavor CIMFlavor::RESTRICTED = 32;
54 const CIMFlavor CIMFlavor::DEFAULTS = OVERRIDABLE + TOSUBCLASS;
|
55 karl 1.13 // ATTN: P1 KS 24 March 2002 Change here to make TOINSTANCE part of the defaults
|
56 kumpf 1.17 //const CIMFlavor CIMFlavor::DEFAULTS = OVERRIDABLE + TOSUBCLASS + TOINSTANCE;
|
57 kumpf 1.16
58
59 CIMFlavor::CIMFlavor ()
|
60 kumpf 1.17 : cimFlavor (CIMFlavor::NONE.cimFlavor)
|
61 kumpf 1.16 {
62 }
63
64 CIMFlavor::CIMFlavor (const CIMFlavor & flavor)
65 : cimFlavor (flavor.cimFlavor)
66 {
67 }
68
69 CIMFlavor::CIMFlavor (const Uint32 flavor)
70 : cimFlavor (flavor)
71 {
|
72 kumpf 1.17 //
73 // Test that no undefined bits are set
74 //
75 // Note that conflicting bits may be set in the Uint32 flavor
76 // For example, OVERRIDABLE and DISABLEOVERRIDE may both be set
77 // or TOSUBCLASS and RESTRICTED may both be set
78 // Currently, the flavor is not checked for these conflicts
79 // That is corrected later when a CIMQualifierDecl object is constructed
80 // with the CIMFlavor object
81 //
82 PEGASUS_ASSERT (flavor < 64);
|
83 kumpf 1.16 }
84
85 CIMFlavor & CIMFlavor::operator= (const CIMFlavor & flavor)
86 {
87 this->cimFlavor = flavor.cimFlavor;
88 return *this;
89 }
90
91 void CIMFlavor::addFlavor (const CIMFlavor & flavor)
92 {
93 this->cimFlavor |= flavor.cimFlavor;
94 }
95
|
96 kumpf 1.17 void CIMFlavor::removeFlavor (const CIMFlavor & flavor)
|
97 kumpf 1.16 {
|
98 kumpf 1.17 this->cimFlavor &= (~flavor.cimFlavor);
|
99 kumpf 1.16 }
100
101 Boolean CIMFlavor::hasFlavor (const CIMFlavor & flavor) const
102 {
103 return ((this->cimFlavor & flavor.cimFlavor) == flavor.cimFlavor) ?
104 true : false;
105 }
106
107 Boolean CIMFlavor::equal (const CIMFlavor & flavor) const
108 {
109 return (this->cimFlavor == flavor.cimFlavor) ? true : false;
110 }
111
|
112 kumpf 1.17 CIMFlavor CIMFlavor::operator+ (const CIMFlavor & flavor) const
113 {
114 return CIMFlavor(this->cimFlavor | flavor.cimFlavor);
115 }
116
|
117 kumpf 1.16 String CIMFlavor::toString () const
118 {
119 String tmp;
120
121 if (this->hasFlavor (CIMFlavor::OVERRIDABLE))
|
122 kumpf 1.20 tmp.append("OVERRIDABLE ");
|
123 kumpf 1.16
124 if (this->hasFlavor (CIMFlavor::TOSUBCLASS))
|
125 kumpf 1.20 tmp.append("TOSUBCLASS ");
|
126 kumpf 1.16
127 if (this->hasFlavor (CIMFlavor::TOINSTANCE))
|
128 kumpf 1.20 tmp.append("TOINSTANCE ");
|
129 kumpf 1.16
130 if (this->hasFlavor (CIMFlavor::TRANSLATABLE))
|
131 kumpf 1.20 tmp.append("TRANSLATABLE ");
|
132 kumpf 1.16
133 if (this->hasFlavor (CIMFlavor::DISABLEOVERRIDE))
|
134 kumpf 1.20 tmp.append("DISABLEOVERRIDE ");
|
135 kumpf 1.16
136 if (this->hasFlavor (CIMFlavor::RESTRICTED))
|
137 kumpf 1.20 tmp.append("RESTRICTED ");
|
138 kumpf 1.16
139 if (tmp.size ())
140 tmp.remove (tmp.size () - 1);
141
142 return tmp;
143 }
|
144 mike 1.8
145 PEGASUS_NAMESPACE_END
|