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 marek 1.11 // Class CIMResponseData encapsulates the possible types of response data
31 // representations and supplies conversion methods between these types.
32 // PEP#348 - The CMPI infrastructure using SCMO (Single Chunk Memory Objects)
33 // describes its usage in the server flow.
34 // The design document can be found on the OpenPegasus website openpegasus.org
35 // at https://collaboration.opengroup.org/pegasus/pp/documents/21210/PEP_348.pdf
36 //
|
37 r.kieninger 1.1 //%/////////////////////////////////////////////////////////////////////////////
38
|
39 thilo.boehm 1.4 #ifndef Pegasus_CIMResponseData_h
|
40 r.kieninger 1.1 #define Pegasus_CIMResponseData_h
41
42 #include <Pegasus/Common/Config.h>
43 #include <Pegasus/Common/CIMInstance.h>
44 #include <Pegasus/Common/Linkage.h>
45 #include <Pegasus/Common/CIMBuffer.h>
|
46 thilo.boehm 1.4 #include <Pegasus/Common/SCMOClass.h>
47 #include <Pegasus/Common/SCMOInstance.h>
|
48 r.kieninger 1.1
49 PEGASUS_NAMESPACE_BEGIN
50
51 typedef Array<Sint8> ArraySint8;
52 #define PEGASUS_ARRAY_T ArraySint8
53 # include <Pegasus/Common/ArrayInter.h>
54 #undef PEGASUS_ARRAY_T
55
56
|
57 thilo.boehm 1.4 class PEGASUS_COMMON_LINKAGE CIMResponseData
|
58 r.kieninger 1.1 {
59 public:
60
|
61 thilo.boehm 1.4 enum ResponseDataEncoding {
62 RESP_ENC_CIM = 1,
63 RESP_ENC_BINARY = 2,
64 RESP_ENC_XML = 4,
65 RESP_ENC_SCMO = 8
66 };
|
67 r.kieninger 1.1
|
68 thilo.boehm 1.4 enum ResponseDataContent {
69 RESP_INSTNAMES = 1,
70 RESP_INSTANCES = 2,
71 RESP_INSTANCE = 3,
72 RESP_OBJECTS = 4,
73 RESP_OBJECTPATHS = 5
74 };
|
75 anusha.kandepu 1.7 //includeClassOrigin & _includeQualifiers are set to true by default.
76 //_propertyList is initialized to an empty propertylist to enable
|
77 karl 1.12 // sending all properties by default. _isClassOperation set false and
78 // only reset by selected operations (ex. associator response builder)
|
79 thilo.boehm 1.4 CIMResponseData(ResponseDataContent content):
|
80 anusha.kandepu 1.7 _encoding(0),_dataType(content),_includeQualifiers(true),
|
81 karl 1.12 _includeClassOrigin(true),
82 _isClassOperation(false),
83 _propertyList(CIMPropertyList())
|
84 anusha.kandepu 1.7 {
85 }
|
86 r.kieninger 1.1
|
87 marek 1.5 CIMResponseData(const CIMResponseData & x):
88 _encoding(x._encoding),
89 _dataType(x._dataType),
90 _referencesData(x._referencesData),
91 _instanceData(x._instanceData),
92 _hostsData(x._hostsData),
93 _nameSpacesData(x._nameSpacesData),
94 _binaryData(x._binaryData),
95 _defaultNamespace(x._defaultNamespace),
96 _defaultHostname(x._defaultHostname),
97 _instanceNames(x._instanceNames),
98 _instances(x._instances),
99 _objects(x._objects),
|
100 anusha.kandepu 1.7 _scmoInstances(x._scmoInstances),
|
101 marek 1.8 _includeQualifiers(x._includeQualifiers),
102 _includeClassOrigin(x._includeClassOrigin),
|
103 karl 1.12 _isClassOperation(x._isClassOperation),
|
104 marek 1.8 _propertyList(x._propertyList)
|
105 anusha.kandepu 1.7 {
106 }
|
107 r.kieninger 1.1
|
108 thilo.boehm 1.4 ~CIMResponseData()
|
109 r.kieninger 1.3 {
110 }
111
|
112 thilo.boehm 1.4 // C++ objects interface handling
|
113 r.kieninger 1.1
|
114 thilo.boehm 1.4 // Instance Names handling
115 Array<CIMObjectPath>& getInstanceNames();
|
116 r.kieninger 1.1
|
117 thilo.boehm 1.4 void setInstanceNames(const Array<CIMObjectPath>& x)
|
118 r.kieninger 1.1 {
|
119 thilo.boehm 1.4 _instanceNames=x;
120 _encoding |= RESP_ENC_CIM;
|
121 r.kieninger 1.1 }
122
|
123 thilo.boehm 1.4 // Instance handling
124 CIMInstance& getInstance();
|
125 r.kieninger 1.1
|
126 thilo.boehm 1.4 void setInstance(const CIMInstance& x)
|
127 r.kieninger 1.1 {
|
128 thilo.boehm 1.4 _instances.clear();
129 _instances.append(x);
130 _encoding |= RESP_ENC_CIM;
|
131 r.kieninger 1.1 }
132
|
133 thilo.boehm 1.4 // Instances handling
134 Array<CIMInstance>& getInstances();
135
136 void setInstances(const Array<CIMInstance>& x)
|
137 r.kieninger 1.1 {
|
138 thilo.boehm 1.4 _instances=x;
139 _encoding |= RESP_ENC_CIM;
|
140 r.kieninger 1.1 }
|
141 thilo.boehm 1.4 void appendInstance(const CIMInstance& x)
|
142 r.kieninger 1.1 {
|
143 thilo.boehm 1.4 _instances.append(x);
144 _encoding |= RESP_ENC_CIM;
|
145 r.kieninger 1.1 }
146
|
147 thilo.boehm 1.4 // Objects handling
148 Array<CIMObject>& getObjects();
149 void setObjects(const Array<CIMObject>& x)
|
150 r.kieninger 1.1 {
|
151 thilo.boehm 1.4 _objects=x;
152 _encoding |= RESP_ENC_CIM;
|
153 r.kieninger 1.1 }
|
154 thilo.boehm 1.4 void appendObject(const CIMObject& x)
|
155 r.kieninger 1.3 {
|
156 thilo.boehm 1.4 _objects.append(x);
157 _encoding |= RESP_ENC_CIM;
|
158 r.kieninger 1.3 }
159
|
160 thilo.boehm 1.4 // SCMO representation, single instance stored as one element array
161 // object paths are represented as SCMOInstance
162 Array<SCMOInstance>& getSCMO();
|
163 r.kieninger 1.1
|
164 thilo.boehm 1.4 void setSCMO(const Array<SCMOInstance>& x);
|
165 r.kieninger 1.1
|
166 thilo.boehm 1.4 void appendSCMO(const Array<SCMOInstance>& x)
|
167 r.kieninger 1.1 {
|
168 thilo.boehm 1.4 _scmoInstances.appendArray(x);
169 _encoding |= RESP_ENC_SCMO;
|
170 r.kieninger 1.1 }
171
|
172 thilo.boehm 1.4 Array<Uint8>& getBinary();
|
173 karl 1.6
174 // Set the binary stream in the CIMBuffer into the CIMResponseData
175 bool setBinary(CIMBuffer& in);
176
177 // Set any data from the CIMBuffer remaining after the current CIMBuffer
178 // position pointer into the CIMResponseData Object.
179 bool setRemainingBinaryData(CIMBuffer& in);
|
180 r.kieninger 1.1
|
181 thilo.boehm 1.4 // Xml data is unformatted, no need to differentiate between instance
182 // instances and object paths or objects
183 bool setXml(CIMBuffer& in);
|
184 r.kieninger 1.1
|
185 thilo.boehm 1.4 // function used by OperationAggregator to aggregate response data in a
186 // single ResponseData object
187 void appendResponseData(const CIMResponseData & x);
|
188 r.kieninger 1.1
|
189 thilo.boehm 1.4 // Function used by CMPI layer to complete the namespace on all data held
190 // Input (x) has to have a valid namespace
191 void completeNamespace(const SCMOInstance * x);
|
192 r.kieninger 1.1
|
193 thilo.boehm 1.4 // Function primarily used by CIMOperationRequestDispatcher to complete
194 // namespace and hostname on a,an,r and rn operations in the
195 // OperationAggregator
196 void completeHostNameAndNamespace(
197 const String & hn,
198 const CIMNamespaceName & ns);
|
199 r.kieninger 1.3
|
200 thilo.boehm 1.4 // Encoding responses
|
201 r.kieninger 1.1
|
202 thilo.boehm 1.4 // binary format used with Provider Agents and OP Clients
203 void encodeBinaryResponse(CIMBuffer& out);
204 // Xml format used with Provider Agents only
205 void encodeInternalXmlResponse(CIMBuffer& out);
206 // official Xml format(CIM over Http) used to communicate to clients
207 void encodeXmlResponse(Buffer& out);
|
208 karl 1.12
209 //This function is called from buildResponce to set CIMResponcedata
|
210 anusha.kandepu 1.7 //with respective values of IncludeQualifiers,IncludeClassOrigin and
211 //propertyFilter.
212 void setRequestProperties(
213 const Boolean includeQualifiers,
214 const Boolean includeClassOrigin,
215 const CIMPropertyList& propertyList);
|
216 marek 1.8
|
217 karl 1.12 // Used with association and reference operations (i.e. operations that
218 // return CIMObject or CIMObjectPath to set a parameter to define whether
219 // responseData is for operation on a class or instance.
220 // Allows building the correct path (classPath or instancePath) and
221 // object type (Class or Instance) on response.
222 void setIsClassOperation(Boolean b);
223
|
224 marek 1.8 void setPropertyList(const CIMPropertyList& propertyList)
225 {
226 _propertyList = propertyList;
227 }
228 CIMPropertyList & getPropertyList()
229 {
230 return _propertyList;
231 }
|
232 r.kieninger 1.1
233 private:
234
|
235 thilo.boehm 1.4 // helper functions to transform different formats into one-another
236 // functions work on the internal data and calling of them should be
237 // avoided
238
239 void _resolveToCIM();
240 void _resolveToSCMO();
241
242 void _resolveBinary();
243
244 void _resolveXmlToSCMO();
245 void _resolveXmlToCIM();
246
247 void _resolveSCMOToCIM();
248 void _resolveCIMToSCMO();
249
250 // Helper functions for this class only, do NOT externalize
251 SCMOInstance _getSCMOFromCIMInstance(const CIMInstance& cimInst);
252 SCMOInstance _getSCMOFromCIMObject(const CIMObject& cimObj);
253 SCMOInstance _getSCMOFromCIMObjectPath(const CIMObjectPath& cimPath);
254 SCMOClass* _getSCMOClass(const char* ns,const char* cls);
|
255 thilo.boehm 1.9 void _deserializeInstance(Uint32 idx,CIMInstance& cimInstance);
256 void _deserializeObject(Uint32 idx,CIMObject& cimObject);
257 Boolean _deserializeReference(Uint32 idx,CIMObjectPath& cimObjectPath);
258 Boolean _deserializeInstanceName(Uint32 idx,CIMObjectPath& cimObjectPath);
|
259 thilo.boehm 1.4
260 // Bitflags in this integer will reflect what data representation types
261 // are currently stored in this CIMResponseData object
262 Uint32 _encoding;
263
264 // Storing type of data in this enumeration
265 ResponseDataContent _dataType;
266
267 // unused arrays are represented by ArrayRepBase _empty_rep
268 // which is a 16 byte large static shared across all of them
269 // so, even though this object looks large, it holds just
270 // 2 integer and 9 pointers
|
271 r.kieninger 1.1
272 // For XML encoding.
273 Array<ArraySint8> _referencesData;
|
274 thilo.boehm 1.4 Array<ArraySint8> _instanceData;
|
275 r.kieninger 1.1 Array<String> _hostsData;
276 Array<CIMNamespaceName> _nameSpacesData;
277
|
278 thilo.boehm 1.4
|
279 r.kieninger 1.1 // For binary encoding.
280 Array<Uint8> _binaryData;
|
281 thilo.boehm 1.4 CIMNamespaceName _defaultNamespace;
282 String _defaultHostname;
283
284 // Default C++ encoding
285 Array<CIMObjectPath> _instanceNames;
286 Array<CIMInstance> _instances;
287 Array<CIMObject> _objects;
288
289 // SCMO encoding
290 Array<SCMOInstance> _scmoInstances;
|
291 karl 1.12
292 // Request characteristics that are carried through operation for
293 // modification of response generation.
294 Boolean _includeQualifiers;
|
295 anusha.kandepu 1.7 Boolean _includeClassOrigin;
|
296 karl 1.12 // Defines whether response CIMObjects or ObjectPaths are class or instance.
|
297 karl 1.13 // because associators, etc. operations provide both class and instance
298 // responses. Default is false and should only be set to true by
299 // operation requests such as associators (which could return either
300 // instances or classes) when the operation is to return class information.
|
301 karl 1.12 Boolean _isClassOperation;
|
302 anusha.kandepu 1.7 CIMPropertyList _propertyList;
|
303 r.kieninger 1.1
304 };
305
306 PEGASUS_NAMESPACE_END
307
308 #endif /* Pegasus_CIMResponseData_h */
|