1 martin 1.24 //%LICENSE////////////////////////////////////////////////////////////////
|
2 martin 1.25 //
|
3 martin 1.24 // 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 martin 1.25 //
|
10 martin 1.24 // 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 martin 1.25 //
|
17 martin 1.24 // The above copyright notice and this permission notice shall be included
18 // in all copies or substantial portions of the Software.
|
19 martin 1.25 //
|
20 martin 1.24 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
|
21 martin 1.25 // OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
22 martin 1.24 // 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 martin 1.25 //
|
28 martin 1.24 //////////////////////////////////////////////////////////////////////////
|
29 mike 1.9 //
30 //%/////////////////////////////////////////////////////////////////////////////
31
32 #include <cstring>
|
33 kumpf 1.17 #include <Pegasus/Common/InternalException.h>
|
34 mike 1.9 #include "CIMScope.h"
35
36 PEGASUS_NAMESPACE_BEGIN
37
|
38 kumpf 1.15 const CIMScope CIMScope::NONE = 0;
39 const CIMScope CIMScope::CLASS = 1;
40 const CIMScope CIMScope::ASSOCIATION = 2;
41 const CIMScope CIMScope::INDICATION = 4;
42 const CIMScope CIMScope::PROPERTY = 8;
43 const CIMScope CIMScope::REFERENCE = 16;
44 const CIMScope CIMScope::METHOD = 32;
45 const CIMScope CIMScope::PARAMETER = 64;
46 const CIMScope CIMScope::ANY = CIMScope::CLASS + CIMScope::ASSOCIATION +
47 CIMScope::INDICATION + CIMScope::PROPERTY +
48 CIMScope::REFERENCE + CIMScope::METHOD +
49 CIMScope::PARAMETER;
|
50 mike 1.9
|
51 kumpf 1.14 CIMScope::CIMScope ()
|
52 kumpf 1.15 : cimScope (CIMScope::NONE.cimScope)
|
53 kumpf 1.14 {
54 }
55
56 CIMScope::CIMScope (const CIMScope & scope)
57 : cimScope (scope.cimScope)
58 {
59 }
60
61 CIMScope::CIMScope (const Uint32 scope)
62 : cimScope (scope)
63 {
|
64 kumpf 1.15 PEGASUS_ASSERT (scope < 128);
|
65 kumpf 1.14 }
66
67 CIMScope & CIMScope::operator= (const CIMScope & scope)
68 {
69 this->cimScope = scope.cimScope;
70 return *this;
71 }
72
|
73 kumpf 1.15 void CIMScope::addScope (const CIMScope & scope)
|
74 kumpf 1.14 {
|
75 kumpf 1.15 this->cimScope |= scope.cimScope;
|
76 kumpf 1.14 }
77
78 Boolean CIMScope::hasScope (const CIMScope & scope) const
79 {
|
80 kumpf 1.16 return ((this->cimScope & scope.cimScope) == scope.cimScope);
|
81 kumpf 1.14 }
82
83 Boolean CIMScope::equal (const CIMScope & scope) const
84 {
|
85 kumpf 1.16 return (this->cimScope == scope.cimScope);
|
86 kumpf 1.15 }
87
88 CIMScope CIMScope::operator+ (const CIMScope & scope) const
89 {
90 return CIMScope(this->cimScope | scope.cimScope);
|
91 kumpf 1.14 }
92
93 String CIMScope::toString () const
|
94 mike 1.9 {
95 String tmp;
96
|
97 kumpf 1.14 if (this->hasScope (CIMScope::CLASS))
|
98 kumpf 1.23 tmp.append("CLASS ");
|
99 mike 1.9
|
100 kumpf 1.14 if (this->hasScope (CIMScope::ASSOCIATION))
|
101 kumpf 1.23 tmp.append("ASSOCIATION ");
|
102 mike 1.9
|
103 kumpf 1.14 if (this->hasScope (CIMScope::INDICATION))
|
104 kumpf 1.23 tmp.append("INDICATION ");
|
105 mike 1.9
|
106 kumpf 1.14 if (this->hasScope (CIMScope::PROPERTY))
|
107 kumpf 1.23 tmp.append("PROPERTY ");
|
108 mike 1.9
|
109 kumpf 1.14 if (this->hasScope (CIMScope::REFERENCE))
|
110 kumpf 1.23 tmp.append("REFERENCE ");
|
111 mike 1.9
|
112 kumpf 1.14 if (this->hasScope (CIMScope::METHOD))
|
113 kumpf 1.23 tmp.append("METHOD ");
|
114 mike 1.9
|
115 kumpf 1.14 if (this->hasScope (CIMScope::PARAMETER))
|
116 kumpf 1.23 tmp.append("PARAMETER ");
|
117 mike 1.9
118 if (tmp.size())
|
119 kumpf 1.23 tmp.remove(tmp.size() - 1);
|
120 mike 1.9
121 return tmp;
122 }
123
124 PEGASUS_NAMESPACE_END
|