1 thilo.boehm 1.2 //%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 thilo.boehm 1.2 // 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.8 // This code implements part of PEP#348 - The CMPI infrastructure using SCMO
31 // (Single Chunk Memory Objects).
32 // The design document can be found on the OpenPegasus website openpegasus.org
33 // at https://collaboration.opengroup.org/pegasus/pp/documents/21210/PEP_348.pdf
34 //
|
35 karl 1.9 // This file defines the SCMOInstance interfaces. The implementation of
36 // these methods is in SCMO.cpp
|
37 thilo.boehm 1.2 //%/////////////////////////////////////////////////////////////////////////////
38
39 #ifndef _SCMOINSTANCE_H_
40 #define _SCMOINSTANCE_H_
41
42
43 #include <Pegasus/Common/Config.h>
44 #include <Pegasus/Common/Linkage.h>
45 #include <Pegasus/Common/SCMO.h>
46 #include <Pegasus/Common/SCMOClass.h>
47 #include <Pegasus/Common/Union.h>
48
49 PEGASUS_NAMESPACE_BEGIN
50
|
51 karl 1.9 PEGASUS_USING_STD;
52
|
53 thilo.boehm 1.2 #define PEGASUS_SCMB_INSTANCE_MAGIC 0xD00D1234
54
|
55 karl 1.9 // KS_TODO Temp console display while debugging Sept 2014
56 // Set DIAGDISPLAY to true to enable diagnostics.
57 #define DIAGDISPLAY false
58 #define XCOUT if (DIAGDISPLAY) cout << __FILE__ << ":" << __LINE__ << " "
59
|
60 thilo.boehm 1.2 class PEGASUS_COMMON_LINKAGE SCMOInstance
61 {
62 public:
63
64 /**
65 * A SCMOInstance can only be created by a SCMOClass
66 */
67 SCMOInstance();
68
69 /**
70 * Creating a SCMOInstance using a SCMOClass.
71 * @param baseClass A SCMOClass.
72 */
73 SCMOInstance(SCMOClass& baseClass);
74
75
76 /**
77 * Creating a SCMOInstance using a CIMClass
78 * using an optional name space name,
79 * @param baseClass A SCMOClass.
80 * @param nameSpaceName An optional name space name.
81 thilo.boehm 1.2 */
82 SCMOInstance(CIMClass& theCIMClass, const char* nameSpaceName=0);
83
84 /**
85 * Copy constructor for the SCMO instance, used to implement refcounting.
86 * @param theSCMOClass The instance for which to create a copy
87 * @return
88 */
89 SCMOInstance(const SCMOInstance& theSCMOInstance )
90 {
91 inst.hdr = theSCMOInstance.inst.hdr;
92 Ref();
93 }
94
95 /**
96 * Constructs a SCMOInstance from a memory object of type SCMBInstance_Main.
97 * It incremets the referece counter of the memory object.
98 * @param hdr A memory object of type SCMBInstance_Main.
99 **/
100 SCMOInstance(SCMBInstance_Main* hdr)
101 {
102 thilo.boehm 1.2 inst.hdr = hdr;
103 Ref();
104 }
105
106
107 /**
108 * Assignment operator for the SCMO instance,
109 * @param theSCMOInstance The right hand value
110 **/
111 SCMOInstance& operator=(const SCMOInstance& theSCMOInstance)
112 {
113 if (inst.hdr != theSCMOInstance.inst.hdr)
114 {
115 Unref();
116 inst.hdr = theSCMOInstance.inst.hdr;
117 Ref();
118 }
119 return *this;
120 }
121
122 /**
123 thilo.boehm 1.2 * Destructor is decrementing the refcount. If refcount is zero, the
124 * singele chunk memory object is deallocated.
125 */
126 ~SCMOInstance()
127 {
128 Unref();
129 }
130
131 /**
132 * Builds a SCMOInstance based on this SCMOClass.
133 * The method arguments determine whether qualifiers are included,
134 * the class origin attributes are included,
135 * and which properties are included in the new instance.
136 * @param baseClass The SCMOClass of this instance.
137 * @param includeQualifiers A Boolean indicating whether qualifiers in
138 * the class definition (and its properties) are to be added to the
139 * instance. The TOINSTANCE flavor is ignored.
140 * @param includeClassOrigin A Boolean indicating whether ClassOrigin
141 * attributes are to be added to the instance.
142 *
143 * Note that this function does NOT generate an error if a property name
144 thilo.boehm 1.2 * is supplied that is NOT in the class;
145 * it simply does not add that property to the instance.
146 *
147 */
148 SCMOInstance(
149 SCMOClass& baseClass,
150 Boolean includeQualifiers,
|
151 marek 1.7 Boolean includeClassOrigin);
|
152 thilo.boehm 1.2
153 /**
154 * Builds a SCMOInstance from the given SCMOClass and copies all
155 * CIMInstance data into the new SCMOInstance.
156 * @param baseClass The SCMOClass of this instance.
157 * @param cimInstance A CIMInstace of the same class.
158 * @exception Exception if class name does not match.
159 * @exception Exception if a property is not part of class definition.
160 * @exception Exception if a property does not match the class definition.
161 */
162 SCMOInstance(SCMOClass& baseClass, const CIMInstance& cimInstance);
163
164 /**
165 * Builds a SCMOInstance from the given SCMOClass and copies all
166 * CIMObjectPath data into the new SCMOInstance.
167 * @param baseClass The SCMOClass of this instance.
168 * @param cimInstance A CIMObjectpath of the same class.
169 * @exception Exception if class name does not match.
170 */
171 SCMOInstance(SCMOClass& baseClass, const CIMObjectPath& cimObj);
172
173 thilo.boehm 1.2 /**
174 * Builds a SCMOInstance from the given CIMInstance copying all data.
175 * The SCMOClass is retrieved from SCMOClassCache using
176 * the class and name space of the CIMInstance.
177 * If the SCMOClass was not found, an empty SCMOInstance will be returned
178 * and the resulting SCMOInstance is compromized.
179 * If the CIMInstance does not contain a name space, the optional fall back
180 * name space is used.
181 * @param cimInstance A CIMInstace with class name and name space.
182 * @param altNameSpace An alternative name space name.
183 * @exception Exception if a property is not part of class definition.
184 * @exception Exception if a property does not match the class definition.
185 */
186 SCMOInstance(
187 const CIMInstance& cimInstance,
188 const char* altNameSpace=0,
189 Uint32 altNSLen=0);
190
191 /**
192 * Builds a SCMOInstance from the given CIMObjectPath copying all data.
193 * The SCMOClass is retrieved from SCMOClassCache using
194 thilo.boehm 1.2 * the class and name space of the CIMObjectPath.
195 * If the SCMOClass was not found, an empty SCMOInstance will be returned
196 * and the resulting SCMOInstance is compromized.
197 * If the CIMObjectPath does not contain a name space,
198 * the optional fall back name space is used.
199 * @param cimObj A CIMObjectpath with name space and name
200 * @param altNameSpace An alternative name space name.
201 * @
202 */
203 SCMOInstance(
204 const CIMObjectPath& cimObj,
205 const char* altNameSpace=0,
206 Uint32 altNSLen=0);
207
208 /**
209 * Builds a SCMOInstance from the given CIMObject copying all data.
210 * The SCMOClass is retrieved from SCMOClassCache using
211 * the class and name space of the CIMObject.
212 * If the SCMOClass was not found, an empty SCMOInstance will be returned
213 * and the resulting SCMOInstance is compromized.
214 * If the CIMInstance does not contain a name space, the optional fall back
215 thilo.boehm 1.2 * name space is used.
216 * @param cimInstance A CIMInstace with class name and name space.
217 * @param altNameSpace An alternative name space name.
218 * @exception Exception if a property is not part of class definition.
219 * @exception Exception if a property does not match the class definition.
220 */
221 SCMOInstance(
222 const CIMObject& cimObject,
223 const char* altNameSpace=0,
224 Uint32 altNSLen=0);
225
226 /**
227 * Converts the SCMOInstance into a CIMInstance.
228 * It is a deep copy of the SCMOInstance into the CIMInstance.
229 * @param cimInstance An empty CIMInstance.
230 */
231 SCMO_RC getCIMInstance(CIMInstance& cimInstance) const;
232
233 /**
234 * Makes a deep copy of the instance.
235 * This creates a new copy of the instance.
236 thilo.boehm 1.2 * @param objectPathOnly If set to true, only the object path relevant parts
237 * host name and key bindings are part of the cloned instance.
238 * @return A new copy of the SCMOInstance object.
239 */
240 SCMOInstance clone(Boolean objectPathOnly = false) const;
241
242 /**
243 * Retrieves the objectpath part of the SCMOInstance as an instance
244 * of class CIMObjectPath. .
245 * @param cimObj Reference to an instantiated CIMObjectPath to be
246 * populated with the data from the SCMOInstance.
247 * @return void
248 */
249 void getCIMObjectPath(CIMObjectPath& cimObj) const;
250
251 /**
252 * Returns the number of properties of the instance.
253 * @param Number of properties
254 */
255 Uint32 getPropertyCount() const;
256
257 thilo.boehm 1.2 /**
258 * Gets the property name, type, and value addressed by a positional index.
259 * The property name and value has to be copied by the caller !
260 * @param pos The positional index of the property
261 * @param pname Returns the property name as '\0' terminated string.
262 * Has to be copied by caller.
263 * It is set to NULL if rc != SCMO_OK.
264 * @param pvalue Returns a pointer to the value of property.
265 * The value is stored in a SCMBUnion
266 * and has to be copied by the caller !
267 * It returns NULL if rc != SCMO_OK.
268 *
269 * If the value is an array, the
270 * value array is stored in continuous memory.
271 * e.g. (SCMBUnion*)value[0 to size-1]
272 *
273 * If the value is type of CIMTYPE_STRING,
274 * the string is referenced by the structure
275 * SCMBUnion.extString:
276 * pchar contains the absolut pointer to the string
277 * length contains the size of the string
278 thilo.boehm 1.2 * without trailing '\0'.
279 * Only for strings the caller has to free pvalue !
280 * @param type Returns the CIMType of the property
281 * It is invalid if rc == SCMO_INDEX_OUT_OF_BOUND.
282 * @param isArray Returns if the value is an array.
283 * It is invalid if rc == SCMO_INDEX_OUT_OF_BOUND.
284 * @param size Returns the size of the array.
285 * If it is not an array, 0 is returned.
286 * It is invalid if rc == SCMO_INDEX_OUT_OF_BOUND.
287 *
288 * @return SCMO_OK
289 * SCMO_NULL_VALUE : The value is a null value.
290 * SCMO_INDEX_OUT_OF_BOUND : Given index not found
291 *
292 */
293 SCMO_RC getPropertyAt(
294 Uint32 pos,
295 const char** pname,
296 CIMType& type,
297 const SCMBUnion** pvalue,
298 Boolean& isArray,
299 thilo.boehm 1.2 Uint32& size ) const;
300
|
301 karl 1.9 // KS_FUTURE removed this as not used. Compiles without it
302 //// void getSCMBValuePropertyAt(
303 //// Uint32 pos,
304 //// SCMBValue** value,
305 //// const char ** valueBase,
306 //// SCMBClassProperty ** propDef,
307 //// const char ** classBase) const;
|
308 thilo.boehm 1.2
309 /**
310 * Gets the type and value of the named property.
311 * The value has to be copied by the caller !
312 * @param name The property name
313 * @param pvalue Returns a pointer to the value of property.
314 * The value is stored in a SCMBUnion
315 * and has to be copied by the caller !
316 * It returns NULL if rc != SCMO_OK.
317 *
318 * If the value is an array, the
319 * value array is stored in continuous memory.
320 * e.g. (SCMBUnion*)value[0 to size-1]
321 *
322 * If the value is type of CIMTYPE_STRING,
323 * the string is referenced by the structure
324 * SCMBUnion.extString:
325 * pchar contains the absolut pointer to the string
326 * length contains the size of the string
327 * without trailing '\0'.
328 * Only for strings the caller has to free pvalue !
329 thilo.boehm 1.2 * @param type Returns the CIMType of the property
330 * It is invalid if rc == SCMO_NOT_FOUND.
331 * @param isArray Returns if the value is an array.
332 * It is invalid if rc == SCMO_NOT_FOUND.
333 * @param size Returns the size of the array.
334 * If it is not an array, 0 is returned.
335 * It is invalid if rc == SCMO_NOT_FOUND.
336 *
337 * @return SCMO_OK
338 * SCMO_NULL_VALUE : The value is a null value.
339 * SCMO_NOT_FOUND : Given property name not found.
340 */
341 SCMO_RC getProperty(
342 const char* name,
343 CIMType& type,
344 const SCMBUnion** pvalue,
345 Boolean& isArray,
346 Uint32& size ) const;
347
348 /**
349 * Set/replace a property in the instance.
|
350 karl 1.9 * If the class origin is specified, it is honored when the
351 * property is identified within the instance.
352 *
|
353 thilo.boehm 1.2 * Note: Only properties which are already part of the instance/class can
|
354 karl 1.9 * be set/replaced except in for special case where the flag
355 * lags.noClassForInstance is set when the instance is created.
356 * If the class is not found in the repository, the instance is
357 * are marked as noClassForInstance and properties are set in
358 * the UserDefined properties area.
|
359 thilo.boehm 1.2 * @param name The name of the property to be set.
|
360 karl 1.9 * @param theType The CIMType of the property
|
361 thilo.boehm 1.2 * @param value A pointer to the value to be set at the named property.
|
362 karl 1.9 * The value must be in a SCMBUnion.
|
363 thilo.boehm 1.2 * The value is copied into the instance
364 * If the value == NULL, a null value is assumed.
365 * If the value is an array, the value array has to be
366 * stored in continuous memory.
367 * e.g. (SCMBUnion*)value[0 to size-1]
368 *
369 * To store an array of size 0, The value pointer has to
370 * not NULL ( value != NULL ) but the size has to be 0
371 * (size == 0).
372 *
373 * If the value is type of CIMTYPE_STRING,
374 * the string is referenced by the structure
375 * SCMBUnion.extString:
|
376 karl 1.9 * pchar contains the absolute pointer to
377 * the string length contains the size of
378 * the string
|
379 thilo.boehm 1.2 * without trailing '\0'.
380 * @param isArray Indicate that the value is an array. Default false.
381 * @param size Returns the size of the array. If not an array this
|
382 karl 1.9 * this parameter is ignored. Default 0.
|
383 thilo.boehm 1.2 * @param origin The class originality of the property.
|
384 karl 1.9 * If NULL, then it is ignored. Default NULL.
|
385 thilo.boehm 1.2 * @return SCMO_OK
386 * SCMO_NOT_SAME_ORIGIN : The property name was found, but
387 * the origin was not the same.
388 * SCMO_NOT_FOUND : Given property name not found.
389 * SCMO_WRONG_TYPE : Named property has the wrong type.
390 * SCMO_NOT_AN_ARRAY : Named property is not an array.
391 * SCMO_IS_AN_ARRAY : Named property is an array.
392 */
393 SCMO_RC setPropertyWithOrigin(
394 const char* name,
|
395 karl 1.9 CIMType theType,
|
396 thilo.boehm 1.2 const SCMBUnion* value,
397 Boolean isArray=false,
398 Uint32 size = 0,
399 const char* origin = NULL);
400
401 /**
402 * Rebuild of the key bindings from the property values
403 * if no or incomplete key properties are set on the instance.
404 * @exception NoSuchProperty
405 */
406 void buildKeyBindingsFromProperties();
|
407 karl 1.9
|
408 thilo.boehm 1.2 /**
409 * Gets the hash index for the named property. Filtering is ignored.
410 * @param theName The property name
411 * @param pos Returns the hash index.
412 * @return SCMO_OK
413 * SCMO_INVALID_PARAMETER: name was a NULL pointer.
414 * SCMO_NOT_FOUND : Given property name not found.
415 */
416 SCMO_RC getPropertyNodeIndex(const char* name, Uint32& pos) const;
417
|
418 karl 1.9 // KS_FUTURE confirm that the following is used in OpenPegasus
419 // Apprently never referenced within any of OpenPegasus code
|
420 thilo.boehm 1.2 /**
421 * Set/replace a property in the instance at node index.
422 * @param index The node index.
423 * @param type The CIMType of the property
424 * @param pInVal A pointer to the value to be set at the named property.
425 * The value has to be in a SCMBUnion.
426 * The value is copied into the instance
427 * If the value == NULL, a null value is assumed.
428 * If the value is an array, the value array has to be
429 * stored in continuous memory.
430 * e.g. (SCMBUnion*)value[0 to size-1]
431 *
432 * To store an array of size 0, The value pointer has to
433 * not NULL ( value != NULL ) but the size has to be 0
434 * (size == 0).
435 *
436 * If the value is type of CIMTYPE_STRING,
437 * the string is referenced by the structure
438 * SCMBUnion.extString:
439 * pchar contains the absolut pointer to the string
440 * length contains the size of the string
441 thilo.boehm 1.2 * without trailing '\0'.
442 * @param isArray Indicate that the value is an array. Default false.
443 * @param size The size of the array. If not an array this
444 * this parameter is ignorer. Default 0.
445 * @return SCMO_OK
446 * SCMO_INDEX_OUT_OF_BOUND : Given index not found
447 * SCMO_WRONG_TYPE : The property at given node index
448 * has the wrong type.
449 * SCMO_NOT_AN_ARRAY : The property at given node index
450 * is not an array.
451 * SCMO_IS_AN_ARRAY : The property at given node index
452 * is an array.
453 */
454 SCMO_RC setPropertyWithNodeIndex(
455 Uint32 node,
456 CIMType type,
457 const SCMBUnion* pInVal,
458 Boolean isArray=false,
459 Uint32 size = 0);
460
461 /**
462 thilo.boehm 1.2 * Set/replace the named key binding using binary data
463 * @param name The key binding name.
464 * @param type The type as CIMType.
465 * @param keyvalue A pointer to the binary key value.
466 * The value is copied into the instance
467 * If the value == NULL, a null value is assumed.
468 * @param keyvalue A pointer to the value to be set at the key binding,
469 * The keyvalue has to be in a SCMBUnion.
470 * The keyvalue is copied into the instance.
471 * If the keyvalue == NULL, a null value is assumed.
472 *
473 * If the keyvalue is type of CIMTYPE_STRING,
474 * the string is referenced by the structure
475 * SCMBUnion.extString:
476 * pchar contains the absolut pointer to the string
477 * length contains the size of the string
478 * without trailing '\0'.
479 * @return SCMO_OK
480 * SCMO_INVALID_PARAMETER : Given name or pvalue
481 * is a NULL pointer.
482 * SCMO_TYPE_MISSMATCH : Given type does not
483 thilo.boehm 1.2 * match to key binding type
484 * SCMO_NOT_FOUND : Given property name not found.
485 */
486 SCMO_RC setKeyBinding(
487 const char* name,
488 CIMType type,
489 const SCMBUnion* keyvalue);
490
491 /**
492 * Set/replace the key binding at node
493 * @param node The node index of the key.
494 * @param type The type as CIMType.
495 * @param keyvalue A pointer to the value to be set at the key binding,
496 * The keyvalue has to be in a SCMBUnion.
497 * The keyvalue is copied into the instance.
498 * If the keyvalue == NULL, a null value is assumed.
499 *
500 * If the keyvalue is type of CIMTYPE_STRING,
501 * the string is referenced by the structure
502 * SCMBUnion.extString:
503 * pchar contains the absolut pointer to the string
504 thilo.boehm 1.2 * length contains the size of the string
505 * without trailing '\0'.
506 * @return SCMO_OK
507 * SCMO_INVALID_PARAMETER : Given pvalue is a NULL pointer.
508 * SCMO_TYPE_MISSMATCH : Given type does not
509 * match to key binding type
510 * SCMO_INDEX_OUT_OF_BOUND : Given index is our of range.
511 */
512 SCMO_RC setKeyBindingAt(
513 Uint32 node,
514 CIMType type,
515 const SCMBUnion* keyvalue);
516
517 /**
518 * Clears all key bindings in an instance.
519 * Warning: External references are freed but only the internal
520 * control structures are resetted. No memory is freed and at setting
521 * new key bindings the instance will grow in memory usage.
522 **/
523 void clearKeyBindings();
524
525 thilo.boehm 1.2 /**
526 * Gets the key binding count.
527 * @return the number of key bindings set.
528 */
529 Uint32 getKeyBindingCount() const;
530
531 /**
532 * Get the indexed key binding.
533 * @parm idx The key bining index
534 * @parm pname Returns the name.
535 * Has to be copied by caller.
536 * It is invalid if rc == SCMO_INDEX_OUT_OF_BOUND.
537 * @param type Returns the type as CIMType.
538 * It is invalid if rc == SCMO_INDEX_OUT_OF_BOUND.
539 * @param keyvalue A pointer to the binary key value.
540 * Has to be copied by caller.
541 * It is only valid if rc == SCMO_OK.
542 * @return SCMO_OK
543 * SCMO_NULL_VALUE : The key binding is not set.
544 * SCMO_INDEX_OUT_OF_BOUND : Given index not found
545 *
546 thilo.boehm 1.2 */
547 SCMO_RC getKeyBindingAt(
548 Uint32 idx,
549 const char** pname,
550 CIMType& type,
551 const SCMBUnion** keyvalue) const;
552
553 SCMO_RC getKeyBindingAtUnresolved(
554 Uint32 node,
555 const char** pname,
556 Uint32 & pnameLen,
557 CIMType& type,
558 const SCMBUnion** pdata,
559 const char** valueBase) const;
560
561 /**
562 * Get the named key binding.
563 * @parm name The name of the key binding.
564 * @param type Returns the type as CIMType.
565 * It is invalid if rc == SCMO_INDEX_OUT_OF_BOUND.
566 * @param keyvalue Returns a pointer to the value of keybinding.
567 thilo.boehm 1.2 * The value is stored in a SCMBUnion
568 * and has to be copied by the caller !
569 * It returns NULL if rc != SCMO_OK.
570 *
571 * If the value is type of CIMTYPE_STRING,
572 * the string is referenced by the structure
573 * SCMBUnion.extString:
574 * pchar contains the absolut pointer to the string
575 * length contains the size of the string
576 * without trailing '\0'.
577 * Only for strings the caller has to free pvalue !
578 * @param keyvalue A pointer to the binary key value.
579 * Has to be copied by caller.
580 * It is only valid if rc == SCMO_OK.
581 * @return SCMO_OK
582 * SCMO_NULL_VALUE : The key binding is not set.
583 * SCMO_NOT_FOUND : Given property name not found.
584 */
585 SCMO_RC getKeyBinding(
586 const char* name,
587 CIMType& ptype,
588 thilo.boehm 1.2 const SCMBUnion** keyvalue) const;
589
590 /**
591 * Determines whether the c++ object has been initialized.
592 * @return True if the c++ object has not been initialized, false otherwise.
593 */
594 Boolean isUninitialized( ) const {return (0 == inst.base); };
595
596 /**
597 * Determines if the SCMOInstance does not contain any property information.
598 * Maybe only the class name and/or name space are available.
|
599 karl 1.9 * @return True if the SCMOInstance is empty, false otherwise.
|
600 thilo.boehm 1.2 */
|
601 karl 1.9 Boolean isEmpty( ) const;
|
602 thilo.boehm 1.2
603 /**
604 * Determines whether the instance is used as a class container.
605 * @return True if the instance is used as a class container only.
606 */
607 Boolean getIsClassOnly( ) const
608 {
609 return inst.hdr->flags.isClassOnly;
610 }
611
612 /**
613 * To mark if this instance is a class only container.
614 */
615 void setIsClassOnly( Boolean b )
616 {
617 inst.hdr->flags.isClassOnly = b;
618 }
619
620 /**
621 * Determies if two objects are referencing to the same instance
622 * @return True if the objects are referencing to the some instance.
623 thilo.boehm 1.2 */
624 Boolean isSame(SCMOInstance& theInstance) const;
625
626 /**
627 * Sets the provided host name at the instance.
628 * @param hostName The host name as UTF8.
629 */
630 void setHostName(const char* hostName);
631
632 /**
633 * Get the host name of the instance. The caller has to make a copy !
634 * @return The host name as UTF8.
635 */
636 const char* getHostName() const;
637
638 /**
639 * Get the host name of the instance.
640 * @param Return strlen of result string.
641 * @return The class name as UTF8.
642 */
643 const char* getHostName_l(Uint32 & length) const;
644 thilo.boehm 1.2
645 /**
646 * Sets the provided class name at the instance. By caling this function
647 * the instance is in an inconsitacne state and is maked as isCompromised.
648 * @param className The class name as UTF8.
649 */
650 void setClassName(const char* className);
651
652 /**
653 * Sets the provided class name at the instance. By caling this function
654 * the instance is in an inconsitacne state and is maked as isCompromised.
655 * @param className The class name as UTF8.
656 * @param len The strlen of the name space.
657 */
658 void setClassName_l(const char* className, Uint32 len);
659
660 /**
661 * Get the class name of the instance. The caller has to make a copy !
662 * @return The class name as UTF8.
663 */
664 const char* getClassName() const;
665 thilo.boehm 1.2
666 /**
667 * Get the class name of the instance. The caller has to make a copy !
668 * @param lenght Return strlen of result string.
669 * @return The class name as UTF8.
670 */
671 const char* getClassName_l(Uint32 & length) const;
672
673 /**
674 * Sets the provided name space name at the instance.
675 * By caling this function the instance is in an inconsitacne state and
676 * is maked as isCompromised.
677 * @param nameSpaceName The name space name as UTF8.
678 */
679 void setNameSpace(const char* nameSpace);
680
681 /**
682 * Sets the provided name space name unchecked at the instance.
683 * By caling this function the instance is in an inconsitacne state and
684 * is maked as isCompromised.
685 * @param nameSpaceName The name space name as UTF8.
686 thilo.boehm 1.2 * @param len The strlen of the name space.
687 */
688 void setNameSpace_l(const char* nameSpace, Uint32 len);
689
690 /**
691 * Get the name space of the instance. The caller has to make a copy !
692 * @return The name space as UTF8.
693 */
694 const char* getNameSpace() const;
695
696 /**
697 * Get the class name of the instance. The caller has to make a copy !
698 * @param Return strlen of result string.
699 * @return The class name as UTF8.
700 */
701 const char* getNameSpace_l(Uint32 & length) const;
702
703 /**
|
704 marek 1.6 * If hostname or namespace of the SCMOInstance are NULL or empty string,
705 * replace them with the given input.
706 * @param hn The host name to apply to the SCMOInstance.
707 * @param hnLen The length of the hostname in byte without closing zero.
708 * @param ns The namespace name to apply to the SCMOInstance.
709 * @param nsLen The length of the hostname in byte without closing zero.
710 */
711 void completeHostNameAndNamespace(
712 const char* hn,
713 Uint32 hnLen,
714 const char* ns,
715 Uint32 nsLen);
716
717 /**
|
718 thilo.boehm 1.2 * Is the name space or class name of the instance the origianl values
719 * set by the used SCMOClass.
720 * The class name and/or name space may differ with the associated class.
721 * @return true if name space or class name was set manually by
722 * setNameSpace() or setClassName()
723 */
724 Boolean isCompromised() const
725 {
726 return inst.hdr->flags.isCompromised;
727 };
728
|
729 karl 1.9 /**
730 returns true if there is no class defined for this instance.
731 The flag is set when the SCMO instance is created and the
732 repository returns no class.
733 */
734 Boolean noClassForInstance() const
735 {
736 return inst.hdr->flags.noClassForInstance;
737 };
|
738 thilo.boehm 1.2
739 /**
740 * Mark the instance as a non validated instance.
741 */
742 void markAsCompromised()
743 {
744 inst.hdr->flags.isCompromised = true;
745 };
746
747 /**
|
748 karl 1.9 Sets the flag indicating that there is no class for this
749 instance. This property is used for Instances that are
750 created where there is no class in the repository.
751 */
752 void markNoClassForInstance(Boolean x)
753 {
754 inst.hdr->flags.noClassForInstance = x;
755 };
756
757 /**
|
758 thilo.boehm 1.2 * To indicate the export processing ( eg. XMLWriter )
759 * to include qualifiers for this instance.
760 */
761 void includeQualifiers()
762 {
763 inst.hdr->flags.includeQualifiers = true;
764 };
765
766 /**
767 * To indicate the export processing ( eg. XMLWriter )
768 * to NOT to include (exclude) qualifiers for this instance.
769 */
770 void excludeQualifiers()
771 {
772 inst.hdr->flags.includeQualifiers = false;
773 }
774
775 /**
776 * To indicate the export processing ( eg. XMLWriter )
777 * to include class origins for this instance.
778 */
779 thilo.boehm 1.2 void includeClassOrigins()
780 {
781 inst.hdr->flags.includeClassOrigin = true;
782 };
783
784 /**
785 * To indicate the export processing ( eg. XMLWriter )
786 * to NOT to include (exclude) class origins for this instance.
787 */
788 void excludeClassOrigins()
789 {
790 inst.hdr->flags.includeClassOrigin = false;
791 }
792
793
794 /**
795 * Returns the number of external references hosted by the instance.
796 **/
797 Uint32 numberExtRef() const
798 {
799 return inst.mem->numberExtRef;
800 thilo.boehm 1.2 }
801
802 /**
803 * Gets the pointer of an external reference of the instance.
804 * Warning: The pointer is purely returned. No management is done.
805 * @parm idx The index of the external reference.
806 **/
807 SCMOInstance* getExtRef(Uint32 idx) const;
808
809 /**
810 * Sets a pointer of an external reference of the instance.
811 * Warning: The pointer is purely returned. No management is done.
812 * @parm idx The index of the external reference.
813 * @parm ptr The pointer to an SCMOInstance
814 **/
815 void putExtRef(Uint32 idx,SCMOInstance* ptr);
816
817 private:
818
819 void Ref()
820 {
821 thilo.boehm 1.2 inst.hdr->refCount++;
822 };
823
824 void Unref()
825 {
826 if (inst.hdr->refCount.decAndTestIfZero())
827 {
|
828 karl 1.9 // All external references have to be destroyed.
|
829 thilo.boehm 1.2 _destroyExternalReferences();
830 // The class has also be dereferenced.
831 delete inst.hdr->theClass.ptr;
832 free(inst.base);
833 inst.base=NULL;
834 }
835
836 };
837
838
839 void _copyOnWrite()
840 {
841 if ( 1 < inst.hdr->refCount.get() )
842 {
843 SCMBInstance_Main * oldRef = inst.hdr;
|
844 thilo.boehm 1.3 SCMBMgmt_Header* oldMgmt = inst.mem;
845
|
846 thilo.boehm 1.2 _clone();
847 if (oldRef->refCount.decAndTestIfZero())
848 {
|
849 karl 1.9 // All external references have to be destroyed.
|
850 thilo.boehm 1.3 _destroyExternalReferencesInternal(oldMgmt);
|
851 thilo.boehm 1.2 // The class has also be dereferenced.
852 delete oldRef->theClass.ptr;
853 free((void*)oldRef);
854 oldRef=0;
855 }
856 }
857 };
858
859 void _clone();
860
861 void _destroyExternalReferences();
862
863 void _destroyExternalKeyBindings();
864
865 void _copyExternalReferences();
866
867 void _setExtRefIndex(Uint64 idx);
868
869 void _initSCMOInstance(SCMOClass* pClass);
870
871 void _setCIMInstance(const CIMInstance& cimInstance);
872 thilo.boehm 1.2
|
873 karl 1.9 // Internal but used by friend class SCMOXmlWriter.cpp
874 // This function accounts for user-defined and class-defined properties
|
875 thilo.boehm 1.2 void _getPropertyAt(
876 Uint32 pos,
877 SCMBValue** value,
878 const char ** valueBase,
879 SCMBClassProperty ** propDef) const;
880
881 SCMO_RC _getPropertyAtNodeIndex(
882 Uint32 pos,
883 const char** pname,
884 CIMType& type,
885 const SCMBUnion** pvalue,
886 Boolean& isArray,
887 Uint32& size ) const;
888
889 void _setPropertyAtNodeIndex(
890 Uint32 pos,
891 CIMType type,
892 const SCMBUnion* pInVal,
893 Boolean isArray,
894 Uint32 size);
895
896 thilo.boehm 1.2 void _setCIMValueAtNodeIndex(
897 Uint32 node,
898 CIMValueRep* valRep,
899 CIMType realType);
900
901 static void _getCIMValueFromSCMBUnion(
902 CIMValue& cimV,
903 const CIMType type,
904 const Boolean isNull,
905 const Boolean isArray,
906 const Uint32 arraySize,
907 const SCMBUnion& scmbUn,
908 const char * base);
909
910 static void _getCIMValueFromSCMBValue(
911 CIMValue& cimV,
912 const SCMBValue& scmbV,
913 const char * base);
914
915 static SCMOClass _getSCMOClass(
916 const CIMObjectPath& theCIMObj,
917 thilo.boehm 1.2 const char* altNS,
918 Uint32 altNSlength);
919
920 CIMProperty _getCIMPropertyAtNodeIndex(Uint32 nodeIdx) const;
921
922 void _setCIMObjectPath(const CIMObjectPath& cimObj);
923
924 SCMBUnion* _resolveSCMBUnion(
925 CIMType type,
926 Boolean isArray,
927 Uint32 size,
928 Uint64 start,
929 char* base) const;
930
931 void _setSCMBUnion(
932 const SCMBUnion* pInVal,
933 CIMType type,
934 Boolean isArray,
935 Uint32 size,
936 SCMBUnion & u);
937
938 thilo.boehm 1.2 static void _setUnionValue(
939 Uint64 start,
940 SCMBMgmt_Header** pmem,
941 CIMType type,
942 Uint64 startNS,
943 Uint32 lenNS,
944 Union& u);
945
946 static void _setUnionArrayValue(
947 Uint64 start,
948 SCMBMgmt_Header** pmem,
949 CIMType type,
950 Uint32& n,
951 Uint64 startNS,
952 Uint32 lenNS,
953 Union& u);
954
955 static void _setExtRefIndex(SCMBUnion* pInst, SCMBMgmt_Header** pmem);
956
957 SCMO_RC _getKeyBindingDataAtNodeIndex(
958 Uint32 node,
959 thilo.boehm 1.2 const char** pname,
960 Uint32 & pnameLen,
961 CIMType& type,
962 const SCMBUnion** pdata) const;
963
964 void _copyKeyBindings(SCMOInstance& targetInst) const;
965
966 void _setKeyBindingFromSCMBUnion(
967 CIMType type,
968 const SCMBUnion& u,
969 const char * uBase,
970 SCMBKeyBindingValue& keyData);
971
972 SCMO_RC _setKeyBindingFromString(
973 const char* name,
974 CIMType type,
975 String cimKeyBinding);
976
977 SCMBUserKeyBindingElement* _getUserDefinedKeyBinding(
978 const char* name,
979 Uint32 nameLen,
980 thilo.boehm 1.2 CIMType type);
981
982 void _setUserDefinedKeyBinding(
983 SCMBUserKeyBindingElement& theInsertElement,
984 char* elementBase);
985 /**
986 * Set a SCMO user defined key binding using the class CIM type tolerating
|
987 karl 1.9 * CIM key binding types converted to CIM types by function
|
988 thilo.boehm 1.2 * _CIMTypeFromKeyBindingType().
989 *
990 * @parm classType The type of the key binding in the class definition
991 * @parm setType The type of the key binding to be set.
992 * @param keyValue A pointer to the key binding to be set.
993 * @param kbValue Out parameter, the SCMO keybinding to be set.
994 *
995 **/
996 SCMO_RC _setKeyBindingTypeTolerate(
997 CIMType classType,
998 CIMType setType,
999 const SCMBUnion* keyValue,
1000 SCMBKeyBindingValue& kbValue);
1001
1002 CIMType _CIMTypeFromKeyBindingType(
1003 const char* key,
1004 CIMKeyBinding::Type t);
1005
1006 SCMO_RC _getUserKeyBindingNodeIndex(Uint32& node, const char* name) const;
1007
1008 SCMBUserKeyBindingElement* _getUserDefinedKeyBindingAt(Uint32 index) const;
1009 thilo.boehm 1.2
1010 Boolean _setCimKeyBindingStringToSCMOKeyBindingValue(
1011 const String& kbs,
1012 CIMType type,
1013 SCMBKeyBindingValue& scmoKBV
1014 );
1015
|
1016 karl 1.9 // Functions to support the use of user defined properties
1017 /*
1018 Get the node for a user defined property.
1019 @return node of the property and SCMO_OK or an error
1020 SCMO_NOT_FOUND indicating that the property cannot be
1021 found as a user-defined property.
1022 */
1023 SCMO_RC _getUserPropertyNodeIndex(Uint32& node, const char* name) const;
1024
1025 /*
1026 get the Instance SCMBUserPropertyElement for the defined node index.
1027 */
1028 SCMBUserPropertyElement*
1029 _getUserDefinedPropertyElementAt(Uint32 index) const;
1030
1031 void _setPropertyInUserDefinedElement(
1032 SCMBUserPropertyElement* ptrNewElement,
1033 CIMType theType,
1034 const SCMBUnion* pinVal,
1035 Boolean isArray,
1036 Uint32 size);
1037 karl 1.9 /**
1038 Creates a new user-defined property element, chains it to
1039 the existing user-defined property chain, and populate it
1040 with name, type, isArray. isSet = false.
1041 @return pointer to new SCMBUserPropertyElement
1042 */
1043 SCMBUserPropertyElement* _createNewUserDefinedProperty(
1044 const char * name,
1045 Uint32 nameLen,
1046 CIMType theType);
|
1047 thilo.boehm 1.2
|
1048 karl 1.9 /*
1049 Returns true if the Property is in the set of
1050 properties defined in an including class
1051 */
1052 Boolean _isClassDefinedProperty(Uint32 node) const;
1053
1054 SCMBValue& _getSCMBValueForNode(Uint32 node) const;
1055
1056 /* Definition of inst. Pointer to:
1057 SCMBInstance_Manin
1058 SCMBMgmt_Header
1059 or generic base pointer.
1060 */
|
1061 thilo.boehm 1.2 union{
1062 // To access the instance main structure
1063 SCMBInstance_Main *hdr;
1064 // To access the memory management header
1065 SCMBMgmt_Header *mem;
1066 // Generic access pointer
1067 char *base;
1068 }inst;
1069
1070 friend class SCMOClass;
1071 friend class SCMODump;
1072 friend class SCMOXmlWriter;
1073 friend class SCMOStreamer;
1074 };
1075
|
1076 karl 1.9
1077 inline SCMBValue& SCMOInstance::_getSCMBValueForNode(Uint32 node) const
1078 {
1079 if (_isClassDefinedProperty(node))
1080 {
1081 SCMBValue *theInstPropNodeArray =
1082 (SCMBValue*)&(inst.base[inst.hdr->propertyArray.start]);
1083
1084 return theInstPropNodeArray[node];
1085 }
1086
1087 SCMBUserPropertyElement* pElement =
1088 _getUserDefinedPropertyElementAt(node);
1089 XCOUT << "_getSCMBValueForUserDefinedNode " << node
1090 << " pElement = " << pElement << endl;
1091 return pElement->value;
1092 }
1093
1094
1095 // KS_TODO clarify this test since our rule is more explicit
1096 // We cannot have both user-defined and class-defined properties so this
1097 karl 1.9 // could be a more concrete tests.
1098 inline Boolean SCMOInstance::_isClassDefinedProperty(Uint32 node) const
1099 {
1100 return (node < inst.hdr->numberProperties);
1101 }
1102
1103 // This internal function used by SCMOXmlWriter.cpp
1104 // It is inline because it is called only once in the CIMServer.
|
1105 thilo.boehm 1.2 inline void SCMOInstance::_getPropertyAt(
1106 Uint32 pos,
1107 SCMBValue** value,
1108 const char ** valueBase,
|
1109 karl 1.9 SCMBClassProperty ** propertyDef) const
|
1110 thilo.boehm 1.2 {
|
1111 karl 1.9 if (_isClassDefinedProperty(pos))
1112 {
1113 SCMBValue *theInstPropNodeArray =
1114 (SCMBValue*)&(inst.base[inst.hdr->propertyArray.start]);
|
1115 thilo.boehm 1.2
|
1116 karl 1.9 // create a pointer to property node array of the class.
1117 Uint64 idx =
1118 inst.hdr->theClass.ptr->cls.hdr->propertySet.nodeArray.start;
1119 SCMBClassPropertyNode* theClassPropNodeArray =
1120 (SCMBClassPropertyNode*)&(inst.hdr->theClass.ptr->cls.base)[idx];
|
1121 thilo.boehm 1.2
|
1122 karl 1.9 // return the absolute pointer to the property definition
1123 *propertyDef = &(theClassPropNodeArray[pos].theProperty);
|
1124 thilo.boehm 1.2
|
1125 karl 1.9 // need check if property set or not, if not set use the default value
1126 if (theInstPropNodeArray[pos].flags.isSet)
1127 {
1128 // return the absolute pointer to the property value in the instance
1129 *value = &(theInstPropNodeArray[pos]);
1130 *valueBase = inst.base;
1131 }
1132 else
1133 {
1134 // return the absolute pointer to
1135 *value = &(theClassPropNodeArray[pos].theProperty.defaultValue);
1136 *valueBase = inst.hdr->theClass.ptr->cls.base;
1137 }
1138 }
1139 else // User-defined property
|
1140 thilo.boehm 1.2 {
|
1141 karl 1.9 // KS_TODO mostly same code as _getPropertyAtNodeIndex
1142 SCMBUserPropertyElement* pElement =
1143 _getUserDefinedPropertyElementAt(pos);
1144
1145 PEGASUS_ASSERT(pElement != 0);
1146
1147 *value = &(pElement->value);
1148 // KS_TODO do we have to deal with isSet == false here. Probably
1149 // no but confirm with Assert.
|
1150 thilo.boehm 1.2 *valueBase = inst.base;
1151 }
1152 }
1153
|
1154 karl 1.9 inline Uint32 SCMOInstance::getPropertyCount() const
|
1155 thilo.boehm 1.2 {
|
1156 karl 1.9 return(inst.hdr->numberProperties + inst.hdr->numberUserProperties);
1157 }
|
1158 thilo.boehm 1.2
|
1159 karl 1.9 // KS_FUTURE Remove this completely from code since apparently not used.
1160 ////// Apparently never used.
1161 ////inline void SCMOInstance::getSCMBValuePropertyAt(
1162 //// Uint32 pos,
1163 //// SCMBValue** value,
1164 //// const char ** valueBase,
1165 //// SCMBClassProperty ** propDef,
1166 //// const char ** propDefBase) const
1167 ////{
1168 //// _getPropertyAt(pos,value,valueBase,propDef);
1169 ////
1170 //// *propDefBase = inst.hdr->theClass.ptr->cls.base;
1171 ////}
|
1172 thilo.boehm 1.2
1173 inline SCMO_RC SCMOInstance::getKeyBindingAtUnresolved(
1174 Uint32 node,
1175 const char** pname,
1176 Uint32 & pnameLen,
1177 CIMType& type,
1178 const SCMBUnion** pdata,
1179 const char** valueBase) const
1180 {
1181 SCMO_RC rc = _getKeyBindingDataAtNodeIndex(node,pname,pnameLen,type,pdata);
1182 // Adjust size to string length
1183 if (pnameLen)
1184 {
1185 pnameLen--;
1186 }
1187 *valueBase = inst.base;
1188 return rc;
1189 }
1190
|
1191 karl 1.9 inline Boolean SCMOInstance::isEmpty( ) const
1192 {
1193 if (noClassForInstance())
1194 {
1195 // KS_TODO need another test for empty. Number properties
1196 // != 0 might work but that would disallow an empty embedded
1197 // instance.
1198 return false;
1199 }
1200 else
1201 {
1202 return (inst.hdr->theClass.ptr->isEmpty());
1203 }
1204 }
1205
|
1206 thilo.boehm 1.2
1207
1208 #define PEGASUS_ARRAY_T SCMOInstance
1209 # include <Pegasus/Common/ArrayInter.h>
1210 #undef PEGASUS_ARRAY_T
1211
1212 PEGASUS_NAMESPACE_END
1213
1214
1215 #endif
|