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 _omi_instance_h
26 #define _omi_instance_h
27
28 #include "config.h"
29 #include <common.h>
|
30 krisbash 1.3 #include <pal/atomic.h>
|
31 mike 1.1 #include "batch.h"
32 #include "buf.h"
33
34 BEGIN_EXTERNC
35
36 /*
37 **==============================================================================
38 **
39 ** Instance structure and related functions.
40 **
41 **==============================================================================
42 */
43
44 /* Immediately precedes heap-allocated Instance structures */
45 typedef struct _InstanceHeader
46 {
47 MI_Uint32 magic;
48 union
49 {
|
50 krisbash 1.3 volatile ptrdiff_t refs;
|
51 mike 1.1 MI_Uint64 alignment;
52 }
53 u;
54 }
55 InstanceHeader;
56
57 typedef struct _Instance /* extends MI_Instance */
58 {
59 /* Function table (inherited field) */
60 MI_InstanceFT* ft;
61
62 /* The class declaration for this instance (inherited field) */
63 MI_ClassDecl* classDecl;
64
65 /* The optional server name (inherited field) */
|
66 krisbash 1.3 ZChar* serverName;
|
67 mike 1.1
68 /* The optional namespace (inherited field) */
|
69 krisbash 1.3 ZChar* nameSpace;
|
70 mike 1.1
71 /* Allocator for this instance */
72 Batch* batch;
73
74 /* Points to this structure if static, other structure if dynamic. */
75 struct _Instance* self;
76
77 /* If true, instances releases batch upon destruction */
78 MI_Boolean releaseBatch;
79 }
80 Instance;
81
82 MI_Result MI_CALL Instance_Construct(
83 MI_Instance* self,
84 const MI_ClassDecl* classDecl,
85 Batch* batch);
86
87 MI_Result Instance_New(
|
88 krisbash 1.3 _Outptr_ MI_Instance** selfOut,
89 _In_ const MI_ClassDecl* classDecl,
90 _In_opt_ Batch* batch);
|
91 mike 1.1
92 MI_Result MI_CALL Instance_NewDynamic(
|
93 krisbash 1.3 _Outptr_ MI_Instance** self,
94 _In_z_ const ZChar* className,
|
95 mike 1.1 MI_Uint32 metaType, /* MI_FLAG_(CLASS|ASSOCIATION|INDICATION|METHOD) */
|
96 krisbash 1.3 _In_opt_ Batch* batch);
|
97 mike 1.1
98 /* TODO: Set MI_ClassDecl.schema during generation; eliminate schemaDecl arg */
99 MI_Result MI_CALL Instance_InitConvert(
|
100 krisbash 1.3 _In_ MI_Instance* self,
101 _In_ const MI_ClassDecl* classDecl,
102 _In_ const MI_Instance* instance,
|
103 mike 1.1 MI_Boolean keysOnly,
104 MI_Boolean allowKeylessInst,
105 MI_Boolean copy,
|
106 krisbash 1.3 _In_opt_ Batch* batch,
107 MI_Uint32 flags);
|
108 mike 1.1
109 MI_Result MI_CALL Instance_Clone(
110 const MI_Instance* self,
111 MI_Instance** inst,
112 Batch* batch);
113
114 MI_Result MI_CALL Instance_SetClassName(
115 MI_Instance* self,
|
116 krisbash 1.3 const ZChar* className);
|
117 mike 1.1
118 MI_Result MI_CALL Instance_Print(
119 const MI_Instance* self,
120 FILE* os,
121 MI_Uint32 level,
|
122 krisbash 1.3 MI_Boolean showNulls,
123 MI_Boolean isClass);
|
124 mike 1.1
125 /* Return true if instances have exactly the same keys */
126 MI_Boolean Instance_MatchKeys(
127 const MI_Instance* self,
128 const MI_Instance* instance);
129
|
130 krisbash 1.3 /* Get underline instance */
131 Instance* Instance_GetSelf(
132 const MI_Instance* self);
133
134 MI_Result Instance_SetElementArrayItem(
135 _Out_ MI_Instance* self_,
136 MI_Uint32 elementId,
137 MI_Value value);
138
139 MI_Result Instance_SetElementArray(
140 _Out_ MI_Instance* self_,
141 _In_z_ const MI_Char* name,
142 MI_Type type,
143 MI_Uint32 flags,
144 MI_Uint32 numberArrayItems,
145 _Out_ MI_Uint32 *elementId
146 );
147
148 MI_Boolean Instance_IsDynamic(
149 _In_ MI_Instance *self_);
150
151 krisbash 1.3 /* Verify all Keys are non-NULL */
152 MI_Boolean Instance_ValidateNonNullKeys(
153 const MI_Instance* self);
154
|
155 mike 1.1 /*
156 **==============================================================================
157 **
158 ** MI_Instance function table and functions
159 **
160 **==============================================================================
161 */
162
163 void __MI_Instance_Ref(MI_Instance* self);
164
165 void __MI_Instance_Unref(MI_Instance* self);
166
|
167 krisbash 1.3 MI_ClassDecl* _CloneClassDecl(
168 const MI_ClassDecl* cd,
169 Batch* batch);
170
171
|
172 mike 1.1 MI_Result MI_CALL __MI_Instance_Clone(
173 const MI_Instance* self,
174 MI_Instance** inst);
175
176 MI_Result MI_CALL __MI_Instance_Destruct(
177 MI_Instance* self);
178
179 MI_Result MI_CALL __MI_Instance_Delete(
180 MI_Instance* self);
181
182 MI_Result MI_CALL __MI_Instance_IsA(
183 const MI_Instance* self_,
184 const MI_ClassDecl* classDecl,
185 MI_Boolean* result);
186
187 MI_Result MI_CALL __MI_Instance_GetClassName(
188 const MI_Instance* self_,
|
189 krisbash 1.3 const ZChar** classname);
|
190 mike 1.1
191 MI_Result MI_CALL __MI_Instance_SetNameSpace(
192 MI_Instance* self,
|
193 krisbash 1.3 const ZChar* nameSpace);
|
194 mike 1.1
195 MI_Result MI_CALL __MI_Instance_GetNameSpace(
196 const MI_Instance* self,
|
197 krisbash 1.3 const ZChar** nameSpace);
|
198 mike 1.1
199 MI_Result MI_CALL __MI_Instance_GetElementCount(
200 const MI_Instance* self,
201 MI_Uint32* count);
202
203 MI_Result MI_CALL __MI_Instance_AddElement(
204 MI_Instance* self,
|
205 krisbash 1.3 const ZChar* name,
|
206 mike 1.1 const MI_Value* value,
207 MI_Type type,
208 MI_Uint32 flags);
209
210 MI_Result MI_CALL __MI_Instance_SetElement(
211 MI_Instance* self,
|
212 krisbash 1.3 const ZChar* name,
|
213 mike 1.1 const MI_Value* value,
214 MI_Type type,
215 MI_Uint32 flags);
216
217 MI_Result MI_CALL __MI_Instance_SetElementAt(
218 MI_Instance* self,
219 MI_Uint32 index,
220 const MI_Value* value,
221 MI_Type type,
222 MI_Uint32 flags);
223
224 MI_Result MI_CALL __MI_Instance_GetElement(
225 const MI_Instance* self,
|
226 krisbash 1.3 const ZChar* name,
|
227 mike 1.1 MI_Value* valueOut,
228 MI_Type* typeOut,
229 MI_Uint32* flagsOut,
230 MI_Uint32* indexOut);
231
232 MI_Result MI_CALL __MI_Instance_GetElementAt(
233 const MI_Instance* self,
234 MI_Uint32 index,
|
235 krisbash 1.3 const ZChar** name,
|
236 mike 1.1 MI_Value* value,
237 MI_Type* type,
238 MI_Uint32* flags);
239
240 MI_Result MI_CALL __MI_Instance_ClearElement(
241 MI_Instance* self_,
|
242 krisbash 1.3 const ZChar* name);
|
243 mike 1.1
244 MI_Result MI_CALL __MI_Instance_ClearElementAt(
245 MI_Instance* self,
246 MI_Uint32 index);
247
|
248 krisbash 1.3 extern MI_InstanceFT __mi_instanceFT;
|
249 mike 1.1
|
250 krisbash 1.3 MI_Result MI_CALL MI_Instance_GetClassExt(
251 _In_ const MI_Instance *self,
252 _Inout_ MI_Class* classToGet);
|
253 mike 1.1
254 END_EXTERNC
255
256 #endif /* _omi_instance_h */
|