1 mike 1.1 //BEGIN_LICENSE
2 //
3 // Copyright (c) 2000 The Open Group, BMC Software, Tivoli Systems, IBM
4 //
5 // Permission is hereby granted, free of charge, to any person obtaining a
6 // copy of this software and associated documentation files (the "Software"),
7 // to deal in the Software without restriction, including without limitation
8 // the rights to use, copy, modify, merge, publish, distribute, sublicense,
9 // and/or sell copies of the Software, and to permit persons to whom the
10 // Software is furnished to do so, subject to the following conditions:
11 //
12 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
13 // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
14 // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
15 // THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
16 // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
17 // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
18 // DEALINGS IN THE SOFTWARE.
19 //
20 //END_LICENSE
21 //BEGIN_HISTORY
22 mike 1.1 //
23 // Author:
24 //
25 // $Log: CIMType.h,v $
26 // Revision 1.1 2001/02/16 02:07:06 mike
27 // Renamed many classes and headers (using new CIM prefixes).
28 //
29 // Revision 1.2 2001/01/24 16:16:38 karl
30 // Incorporate Doc++ Comments as documentation into .h files
31 //
32 // Revision 1.1.1.1 2001/01/14 19:53:15 mike
33 // Pegasus import
34 //
35 //
36 //END_HISTORY
37
38 /*
39 CIMType.h - This file defines the CIMType enumeration which introduces
40 symbolic constants for the CIM data types.
41 */
42
43 mike 1.1 #ifndef Pegasus_Type_h
44 #define Pegasus_Type_h
45
46 #include <Pegasus/Common/Config.h>
47
48 PEGASUS_NAMESPACE_BEGIN
49
50 /**
51 The CIMType Class defines the CIMType enumeration which introduces
52 symbolic constants for the CIM data types.
53
54 The table below shows each CIM type, its symbolic constant, and its
55 representation type.
56 <PRE>
57
58
59 CIM CIMType Constant C++ CIMType
60 -------------------------------------------------------
61 boolean CIMType::BOOLEAN Boolean
62 uint8 CIMType::UINT8 Uint8
63 sint8 CIMType::SINT8 Sint8
64 mike 1.1 uint16 CIMType::UINT16 Uint16
65 sint16 CIMType::SINT16 Sint16
66 uint32 CIMType::UINT32 Uint32
67 sint32 CIMType::SINT32 Sint32
68 uint64 CIMType::UINT64 Sint64
69 sint64 CIMType::SINT64 Sint64
70 real32 CIMType::REAL32 Real32
71 real64 CIMType::REAL64 Real64
72 char16 CIMType::CHAR16 Char16
73 string CIMType::STRING String
74 datetime CIMType::DATETIME CIMDateTime
75 reference CIMType::REFERENCE CIMReference
76
77 </PRE>
78 */
79 class PEGASUS_COMMON_LINKAGE CIMType
80 {
81 public:
82
83 enum Tag
84 {
85 mike 1.1 NONE,
86 BOOLEAN,
87 UINT8,
88 SINT8,
89 UINT16,
90 SINT16,
91 UINT32,
92 SINT32,
93 UINT64,
94 SINT64,
95 REAL32,
96 REAL64,
97 CHAR16,
98 STRING,
99 DATETIME,
100 REFERENCE
101 };
102
103 CIMType() : _tag(NONE) { }
104
105 CIMType(Tag tag) : _tag(tag) { }
106 mike 1.1
107 explicit CIMType(Uint32 tag) : _tag(Tag(tag)) { }
108
109 CIMType(const CIMType& x) : _tag(x._tag) { }
110
111 CIMType& operator=(Tag tag) { _tag = tag; return *this; }
112
113 operator Tag() const { return _tag; }
114
115 Boolean equal(const CIMType& x) const { return x._tag == _tag; }
116
117 private:
118
119 Tag _tag;
120 };
121
122 inline Boolean operator==(CIMType x, CIMType y)
123 {
124 return CIMType::Tag(x) == CIMType::Tag(y);
125 }
126
127 mike 1.1 inline Boolean operator!=(CIMType x, CIMType y)
128 {
129 return !operator==(x, y);
130 }
131
132 // ATTN: this doesn't seem necessary!
133
134 inline Boolean operator==(CIMType x, CIMType::Tag y)
135 {
136 return x.equal(y);
137 }
138
139 inline Boolean operator==(CIMType::Tag x, CIMType y)
140 {
141 return y.equal(x);
142 }
143
144 inline Boolean operator!=(CIMType x, CIMType::Tag y)
145 {
146 return !operator==(x, y);
147 }
148 mike 1.1
149 inline Boolean operator!=(CIMType::Tag x, CIMType y)
150 {
151 return !operator==(x, y);
152 }
153
154 // Returns a string representation of the given type. The string
155 // is the same as the "CIM CIMType" column in the table above.
156
157 PEGASUS_COMMON_LINKAGE const char* TypeToString(CIMType type);
158
159 PEGASUS_NAMESPACE_END
160
161 #endif /* Pegasus_Type_h */
162
|