1 mike 1.1 /*
2 **==============================================================================
3 **
4 ** Open Management Infrastructure (OMI)
5 **
6 ** Copyright (c) Microsoft Corporation
7 **
8 ** Licensed under the Apache License, Version 2.0 (the "License"); you may not
9 ** use this file except in compliance with the License. You may obtain a copy
10 ** of the License at
11 **
12 ** http://www.apache.org/licenses/LICENSE-2.0
13 **
14 ** THIS CODE IS PROVIDED *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15 ** KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY IMPLIED
16 ** WARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE,
17 ** MERCHANTABLITY OR NON-INFRINGEMENT.
18 **
19 ** See the Apache 2 License for the specific language governing permissions
20 ** and limitations under the License.
21 **
22 mike 1.1 **==============================================================================
23 */
24
25 #ifndef _micxx_field_h
26 #define _micxx_field_h
27
28 #include <MI.h>
29
30 MI_BEGIN_NAMESPACE
31
32 template<class TYPE>
33 class Field
34 {
35 public:
36
37 TYPE value;
38 MI_Boolean exists;
39 MI_Uint8 flags;
40
41 Field();
42
43 mike 1.1 Field(const Field<TYPE>& x);
44
45 explicit Field(const TYPE& x);
46
47 void Set(const TYPE& x);
48
49 void Clear();
50
51 bool Equal(const Field<TYPE>& x) const;
52 };
53
54 template<class TYPE>
55 inline Field<TYPE>::Field() : value(), exists(false), flags(0)
56 {
57 }
58
59 template<class TYPE>
60 inline Field<TYPE>::Field(const Field<TYPE>& x) :
61 value(x.value), exists(x.exists),flags(x.flags)
62 {
63 }
64 mike 1.1
65 template<class TYPE>
66 inline Field<TYPE>::Field(const TYPE& x) : value(x), exists(MI_TRUE), flags(0)
67 {
68 }
69
70 template<class TYPE>
71 inline void Field<TYPE>::Set(const TYPE& x)
72 {
73 value = x;
74 exists = MI_TRUE;
75 }
76
77 template<class TYPE>
78 inline void Field<TYPE>::Clear()
79 {
80 value = TYPE();
81 exists = MI_FALSE;
82 flags = 0;
83 }
84
85 mike 1.1 template<class TYPE>
86 inline bool Field<TYPE>::Equal(const Field<TYPE>& x) const
87 {
88 return exists == x.exists && value == x.value;
89 }
90
91 template<class TYPE>
92 inline bool operator==(const Field<TYPE>& x, const Field<TYPE>& y)
93 {
94 return x.Equal(y);
95 }
96
97 template<class TYPE>
98 inline bool operator!=(const Field<TYPE>& x, const Field<TYPE>& y)
99 {
100 return !x.Equal(y);
101 }
102
103 MI_END_NAMESPACE
104
105 #endif /* _micxx_field_h */
|