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