1 r.kieninger 1.1 //%LICENSE////////////////////////////////////////////////////////////////
2 //
3 // 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 //
10 // 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 //
17 // The above copyright notice and this permission notice shall be included
18 // in all copies or substantial portions of the Software.
19 //
20 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
21 // OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
22 r.kieninger 1.1 // 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 //
28 //////////////////////////////////////////////////////////////////////////
29 //
30 //%/////////////////////////////////////////////////////////////////////////////
31
|
32 thilo.boehm 1.4 #ifndef Pegasus_CIMResponseData_h
|
33 r.kieninger 1.1 #define Pegasus_CIMResponseData_h
34
35 #include <Pegasus/Common/Config.h>
36 #include <Pegasus/Common/CIMInstance.h>
37 #include <Pegasus/Common/Linkage.h>
38 #include <Pegasus/Common/CIMBuffer.h>
|
39 thilo.boehm 1.4 #include <Pegasus/Common/SCMOClass.h>
40 #include <Pegasus/Common/SCMOInstance.h>
41 #include <Pegasus/Common/SCMODump.h>
|
42 karl 1.6.2.1 #include <Pegasus/Common/Magic.h>
|
43 r.kieninger 1.1
44 PEGASUS_NAMESPACE_BEGIN
|
45 karl 1.6.2.1 PEGASUS_USING_STD;
|
46 r.kieninger 1.1 typedef Array<Sint8> ArraySint8;
47 #define PEGASUS_ARRAY_T ArraySint8
48 # include <Pegasus/Common/ArrayInter.h>
49 #undef PEGASUS_ARRAY_T
50
51
|
52 thilo.boehm 1.4 class PEGASUS_COMMON_LINKAGE CIMResponseData
|
53 r.kieninger 1.1 {
54 public:
55
|
56 thilo.boehm 1.4 enum ResponseDataEncoding {
57 RESP_ENC_CIM = 1,
58 RESP_ENC_BINARY = 2,
59 RESP_ENC_XML = 4,
60 RESP_ENC_SCMO = 8
61 };
|
62 r.kieninger 1.1
|
63 thilo.boehm 1.4 enum ResponseDataContent {
64 RESP_INSTNAMES = 1,
65 RESP_INSTANCES = 2,
66 RESP_INSTANCE = 3,
67 RESP_OBJECTS = 4,
68 RESP_OBJECTPATHS = 5
69 };
|
70 r.kieninger 1.1
|
71 thilo.boehm 1.4 CIMResponseData(ResponseDataContent content):
|
72 karl 1.6.2.1 _encoding(0),_dataType(content),_size(0)
|
73 thilo.boehm 1.4 {};
|
74 r.kieninger 1.1
|
75 marek 1.5 CIMResponseData(const CIMResponseData & x):
76 _encoding(x._encoding),
77 _dataType(x._dataType),
|
78 karl 1.6.2.1 _size(x._size),
|
79 marek 1.5 _referencesData(x._referencesData),
80 _instanceData(x._instanceData),
81 _hostsData(x._hostsData),
82 _nameSpacesData(x._nameSpacesData),
83 _binaryData(x._binaryData),
84 _defaultNamespace(x._defaultNamespace),
85 _defaultHostname(x._defaultHostname),
86 _instanceNames(x._instanceNames),
87 _instances(x._instances),
88 _objects(x._objects),
89 _scmoInstances(x._scmoInstances)
90 {};
|
91 r.kieninger 1.1
|
92 karl 1.6.2.1 // Construct an empty object. Issue here in that we would like to
93 // assure that this is invalid but if we add the _dataType parameter
94 // it must be a valid one. The alternative would be to define an
95 // invalid enum but that would cost us in all case/if statements.
96 CIMResponseData():
97 _encoding(0),_size(0)
98 {};
99
100 /**
101 * Move CIM objects from another CIMResponse data object to this
102 * CIMResponseData object. Moves the number of objects defined
103 * in the count parameter from one to another. They are removed
104 * from the from object and inserted into the to object.
105 *
106 * @param CIMResponseData from which the objects are moved
107 * @param count Uint32 count of objects to move
108 * @return - Actual number of objects moved.
109 */
110 Uint32 moveObjects(CIMResponseData & x, Uint32 count);
111
112 /**
113 karl 1.6.2.1 * Return count of the number of CIM objects in the
114 * CIMResponseData object
115 * @return Uint32 The count of the number of CIM objects
116 * (instances, paths, or objects)in the CIMResponsedata object
117 */
118 Uint32 size();
119
|
120 thilo.boehm 1.4 ~CIMResponseData()
|
121 r.kieninger 1.3 {
122 }
123
|
124 karl 1.6.2.1 // This one may be a hack but we have issue with pull and other operations
125 // in that the other assoc operations return objects and objectPaths
126 // and the pulls return instances and instancePaths). The pull operation
127 // must be able to handle either so we use this to reset the datatype
128 // KS_TODO -- This should check size and only allow if nothing in the
129 // object.
130 Boolean setDataType(ResponseDataContent content)
131 {
132 _dataType = content;
133 return true;
134 }
135
136 // get the datatype property
137 ResponseDataContent getResponseDataContent()
138 {
139 return _dataType;
140 }
|
141 thilo.boehm 1.4 // C++ objects interface handling
|
142 r.kieninger 1.1
|
143 thilo.boehm 1.4 // Instance Names handling
144 Array<CIMObjectPath>& getInstanceNames();
|
145 r.kieninger 1.1
|
146 thilo.boehm 1.4 void setInstanceNames(const Array<CIMObjectPath>& x)
|
147 r.kieninger 1.1 {
|
148 thilo.boehm 1.4 _instanceNames=x;
149 _encoding |= RESP_ENC_CIM;
|
150 karl 1.6.2.1 _size += x.size();
|
151 r.kieninger 1.1 }
152
|
153 thilo.boehm 1.4 // Instance handling
154 CIMInstance& getInstance();
|
155 r.kieninger 1.1
|
156 thilo.boehm 1.4 void setInstance(const CIMInstance& x)
|
157 r.kieninger 1.1 {
|
158 thilo.boehm 1.4 _instances.clear();
159 _instances.append(x);
|
160 karl 1.6.2.1 _size++;
|
161 thilo.boehm 1.4 _encoding |= RESP_ENC_CIM;
|
162 r.kieninger 1.1 }
163
|
164 thilo.boehm 1.4 // Instances handling
165 Array<CIMInstance>& getInstances();
166
|
167 karl 1.6.2.1 // Get an array of CIMInstances from the CIMResponseData converting from
168 // any of the internal forms to the C++ format. This will also convert
169 // CIMObjects to CIMInstances if there are any CIMObjects.
170 // NOTE: This is a temporary solution to satisfy the BinaryCodec passing
171 // of data to the client where the data could be either instances or
172 // objects. The correct solution is to convert back when the provider, etc.
173 // returns the data to the server. We must convert to that solution but
174 // this keeps the BinaryCodec working for the moment.
175 // Expect that this will be used only in CIMCLient.cpp
176 Array<CIMInstance>& getInstancesFromInstancesOrObjects();
177
|
178 thilo.boehm 1.4 void setInstances(const Array<CIMInstance>& x)
|
179 r.kieninger 1.1 {
|
180 thilo.boehm 1.4 _instances=x;
181 _encoding |= RESP_ENC_CIM;
|
182 karl 1.6.2.1 _size += x.size();
|
183 r.kieninger 1.1 }
|
184 thilo.boehm 1.4 void appendInstance(const CIMInstance& x)
|
185 r.kieninger 1.1 {
|
186 thilo.boehm 1.4 _instances.append(x);
187 _encoding |= RESP_ENC_CIM;
|
188 karl 1.6.2.1 _size += 1;
189 }
190
191 void appendInstances(const Array<CIMInstance>& x)
192 {
193 _instances.appendArray(x);
194 _encoding |= RESP_ENC_CIM;
195 _size += x.size();
|
196 r.kieninger 1.1 }
197
|
198 thilo.boehm 1.4 // Objects handling
199 Array<CIMObject>& getObjects();
200 void setObjects(const Array<CIMObject>& x)
|
201 r.kieninger 1.1 {
|
202 thilo.boehm 1.4 _objects=x;
203 _encoding |= RESP_ENC_CIM;
|
204 karl 1.6.2.1 _size += x.size();
|
205 r.kieninger 1.1 }
|
206 thilo.boehm 1.4 void appendObject(const CIMObject& x)
|
207 r.kieninger 1.3 {
|
208 thilo.boehm 1.4 _objects.append(x);
209 _encoding |= RESP_ENC_CIM;
|
210 karl 1.6.2.1 _size += 1;
|
211 r.kieninger 1.3 }
212
|
213 thilo.boehm 1.4 // SCMO representation, single instance stored as one element array
214 // object paths are represented as SCMOInstance
215 Array<SCMOInstance>& getSCMO();
|
216 r.kieninger 1.1
|
217 thilo.boehm 1.4 void setSCMO(const Array<SCMOInstance>& x);
|
218 r.kieninger 1.1
|
219 thilo.boehm 1.4 void appendSCMO(const Array<SCMOInstance>& x)
|
220 r.kieninger 1.1 {
|
221 thilo.boehm 1.4 _scmoInstances.appendArray(x);
222 _encoding |= RESP_ENC_SCMO;
|
223 karl 1.6.2.1 _size += x.size();
|
224 r.kieninger 1.1 }
225
|
226 thilo.boehm 1.4 Array<Uint8>& getBinary();
|
227 karl 1.6
228 // Set the binary stream in the CIMBuffer into the CIMResponseData
229 bool setBinary(CIMBuffer& in);
230
231 // Set any data from the CIMBuffer remaining after the current CIMBuffer
232 // position pointer into the CIMResponseData Object.
233 bool setRemainingBinaryData(CIMBuffer& in);
|
234 r.kieninger 1.1
|
235 thilo.boehm 1.4 // Xml data is unformatted, no need to differentiate between instance
236 // instances and object paths or objects
237 bool setXml(CIMBuffer& in);
|
238 r.kieninger 1.1
|
239 thilo.boehm 1.4 // function used by OperationAggregator to aggregate response data in a
240 // single ResponseData object
241 void appendResponseData(const CIMResponseData & x);
|
242 r.kieninger 1.1
|
243 thilo.boehm 1.4 // Function used by CMPI layer to complete the namespace on all data held
244 // Input (x) has to have a valid namespace
245 void completeNamespace(const SCMOInstance * x);
|
246 r.kieninger 1.1
|
247 thilo.boehm 1.4 // Function primarily used by CIMOperationRequestDispatcher to complete
248 // namespace and hostname on a,an,r and rn operations in the
249 // OperationAggregator
250 void completeHostNameAndNamespace(
251 const String & hn,
252 const CIMNamespaceName & ns);
|
253 r.kieninger 1.3
|
254 thilo.boehm 1.4 // Encoding responses
|
255 r.kieninger 1.1
|
256 karl 1.6.2.1 // Encode the CIMResponse data into binary format used with Provider Agents
257 // and OP Clients in the provider CIMBuffer
|
258 thilo.boehm 1.4 void encodeBinaryResponse(CIMBuffer& out);
|
259 karl 1.6.2.1
260 // Encode the CIMResponse data into Xml format used with Provider Agents
261 // only in the provided CIMBuffer
|
262 thilo.boehm 1.4 void encodeInternalXmlResponse(CIMBuffer& out);
|
263 karl 1.6.2.1
264 // Encode the CIMResponse data into official Xml format(CIM over Http)
265 // used to communicate to clients in the provided CIMBuffer.
266 //Note that the pull responses requires a flag.
267 void encodeXmlResponse(Buffer& out, Boolean isPull);
268
269 // diagnostic tests magic number in context to see if valid object
270 Boolean valid();
|
271 r.kieninger 1.1
272 private:
273
|
274 thilo.boehm 1.4 // helper functions to transform different formats into one-another
275 // functions work on the internal data and calling of them should be
276 // avoided
277
278 void _resolveToCIM();
279 void _resolveToSCMO();
280
281 void _resolveBinary();
282
283 void _resolveXmlToSCMO();
284 void _resolveXmlToCIM();
285
286 void _resolveSCMOToCIM();
287 void _resolveCIMToSCMO();
288
289 // Helper functions for this class only, do NOT externalize
290 SCMOInstance _getSCMOFromCIMInstance(const CIMInstance& cimInst);
291 SCMOInstance _getSCMOFromCIMObject(const CIMObject& cimObj);
292 SCMOInstance _getSCMOFromCIMObjectPath(const CIMObjectPath& cimPath);
293 SCMOClass* _getSCMOClass(const char* ns,const char* cls);
294
295 thilo.boehm 1.4 // Bitflags in this integer will reflect what data representation types
296 // are currently stored in this CIMResponseData object
297 Uint32 _encoding;
298
|
299 karl 1.6.2.1 // Special flag to handle the case where binary data in passed through the
300 // system but must be mapped to instances in the getInstances. This
301 // accounts for only one case today, binary data in the BinaryCodec
302 Boolean _mapObjectsToIntances;
303
|
304 thilo.boehm 1.4 // Storing type of data in this enumeration
305 ResponseDataContent _dataType;
306
|
307 karl 1.6.2.1 // Count of objects stored in this CIMResponseData object. This is the
308 // accumulated count of objects stored in all of the data
309 // representations
310 Uint32 _size;
311
|
312 thilo.boehm 1.4 // unused arrays are represented by ArrayRepBase _empty_rep
313 // which is a 16 byte large static shared across all of them
314 // so, even though this object looks large, it holds just
315 // 2 integer and 9 pointers
|
316 r.kieninger 1.1
317 // For XML encoding.
318 Array<ArraySint8> _referencesData;
|
319 thilo.boehm 1.4 Array<ArraySint8> _instanceData;
|
320 r.kieninger 1.1 Array<String> _hostsData;
321 Array<CIMNamespaceName> _nameSpacesData;
322
323 // For binary encoding.
324 Array<Uint8> _binaryData;
|
325 thilo.boehm 1.4 CIMNamespaceName _defaultNamespace;
326 String _defaultHostname;
327
328 // Default C++ encoding
329 Array<CIMObjectPath> _instanceNames;
330 Array<CIMInstance> _instances;
331 Array<CIMObject> _objects;
332
333 // SCMO encoding
334 Array<SCMOInstance> _scmoInstances;
|
335 r.kieninger 1.1
|
336 karl 1.6.2.1 // magic number to use with valid function to confirm validity
337 // of response data.
338 Magic<0x57D11323> _magic;
339
|
340 r.kieninger 1.1 };
341
342 PEGASUS_NAMESPACE_END
343
344 #endif /* Pegasus_CIMResponseData_h */
|