(file) Return to MemoryResidentRepository.cpp CVS log (file) (dir) Up to [Pegasus] / pegasus / src / Pegasus / Repository

  1 mike  1.1.2.1 //%2006////////////////////////////////////////////////////////////////////////
  2               //
  3               // Copyright (c) 2000, 2001, 2002 BMC Software; Hewlett-Packard Development
  4               // Company, L.P.; IBM Corp.; The Open Group; Tivoli Systems.
  5               // Copyright (c) 2003 BMC Software; Hewlett-Packard Development Company, L.P.;
  6               // IBM Corp.; EMC Corporation, The Open Group.
  7               // Copyright (c) 2004 BMC Software; Hewlett-Packard Development Company, L.P.;
  8               // IBM Corp.; EMC Corporation; VERITAS Software Corporation; The Open Group.
  9               // Copyright (c) 2005 Hewlett-Packard Development Company, L.P.; IBM Corp.;
 10               // EMC Corporation; VERITAS Software Corporation; The Open Group.
 11               // Copyright (c) 2006 Hewlett-Packard Development Company, L.P.; IBM Corp.;
 12               // EMC Corporation; Symantec Corporation; The Open Group.
 13               //
 14               // Permission is hereby granted, free of charge, to any person obtaining a copy
 15               // of this software and associated documentation files (the "Software"), to
 16               // deal in the Software without restriction, including without limitation the
 17               // rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
 18               // sell copies of the Software, and to permit persons to whom the Software is
 19               // furnished to do so, subject to the following conditions:
 20               //
 21               // THE ABOVE COPYRIGHT NOTICE AND THIS PERMISSION NOTICE SHALL BE INCLUDED IN
 22 mike  1.1.2.1 // ALL COPIES OR SUBSTANTIAL PORTIONS OF THE SOFTWARE. THE SOFTWARE IS PROVIDED
 23               // "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT
 24               // LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
 25               // PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
 26               // HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
 27               // ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
 28               // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
 29               //
 30               //==============================================================================
 31               //
 32               //%/////////////////////////////////////////////////////////////////////////////
 33               
 34               #include <cstdarg>
 35               #include <Pegasus/Common/Resolver.h>
 36               #include "MemoryResidentRepository.h"
 37               #include "RepositoryDeclContext.h"
 38               #include "MetaRepository.h"
 39               #include "Filtering.h"
 40 mike  1.1.2.3 #include "Serialization.h"
 41 mike  1.1.2.1 
 42               PEGASUS_NAMESPACE_BEGIN
 43               
 44 mike  1.1.2.2 #define PEGASUS_ARRAY_T NamespaceInstancePair
 45               # include <Pegasus/Common/ArrayImpl.h>
 46               #undef PEGASUS_ARRAY_T
 47               
 48 mike  1.1.2.1 //==============================================================================
 49               //
 50               // Local routines:
 51               //
 52               //==============================================================================
 53               
 54               PEGASUS_FORMAT(2, 3)
 55               static void _throw(CIMStatusCode code, const char* format, ...)
 56               {
 57                   char buffer[4096];
 58               
 59                   va_list ap;
 60                   va_start(ap, format);
 61                   vsprintf(buffer, format, ap);
 62                   va_end(ap);
 63                   throw CIMException(code, buffer);
 64               }
 65               
 66               class Str
 67               {
 68               public:
 69 mike  1.1.2.1     Str(const String& s) : _cstr(s.getCString()) { }
 70                   Str(const CIMName& n) : _cstr(n.getString().getCString()) { }
 71                   Str(const CIMNamespaceName& n) : _cstr(n.getString().getCString()) { }
 72                   Str(const Exception& e) : _cstr(e.getMessage().getCString()) { }
 73                   Str(const CIMDateTime& x) : _cstr(x.toString().getCString()) { }
 74                   Str(const CIMObjectPath& x) : _cstr(x.toString().getCString()) { }
 75                   const char* operator*() const { return (const char*)_cstr; }
 76                   operator const char*() const { return (const char*)_cstr; }
 77               private:
 78                   CString _cstr;
 79               };
 80               
 81               static bool _contains(const CIMPropertyList& propertyList, const CIMName& name)
 82               {
 83                   for (Uint32 i = 0; i < propertyList.size(); i++)
 84                   {
 85                       if (propertyList[i] == name)
 86                           return true;
 87                   }
 88               
 89                   return false;
 90 mike  1.1.2.1 }
 91               
 92               static void _applyModifiedInstance(
 93                   const MetaClass* mc,
 94                   const CIMInstance& modifiedInstance_,
 95                   const CIMPropertyList& propertyList,
 96                   CIMInstance& resultInstance)
 97               {
 98                   CIMInstance& modifiedInstance = *((CIMInstance*)&modifiedInstance_);
 99               
100                   for (Uint32 i = 0; i < modifiedInstance.getPropertyCount(); i++)
101                   {
102                       CIMProperty cp = modifiedInstance.getProperty(i);
103                       Uint32 pos = resultInstance.findProperty(cp.getName());
104               
105                       if (propertyList.isNull() || _contains(propertyList, cp.getName()))
106                       {
107                           // Reject attempts to add properties not in class:
108               
109                           const MetaFeature* mf = FindFeature(
110                               mc, *Str(cp.getName()), META_FLAG_PROPERTY|META_FLAG_REFERENCE);
111 mike  1.1.2.1 
112                           if (!mf)
113                           {
114                               _throw(CIM_ERR_NOT_FOUND, 
115                                   "modifyInstance() failed: unknown property: %s",
116                                   *Str(cp.getName()));
117                           }
118               
119                           // Reject attempts to modify key properties:
120               
121                           if (mf->flags & META_FLAG_KEY)
122                           {
123                               _throw(CIM_ERR_FAILED,
124                                   "modifyInstance() failed to modify key property: %s",
125                                   *Str(cp.getName()));
126                           }
127               
128                           // Add or replace property in result instance:
129               
130                           if (pos != PEG_NOT_FOUND)
131                               resultInstance.removeProperty(pos);
132 mike  1.1.2.1 
133                           resultInstance.addProperty(cp);
134                       }
135                   }
136               }
137               
138               static void _print(const CIMInstance& ci)
139               {
140                   CIMObject co(ci);
141               
142                   std::cout << co.toString() << std::endl;
143               }
144               
145               //==============================================================================
146               //
147               // class MemoryResidentRepository:
148               //
149               //==============================================================================
150               
151 mike  1.1.2.4 static void (*_saveCallback)(const Buffer& buffer, void* data);
152               static void* _saveData;
153               static void (*_loadCallback)(Buffer& buffer, void* data);
154               static void* _loadData;
155 mike  1.1.2.3 
156 mike  1.1.2.1 MemoryResidentRepository::MemoryResidentRepository(
157                   const String& repositoryRoot, 
158                   Uint32 repositoryMode) 
159                   : 
160                   Repository(repositoryRoot, repositoryMode)
161               {
162 mike  1.1.2.3     // Load users data if any:
163                   _processLoadHandler();
164 mike  1.1.2.1 }
165               
166               MemoryResidentRepository::~MemoryResidentRepository()
167               {
168               }
169               
170               CIMClass MemoryResidentRepository::getClass(
171                   bool lock,
172                   const CIMNamespaceName& nameSpace,
173                   const CIMName& className,
174                   Boolean localOnly,
175                   Boolean includeQualifiers,
176                   Boolean includeClassOrigin,
177                   const CIMPropertyList& propertyList)
178               {
179                   return MetaRepository::getClass(
180                       nameSpace, 
181                       className, 
182                       localOnly,
183                       includeQualifiers,
184                       includeClassOrigin,
185 mike  1.1.2.1         propertyList);
186               }
187               
188               CIMInstance MemoryResidentRepository::getInstance(
189                   bool lock,
190                   const CIMNamespaceName& nameSpace,
191                   const CIMObjectPath& instanceName,
192                   Boolean localOnly,
193                   Boolean includeQualifiers,
194                   Boolean includeClassOrigin,
195                   const CIMPropertyList& propertyList)
196               {
197                   Uint32 pos = _findInstance(nameSpace, instanceName);
198               
199                   if (pos == PEG_NOT_FOUND)
200                       _throw(CIM_ERR_NOT_FOUND, "%s", *Str(instanceName));
201               
202                   CIMInstance cimInstance = _rep[pos].second.clone();
203               
204                   Filtering::filterInstance(
205                       cimInstance,
206 mike  1.1.2.1         localOnly,
207                       includeQualifiers,
208                       includeClassOrigin,
209                       propertyList);
210               
211                   return cimInstance;
212               }
213               
214               void MemoryResidentRepository::deleteClass(
215                   bool lock,
216                   const CIMNamespaceName& nameSpace,
217                   const CIMName& className)
218               {
219                   MetaRepository::deleteClass(
220                       nameSpace,
221                       className);
222               }
223               
224               void MemoryResidentRepository::deleteInstance(
225                   bool lock,
226                   const CIMNamespaceName& nameSpace,
227 mike  1.1.2.1     const CIMObjectPath& instanceName)
228               {
229                   Uint32 pos = _findInstance(nameSpace, instanceName);
230               
231                   if (pos == PEG_NOT_FOUND)
232                       _throw(CIM_ERR_NOT_FOUND, "%s", *Str(instanceName));
233               
234                   _rep.remove(pos);
235 mike  1.1.2.3     _processSaveHandler();
236 mike  1.1.2.1 }
237               
238               void MemoryResidentRepository::createClass(
239                   bool lock,
240                   const CIMNamespaceName& nameSpace,
241                   const CIMClass& newClass,
242                   const ContentLanguageList& contentLangs)
243               {
244                   MetaRepository::createClass(
245                       nameSpace,
246                       newClass);
247               }
248               
249               CIMObjectPath MemoryResidentRepository::createInstance(
250                   bool lock,
251                   const CIMNamespaceName& nameSpace,
252                   const CIMInstance& newInstance,
253                   const ContentLanguageList& contentLangs)
254               {
255                   // Resolve the instance first:
256               
257 mike  1.1.2.1     CIMInstance ci(newInstance.clone());
258                   CIMConstClass cc;
259                   RepositoryDeclContext context(this);
260                   Resolver::resolveInstance(ci, &context, nameSpace, cc, false);
261                   CIMObjectPath cop = ci.buildPath(cc);
262               
263                   ci.setPath(cop);
264               
265                   // Reject if an instance with this name already exists:
266               
267                   if (_findInstance(nameSpace, cop) != PEG_NOT_FOUND)
268                       _throw(CIM_ERR_ALREADY_EXISTS, "%s", *Str(cop));
269               
270                   // Add instance to array:
271               
272                   _rep.append(NamespaceInstancePair(nameSpace, ci));
273 mike  1.1.2.3     _processSaveHandler();
274 mike  1.1.2.1 
275                   return cop;
276               }
277               
278               void MemoryResidentRepository::modifyClass(
279                   bool lock,
280                   const CIMNamespaceName& nameSpace,
281                   const CIMClass& modifiedClass,
282                   const ContentLanguageList& contentLangs)
283               {
284                   MetaRepository::modifyClass(
285                       nameSpace,
286                       modifiedClass);
287               }
288               
289               void MemoryResidentRepository::modifyInstance(
290                   bool lock,
291                   const CIMNamespaceName& nameSpace,
292                   const CIMInstance& modifiedInstance,
293                   Boolean includeQualifiers,
294                   const CIMPropertyList& propertyList,
295 mike  1.1.2.1     const ContentLanguageList& contentLangs)
296               {
297                   const CIMObjectPath& cop = modifiedInstance.getPath();
298                   CIMName className = cop.getClassName();
299               
300                   // Get the meta class for this instance.
301               
302                   const MetaClass* mc = MetaRepository::findMetaClass(
303                       *Str(nameSpace), *Str(className));
304               
305                   if (!mc)
306                   {
307                       _throw(CIM_ERR_FAILED, 
308                           "modifyInstance() failed: unknown class: %s:%s",
309                           *Str(nameSpace), *Str(className));
310                   }
311               
312                   // Get original instance to be modified:
313               
314                   Uint32 pos = _findInstance(nameSpace, cop);
315               
316 mike  1.1.2.1     if (pos == PEG_NOT_FOUND)
317                   {
318                       _throw(CIM_ERR_NOT_FOUND, "modified() failed: unknown instance: %s",
319                           *Str(cop.toString()));
320                   }
321               
322                   CIMInstance resultInstance = _rep[pos].second.clone();
323               
324                   // Apply features of modifiedInstance to result instance.
325               
326                   _applyModifiedInstance(mc, modifiedInstance, propertyList, resultInstance);
327               
328                   // Resolve the instance.
329               
330                   CIMConstClass cc;
331                   RepositoryDeclContext context(this);
332                   Resolver::resolveInstance(resultInstance, &context, nameSpace, cc, false);
333               
334                   // Replace original instance.
335               
336                   _rep[pos].second = resultInstance;
337 mike  1.1.2.3     _processSaveHandler();
338 mike  1.1.2.1 }
339               
340               Array<CIMClass> MemoryResidentRepository::enumerateClasses(
341                   bool lock,
342                   const CIMNamespaceName& nameSpace,
343                   const CIMName& className,
344                   Boolean deepInheritance,
345                   Boolean localOnly,
346                   Boolean includeQualifiers,
347                   Boolean includeClassOrigin)
348               {
349                   return MetaRepository::enumerateClasses(
350                       nameSpace,
351                       className,
352                       deepInheritance,
353                       localOnly,
354                       includeQualifiers,
355                       includeClassOrigin);
356               }
357               
358               Array<CIMName> MemoryResidentRepository::enumerateClassNames(
359 mike  1.1.2.1     bool lock,
360                   const CIMNamespaceName& nameSpace,
361                   const CIMName& className,
362                   Boolean deepInheritance)
363               {
364                   return MetaRepository::enumerateClassNames(
365                       nameSpace,
366                       className,
367                       deepInheritance);
368               }
369               
370               Array<CIMInstance> MemoryResidentRepository::enumerateInstancesForSubtree(
371                   bool lock,
372                   const CIMNamespaceName& nameSpace,
373                   const CIMName& className,
374                   Boolean deepInheritance,
375                   Boolean localOnly,
376                   Boolean includeQualifiers,
377                   Boolean includeClassOrigin,
378                   const CIMPropertyList& propertyList)
379               {
380 mike  1.1.2.1     // Form array of classnames for this class and descendent classes:
381               
382                   Array<CIMName> classNames;
383                   classNames.append(className);
384                   MetaRepository::getSubClassNames(nameSpace, className, true, classNames);
385               
386                   // Get all instances for this class and all descendent classes
387               
388                   Array<CIMInstance> result;
389               
390                   for (Uint32 i = 0; i < classNames.size(); i++)
391                   {
392                       Array<CIMInstance> instances = enumerateInstancesForClass(false, 
393                           nameSpace, classNames[i], false, includeQualifiers, 
394                           includeClassOrigin, propertyList);
395               
396                       for (Uint32 i = 0 ; i < instances.size(); i++)
397                       {
398                           Filtering::filterInstance(
399                               instances[i],
400                               localOnly,
401 mike  1.1.2.1                 includeQualifiers,
402                               includeClassOrigin,
403                               propertyList);
404                       }
405               
406                       result.appendArray(instances);
407                   }
408               
409                   return result;
410               }
411               
412               Array<CIMInstance> MemoryResidentRepository::enumerateInstancesForClass(
413                   bool lock,
414                   const CIMNamespaceName& nameSpace,
415                   const CIMName& className,
416                   Boolean localOnly,
417                   Boolean includeQualifiers,
418                   Boolean includeClassOrigin,
419                   const CIMPropertyList& propertyList)
420               {
421                   Array<CIMInstance> result;
422 mike  1.1.2.1 
423                   for (Uint32 i = 0; i < _rep.size(); i++)
424                   {
425                       if (_rep[i].first != nameSpace)
426                           continue;
427               
428                       CIMInstance& ci = _rep[i].second;
429               
430                       if (ci.getPath().getClassName() == className)
431                       {
432                           CIMInstance tmp = ci.clone();
433               
434                           Filtering::filterInstance(
435                               tmp,
436                               localOnly,
437                               includeQualifiers,
438                               includeClassOrigin,
439                               propertyList);
440               
441                           result.append(tmp);
442                       }
443 mike  1.1.2.1     }
444               
445                   return result;
446               }
447               
448               Array<CIMObjectPath> MemoryResidentRepository::enumerateInstanceNamesForSubtree(
449                   bool lock,
450                   const CIMNamespaceName& nameSpace,
451                   const CIMName& className)
452               {
453                   // Form array of classnames for this class and descendent classes:
454               
455                   Array<CIMName> classNames;
456                   classNames.append(className);
457                   MetaRepository::getSubClassNames(nameSpace, className, true, classNames);
458               
459                   // Get all instances for this class and all descendent classes
460               
461                   Array<CIMObjectPath> result;
462               
463                   for (Uint32 i = 0; i < classNames.size(); i++)
464 mike  1.1.2.1     {
465                       Array<CIMObjectPath> paths = enumerateInstanceNamesForClass(
466                           false, nameSpace, classNames[i]);
467               
468                       result.appendArray(paths);
469                   }
470               
471                   return result;
472               }
473               
474               Array<CIMObjectPath> MemoryResidentRepository::enumerateInstanceNamesForClass(
475                   bool lock,
476                   const CIMNamespaceName& nameSpace,
477                   const CIMName& className)
478               {
479                   Array<CIMObjectPath> result;
480               
481                   for (Uint32 i = 0; i < _rep.size(); i++)
482                   {
483                       if (_rep[i].first != nameSpace)
484                           continue;
485 mike  1.1.2.1 
486                       CIMInstance& ci = _rep[i].second;
487               
488                       if (ci.getPath().getClassName() == className)
489                           result.append(ci.getPath());
490                   }
491               
492                   return result;
493               }
494               
495               Array<CIMInstance> MemoryResidentRepository::execQuery(
496                   bool lock,
497                   const String& queryLanguage,
498                   const String& query)
499               {
500                   _throw(CIM_ERR_NOT_SUPPORTED, "execQuery()");
501                   return Array<CIMInstance>();
502               }
503               
504               Array<CIMObject> MemoryResidentRepository::associators(
505                   bool lock,
506 mike  1.1.2.1     const CIMNamespaceName& nameSpace,
507                   const CIMObjectPath& objectName,
508                   const CIMName& assocClass,
509                   const CIMName& resultClass,
510                   const String& role,
511                   const String& resultRole,
512                   Boolean includeQualifiers,
513                   Boolean includeClassOrigin,
514                   const CIMPropertyList& propertyList)
515               {
516                   if (objectName.getKeyBindings().size() == 0)
517                   {
518                       return MetaRepository::associatorClasses(
519                           nameSpace,
520                           objectName.getClassName(),
521                           assocClass,
522                           resultClass,
523                           role,
524                           resultRole,
525                           includeQualifiers,
526                           includeClassOrigin,
527 mike  1.1.2.1             propertyList);
528                   }
529                   else
530                   {
531                       _throw(CIM_ERR_NOT_SUPPORTED, "associators()");
532                       return Array<CIMObject>();
533                   }
534               }
535               
536               Array<CIMObjectPath> MemoryResidentRepository::associatorNames(
537                   bool lock,
538                   const CIMNamespaceName& nameSpace,
539                   const CIMObjectPath& objectName,
540                   const CIMName& assocClass,
541                   const CIMName& resultClass,
542                   const String& role,
543                   const String& resultRole)
544               {
545                   if (objectName.getKeyBindings().size() == 0)
546                   {
547                       return MetaRepository::associatorClassPaths(
548 mike  1.1.2.1             nameSpace,
549                           objectName.getClassName(),
550                           assocClass,
551                           resultClass,
552                           role,
553                           resultRole);
554                   }
555                   else
556                   {
557                       _throw(CIM_ERR_NOT_SUPPORTED, "associatorNames()");
558                       return Array<CIMObjectPath>();
559                   }
560               }
561               
562               Array<CIMObject> MemoryResidentRepository::references(
563                   bool lock,
564                   const CIMNamespaceName& nameSpace,
565                   const CIMObjectPath& objectName,
566                   const CIMName& resultClass,
567                   const String& role,
568                   Boolean includeQualifiers,
569 mike  1.1.2.1     Boolean includeClassOrigin,
570                   const CIMPropertyList& propertyList)
571               {
572                   if (objectName.getKeyBindings().size() == 0)
573                   {
574                       return MetaRepository::referenceClasses(
575                           nameSpace,
576                           objectName.getClassName(),
577                           resultClass,
578                           role,
579                           includeQualifiers,
580                           includeClassOrigin,
581                           propertyList);
582                   }
583                   else
584                   {
585                       _throw(CIM_ERR_NOT_SUPPORTED, "references()");
586                       return Array<CIMObject>();
587                   }
588               }
589               
590 mike  1.1.2.1 Array<CIMObjectPath> MemoryResidentRepository::referenceNames(
591                   bool lock,
592                   const CIMNamespaceName& nameSpace,
593                   const CIMObjectPath& objectName,
594                   const CIMName& resultClass,
595                   const String& role)
596               {
597                   if (objectName.getKeyBindings().size() == 0)
598                   {
599                       return MetaRepository::referenceClassPaths(
600                           nameSpace,
601                           objectName.getClassName(),
602                           resultClass,
603                           role);
604                   }
605                   else
606                   {
607                       _throw(CIM_ERR_NOT_SUPPORTED, "referenceNames()");
608                       return Array<CIMObjectPath>();
609                   }
610               }
611 mike  1.1.2.1 
612               CIMValue MemoryResidentRepository::getProperty(
613                   bool lock,
614                   const CIMNamespaceName& nameSpace,
615                   const CIMObjectPath& instanceName,
616                   const CIMName& propertyName)
617               {
618                   _throw(CIM_ERR_NOT_SUPPORTED, "getProperty()");
619                   return CIMValue();
620               }
621               
622               void MemoryResidentRepository::setProperty(
623                   bool lock,
624                   const CIMNamespaceName& nameSpace,
625                   const CIMObjectPath& instanceName,
626                   const CIMName& propertyName,
627                   const CIMValue& newValue,
628                   const ContentLanguageList& contentLangs)
629               {
630                   _throw(CIM_ERR_NOT_SUPPORTED, "setProperty()");
631               }
632 mike  1.1.2.1 
633               CIMQualifierDecl MemoryResidentRepository::getQualifier(
634                   bool lock,
635                   const CIMNamespaceName& nameSpace,
636                   const CIMName& qualifierName)
637               {
638                   return MetaRepository::getQualifier(nameSpace, qualifierName);
639               }
640               
641               void MemoryResidentRepository::setQualifier(
642                   bool lock,
643                   const CIMNamespaceName& nameSpace,
644                   const CIMQualifierDecl& qualifierDecl,
645                   const ContentLanguageList& contentLangs)
646               {
647                   MetaRepository::setQualifier(nameSpace, qualifierDecl);
648               }
649               
650               void MemoryResidentRepository::deleteQualifier(
651                   bool lock,
652                   const CIMNamespaceName& nameSpace,
653 mike  1.1.2.1     const CIMName& qualifierName)
654               {
655                   MetaRepository::deleteQualifier(nameSpace, qualifierName);
656               }
657               
658               Array<CIMQualifierDecl> MemoryResidentRepository::enumerateQualifiers(
659                   bool lock,
660                   const CIMNamespaceName& nameSpace)
661               {
662                   return MetaRepository::enumerateQualifiers(nameSpace);
663               }
664               
665               void MemoryResidentRepository::createNameSpace(
666                   bool lock,
667                   const CIMNamespaceName& nameSpace,
668                   const NameSpaceAttributes& attributes)
669               {
670                   MetaRepository::createNameSpace(nameSpace, attributes);
671               }
672               
673               void MemoryResidentRepository::modifyNameSpace(
674 mike  1.1.2.1     bool lock,
675                   const CIMNamespaceName& nameSpace,
676                   const NameSpaceAttributes& attributes)
677               {
678                   MetaRepository::createNameSpace(nameSpace, attributes);
679               }
680               
681               Array<CIMNamespaceName> MemoryResidentRepository::enumerateNameSpaces(
682                   bool lock) const
683               {
684                   return MetaRepository::enumerateNameSpaces();
685               }
686               
687               void MemoryResidentRepository::deleteNameSpace(
688                   bool lock,
689                   const CIMNamespaceName& nameSpace)
690               {
691                   MetaRepository::deleteNameSpace(nameSpace);
692               }
693               
694               Boolean MemoryResidentRepository::getNameSpaceAttributes(
695 mike  1.1.2.1     bool lock,
696                   const CIMNamespaceName& nameSpace,
697                   NameSpaceAttributes& attributes)
698               {
699                   attributes.clear();
700                   return false;
701               }
702               
703               void MemoryResidentRepository::setDeclContext(
704                   bool lock,
705                   RepositoryDeclContext* context)
706               {
707                   _throw(CIM_ERR_NOT_SUPPORTED, "setDeclContext()");
708               }
709               
710               Boolean MemoryResidentRepository::isDefaultInstanceProvider(
711                   bool lock)
712               {
713                   return true;
714               }
715               
716 mike  1.1.2.1 void MemoryResidentRepository::getSubClassNames(
717                   bool lock,
718                   const CIMNamespaceName& nameSpace,
719                   const CIMName& className,
720                   Boolean deepInheritance,
721                   Array<CIMName>& subClassNames) const
722               {
723                   MetaRepository::getSubClassNames(
724                       nameSpace,
725                       className,
726                       deepInheritance,
727                       subClassNames);
728               }
729               
730               void MemoryResidentRepository::getSuperClassNames(
731                   bool lock,
732                   const CIMNamespaceName& nameSpace,
733                   const CIMName& className,
734                   Array<CIMName>& superClassNames) const
735               {
736                   MetaRepository::getSuperClassNames(
737 mike  1.1.2.1         nameSpace,
738                       className,
739                       superClassNames);
740               }
741               
742               Boolean MemoryResidentRepository::isRemoteNameSpace(
743                   bool lock,
744                   const CIMNamespaceName& nameSpace,
745                   String& remoteInfo)
746               {
747                   return false;
748               }
749               
750               #ifdef PEGASUS_DEBUG
751               void MemoryResidentRepository::DisplayCacheStatistics(
752                   bool lock)
753               {
754               }
755               #endif
756               
757               Uint32 MemoryResidentRepository::_findInstance(
758 mike  1.1.2.1     const CIMNamespaceName& nameSpace,
759                   const CIMObjectPath& instanceName)
760               {
761                   for (Uint32 i = 0; i < _rep.size(); i++)
762                   {
763                       if (_rep[i].first == nameSpace &&
764                           _rep[i].second.getPath() == instanceName)
765                       {
766                           return i;
767                       }
768                   }
769               
770                   return PEG_NOT_FOUND;
771               }
772               
773 mike  1.1.2.4 void MemoryResidentRepository::installSaveCallback(
774                   void (*handler)(const Buffer& buffer, void* data),
775                   void * data)
776 mike  1.1.2.3 {
777 mike  1.1.2.4     _saveCallback = handler;
778                   _saveData = data;
779 mike  1.1.2.3 }
780               
781 mike  1.1.2.4 void MemoryResidentRepository::installLoadCallback(
782                   void (*handler)(Buffer& buffer, void* data),
783                   void * data)
784 mike  1.1.2.3 {
785 mike  1.1.2.4     _loadCallback = handler;
786                   _loadData = data;
787 mike  1.1.2.3 }
788               
789               void MemoryResidentRepository::_processSaveHandler()
790               {
791 mike  1.1.2.4     if (!_saveCallback)
792 mike  1.1.2.3         return;
793               
794                   Buffer out;
795               
796                   for (Uint32 i = 0; i < _rep.size(); i++)
797                   {
798                       SerializeNameSpace(out, _rep[i].first);
799                       SerializeInstance(out, _rep[i].second);
800                   }
801               
802 mike  1.1.2.4     (*_saveCallback)(out, _saveData);
803 mike  1.1.2.3 }
804               
805               void MemoryResidentRepository::_processLoadHandler()
806               {
807 mike  1.1.2.4     if (!_loadCallback)
808 mike  1.1.2.3         return;
809               
810                   Buffer in;
811 mike  1.1.2.4     (*_loadCallback)(in, _loadData);
812 mike  1.1.2.3     size_t pos = 0;
813               
814                   while (pos != in.size())
815                   {
816                       CIMNamespaceName nameSpace;
817               
818                       if (DeserializeNameSpace(in, pos, nameSpace) != 0)
819                           return;
820               
821                       CIMInstance cimInstance;
822               
823                       if (DeserializeInstance(in, pos, cimInstance) != 0)
824                           return;
825               
826                       _rep.append(NamespaceInstancePair(nameSpace, cimInstance));
827                   }
828               }
829               
830 mike  1.1.2.1 PEGASUS_NAMESPACE_END

No CVS admin address has been configured
Powered by
ViewCVS 0.9.2