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

Diff for /pegasus/src/Pegasus/Repository/Attic/MemoryResidentRepository.cpp between version 1.1.2.6 and 1.1.2.7

version 1.1.2.6, 2007/11/08 15:56:25 version 1.1.2.7, 2007/11/08 23:20:50
Line 39 
Line 39 
 #include "RepositoryDeclContext.h" #include "RepositoryDeclContext.h"
 #include "Filtering.h" #include "Filtering.h"
 #include "Serialization.h" #include "Serialization.h"
 #include "MetaTypes.h"  #include "SchemaTypes.h"
  
 PEGASUS_NAMESPACE_BEGIN PEGASUS_NAMESPACE_BEGIN
  
 typedef const MetaClass* ConstMetaClassPtr;  typedef const SchemaClass* ConstSchemaClassPtr;
 #define PEGASUS_ARRAY_T ConstMetaClassPtr  #define PEGASUS_ARRAY_T ConstSchemaClassPtr
 # include <Pegasus/Common/ArrayInter.h> # include <Pegasus/Common/ArrayInter.h>
 # include <Pegasus/Common/ArrayImpl.h> # include <Pegasus/Common/ArrayImpl.h>
 #undef PEGASUS_ARRAY_T #undef PEGASUS_ARRAY_T
Line 60 
Line 60 
 //============================================================================== //==============================================================================
  
 static size_t const _MAX_NAMESPACE_TABLE_SIZE = 64; static size_t const _MAX_NAMESPACE_TABLE_SIZE = 64;
 static const MetaNameSpace* _nameSpaceTable[_MAX_NAMESPACE_TABLE_SIZE];  static const SchemaNameSpace* _nameSpaceTable[_MAX_NAMESPACE_TABLE_SIZE];
 static size_t _nameSpaceTableSize = 0; static size_t _nameSpaceTableSize = 0;
  
 static const size_t _MAX_FEATURES = 128; static const size_t _MAX_FEATURES = 128;
Line 119 
Line 119 
 } }
  
 static void _applyModifiedInstance( static void _applyModifiedInstance(
     const MetaClass* mc,      const SchemaClass* mc,
     const CIMInstance& modifiedInstance_,     const CIMInstance& modifiedInstance_,
     const CIMPropertyList& propertyList,     const CIMPropertyList& propertyList,
     CIMInstance& resultInstance)     CIMInstance& resultInstance)
Line 135 
Line 135 
         {         {
             // Reject attempts to add properties not in class:             // Reject attempts to add properties not in class:
  
             const MetaFeature* mf = FindFeature(              const SchemaFeature* mf = FindFeature(mc,
                 mc, *Str(cp.getName()), META_FLAG_PROPERTY|META_FLAG_REFERENCE);                  *Str(cp.getName()), SCHEMA_FLAG_PROPERTY|SCHEMA_FLAG_REFERENCE);
  
             if (!mf)             if (!mf)
             {             {
Line 147 
Line 147 
  
             // Reject attempts to modify key properties:             // Reject attempts to modify key properties:
  
             if (mf->flags & META_FLAG_KEY)              if (mf->flags & SCHEMA_FLAG_KEY)
             {             {
                 Throw((CIM_ERR_FAILED,                 Throw((CIM_ERR_FAILED,
                     "modifyInstance() failed to modify key property: %s",                     "modifyInstance() failed to modify key property: %s",
Line 191 
Line 191 
     return System::strcasecmp(s1, s2) == 0;     return System::strcasecmp(s1, s2) == 0;
 } }
  
 static const MetaNameSpace* _findNameSpace(const char* name)  static const SchemaNameSpace* _findNameSpace(const char* name)
 { {
     for (size_t i = 0; i < _nameSpaceTableSize; i++)     for (size_t i = 0; i < _nameSpaceTableSize; i++)
     {     {
         const MetaNameSpace* ns = _nameSpaceTable[i];          const SchemaNameSpace* ns = _nameSpaceTable[i];
  
         if (_eqi(ns->name, name))         if (_eqi(ns->name, name))
             return ns;             return ns;
Line 205 
Line 205 
     return 0;     return 0;
 } }
  
 static bool _isSubClass(const MetaClass* super, const MetaClass* sub)  static bool _isSubClass(const SchemaClass* super, const SchemaClass* sub)
 { {
     if (!super)     if (!super)
         return true;         return true;
  
     for (MetaClass* p = sub->super; p; p = p->super)      for (SchemaClass* p = sub->super; p; p = p->super)
     {     {
         if (p == super)         if (p == super)
             return true;             return true;
Line 220 
Line 220 
 } }
  
 static inline bool _isDirectSubClass( static inline bool _isDirectSubClass(
     const MetaClass* super,      const SchemaClass* super,
     const MetaClass* sub)      const SchemaClass* sub)
 { {
     return sub->super == super;     return sub->super == super;
 } }
Line 264 
Line 264 
         printf("pl[%s]\n", pl[i]);         printf("pl[%s]\n", pl[i]);
 } }
  
 static bool _contains(const Array<const MetaClass*>& x, const MetaClass* mc)  static bool _contains(const Array<const SchemaClass*>& x, const SchemaClass* mc)
 { {
     Uint32 n = x.size();     Uint32 n = x.size();
     const MetaClass* const* p = x.getData();      const SchemaClass* const* p = x.getData();
  
     while (n--)     while (n--)
     {     {
Line 279 
Line 279 
 } }
  
 static void _associators( static void _associators(
     const MetaNameSpace* ns,      const SchemaNameSpace* ns,
     const CIMName& className,     const CIMName& className,
     const CIMName& assocClass,     const CIMName& assocClass,
     const CIMName& resultClass,     const CIMName& resultClass,
     const String& role,     const String& role,
     const String& resultRole,     const String& resultRole,
     Array<const MetaClass*>& result)      Array<const SchemaClass*>& result)
 { {
     // Lookup source class:     // Lookup source class:
  
     const MetaClass* mc = FindClass(ns, *Str(className));      const SchemaClass* mc = FindClass(ns, *Str(className));
  
     if (!mc)     if (!mc)
         Throw((CIM_ERR_NOT_FOUND, "unknown class: %s", *Str(className)));         Throw((CIM_ERR_NOT_FOUND, "unknown class: %s", *Str(className)));
Line 297 
Line 297 
  
     // Lookup result class (if any).     // Lookup result class (if any).
  
     const MetaClass* rmc = 0;      const SchemaClass* rmc = 0;
  
     if (!resultClass.isNull())     if (!resultClass.isNull())
     {     {
Line 317 
Line 317 
  
     for (size_t i = 0; ns->classes[i]; i++)     for (size_t i = 0; ns->classes[i]; i++)
     {     {
         MetaClass* amc = ns->classes[i];          SchemaClass* amc = ns->classes[i];
  
         // Skip non-association classes:         // Skip non-association classes:
  
         if (!(amc->flags & META_FLAG_ASSOCIATION))          if (!(amc->flags & SCHEMA_FLAG_ASSOCIATION))
             continue;             continue;
  
         // Filter by assocClass parameter:         // Filter by assocClass parameter:
Line 331 
Line 331 
  
         // Process reference properties:         // Process reference properties:
  
         MetaFeatureInfo features[META_MAX_FEATURES];          SchemaFeatureInfo features[SCHEMA_MAX_FEATURES];
         size_t size = 0;         size_t size = 0;
         MergeFeatures(amc, false, META_FLAG_REFERENCE, features, size);          MergeFeatures(amc, false, SCHEMA_FLAG_REFERENCE, features, size);
  
         for (size_t j = 0; j < size; j++)         for (size_t j = 0; j < size; j++)
         {         {
             const MetaFeature* mf = features[j].mf;              const SchemaFeature* mf = features[j].mf;
  
             // Skip non references:             // Skip non references:
  
             if (!(mf->flags & META_FLAG_REFERENCE))              if (!(mf->flags & SCHEMA_FLAG_REFERENCE))
                 continue;                 continue;
  
             const MetaReference* mr = (const MetaReference*)mf;              const SchemaReference* mr = (const SchemaReference*)mf;
  
             // Filter by role parameter.             // Filter by role parameter.
  
Line 360 
Line 360 
  
             for (size_t k = 0; k < size; k++)             for (size_t k = 0; k < size; k++)
             {             {
                 const MetaFeature* rmf = features[k].mf;                  const SchemaFeature* rmf = features[k].mf;
  
                 // Skip the feature under consideration:                 // Skip the feature under consideration:
  
Line 369 
Line 369 
  
                 // Skip non references:                 // Skip non references:
  
                 if (!(rmf->flags & META_FLAG_REFERENCE))                  if (!(rmf->flags & SCHEMA_FLAG_REFERENCE))
                     continue;                     continue;
  
                 const MetaReference* rmr = (const MetaReference*)rmf;                  const SchemaReference* rmr = (const SchemaReference*)rmf;
  
                 // Filter by resultRole parameter.                 // Filter by resultRole parameter.
  
Line 397 
Line 397 
 } }
  
 static void _references( static void _references(
     const MetaNameSpace* ns,      const SchemaNameSpace* ns,
     const CIMName& className,     const CIMName& className,
     const CIMName& resultClass,     const CIMName& resultClass,
     const String& role,     const String& role,
     Array<const MetaClass*>& result)      Array<const SchemaClass*>& result)
 { {
     // Lookup source class:     // Lookup source class:
  
     const MetaClass* mc = FindClass(ns, *Str(className));      const SchemaClass* mc = FindClass(ns, *Str(className));
  
     if (!mc)     if (!mc)
         Throw((CIM_ERR_NOT_FOUND, "unknown class: %s", *Str(className)));         Throw((CIM_ERR_NOT_FOUND, "unknown class: %s", *Str(className)));
  
     // Lookup result class (if any).     // Lookup result class (if any).
  
     const MetaClass* rmc = 0;      const SchemaClass* rmc = 0;
  
     if (!resultClass.isNull())     if (!resultClass.isNull())
     {     {
Line 430 
Line 430 
  
     for (size_t i = 0; ns->classes[i]; i++)     for (size_t i = 0; ns->classes[i]; i++)
     {     {
         MetaClass* amc = ns->classes[i];          SchemaClass* amc = ns->classes[i];
  
         // Skip non-association classes:         // Skip non-association classes:
  
         if (!(amc->flags & META_FLAG_ASSOCIATION))          if (!(amc->flags & SCHEMA_FLAG_ASSOCIATION))
             continue;             continue;
  
         // Filter by result class:         // Filter by result class:
Line 444 
Line 444 
  
         // Process reference properties:         // Process reference properties:
  
         MetaFeatureInfo features[META_MAX_FEATURES];          SchemaFeatureInfo features[SCHEMA_MAX_FEATURES];
         size_t size = 0;         size_t size = 0;
         MergeFeatures(amc, false, META_FLAG_REFERENCE, features, size);          MergeFeatures(amc, false, SCHEMA_FLAG_REFERENCE, features, size);
  
         for (size_t j = 0; j < size; j++)         for (size_t j = 0; j < size; j++)
         {         {
             const MetaFeature* mf = features[j].mf;              const SchemaFeature* mf = features[j].mf;
  
             // Skip non references:             // Skip non references:
  
             if (!(mf->flags & META_FLAG_REFERENCE))              if (!(mf->flags & SCHEMA_FLAG_REFERENCE))
                 continue;                 continue;
  
             const MetaReference* mr = (const MetaReference*)mf;              const SchemaReference* mr = (const SchemaReference*)mf;
  
             // Filter by role parameter.             // Filter by role parameter.
  
Line 472 
Line 472 
             // Add this one to the output:             // Add this one to the output:
  
             if (!_contains(result, amc))             if (!_contains(result, amc))
                 result.append((MetaClass*)amc);                  result.append((SchemaClass*)amc);
         }         }
     }     }
 } }
  
 static const MetaClass* _findMetaClass(  static const SchemaClass* _findSchemaClass(
     const char* nameSpace,     const char* nameSpace,
     const char* className)     const char* className)
 { {
     // Lookup namespace:     // Lookup namespace:
  
     const MetaNameSpace* ns = _findNameSpace(nameSpace);      const SchemaNameSpace* ns = _findNameSpace(nameSpace);
  
     if (!ns)     if (!ns)
         return 0;         return 0;
Line 498 
Line 498 
 { {
     // Lookup namespace:     // Lookup namespace:
  
     const MetaNameSpace* ns = _findNameSpace(*Str(nameSpace));      const SchemaNameSpace* ns = _findNameSpace(*Str(nameSpace));
  
     if (!ns)     if (!ns)
         Throw((CIM_ERR_INVALID_NAMESPACE, "%s", *Str(nameSpace)));         Throw((CIM_ERR_INVALID_NAMESPACE, "%s", *Str(nameSpace)));
  
     // Lookup class:     // Lookup class:
  
     const MetaClass* super = 0;      const SchemaClass* super = 0;
  
     if (!className.isNull())     if (!className.isNull())
     {     {
Line 521 
Line 521 
  
     for (size_t i = 0; ns->classes[i]; i++)     for (size_t i = 0; ns->classes[i]; i++)
     {     {
         MetaClass* mc = ns->classes[i];          SchemaClass* mc = ns->classes[i];
  
         if (deepInheritance)         if (deepInheritance)
         {         {
Line 561 
Line 561 
 { {
     // Lookup namespace:     // Lookup namespace:
  
     const MetaNameSpace* ns = _findNameSpace(*Str(nameSpace));      const SchemaNameSpace* ns = _findNameSpace(*Str(nameSpace));
  
     if (!ns)     if (!ns)
         Throw((CIM_ERR_INVALID_NAMESPACE, "%s", *Str(nameSpace)));         Throw((CIM_ERR_INVALID_NAMESPACE, "%s", *Str(nameSpace)));
  
     // Get associator meta-classes:      // Get associator schema-classes:
  
     Array<const MetaClass*> mcs;      Array<const SchemaClass*> mcs;
     _associators(ns, className, assocClass, resultClass, role, resultRole, mcs);     _associators(ns, className, assocClass, resultClass, role, resultRole, mcs);
  
     // Convert meta-classes to classes.      // Convert schema-classes to classes.
  
     Array<CIMObject> result;     Array<CIMObject> result;
  
Line 579 
Line 579 
  
     for (Uint32 i = 0; i < mcs.size(); i++)     for (Uint32 i = 0; i < mcs.size(); i++)
     {     {
         const MetaClass* mc = mcs[i];          const SchemaClass* mc = mcs[i];
         CIMClass cc;         CIMClass cc;
  
         if (MakeClass(_getHostName(), ns, mc, false, includeQualifiers,         if (MakeClass(_getHostName(), ns, mc, false, includeQualifiers,
Line 606 
Line 606 
 { {
     // Lookup namespace:     // Lookup namespace:
  
     const MetaNameSpace* ns = _findNameSpace(*Str(nameSpace));      const SchemaNameSpace* ns = _findNameSpace(*Str(nameSpace));
  
     if (!ns)     if (!ns)
         Throw((CIM_ERR_INVALID_NAMESPACE, "%s", *Str(nameSpace)));         Throw((CIM_ERR_INVALID_NAMESPACE, "%s", *Str(nameSpace)));
  
     // Get associator meta-classes:      // Get associator schema-classes:
  
     Array<const MetaClass*> mcs;      Array<const SchemaClass*> mcs;
     _associators(ns, className, assocClass, resultClass, role, resultRole, mcs);     _associators(ns, className, assocClass, resultClass, role, resultRole, mcs);
  
     // Convert meta-classes to object names:      // Convert schema-classes to object names:
  
     Array<CIMObjectPath> result;     Array<CIMObjectPath> result;
  
Line 637 
Line 637 
 { {
     // Lookup namespace:     // Lookup namespace:
  
     const MetaNameSpace* ns = _findNameSpace(*Str(nameSpace));      const SchemaNameSpace* ns = _findNameSpace(*Str(nameSpace));
  
     if (!ns)     if (!ns)
         Throw((CIM_ERR_INVALID_NAMESPACE, "%s", *Str(nameSpace)));         Throw((CIM_ERR_INVALID_NAMESPACE, "%s", *Str(nameSpace)));
  
     // Get reference meta-classes:      // Get reference schema-classes:
  
     Array<const MetaClass*> mcs;      Array<const SchemaClass*> mcs;
     _references(ns, className, resultClass, role, mcs);     _references(ns, className, resultClass, role, mcs);
  
     // Convert meta-classes to classes.      // Convert schema-classes to classes.
  
     Array<CIMObject> result;     Array<CIMObject> result;
  
Line 655 
Line 655 
  
     for (Uint32 i = 0; i < mcs.size(); i++)     for (Uint32 i = 0; i < mcs.size(); i++)
     {     {
         const MetaClass* mc = mcs[i];          const SchemaClass* mc = mcs[i];
         CIMClass cc;         CIMClass cc;
  
         if (MakeClass(_getHostName(), ns, mc, false, includeQualifiers,         if (MakeClass(_getHostName(), ns, mc, false, includeQualifiers,
Line 680 
Line 680 
 { {
     // Lookup namespace:     // Lookup namespace:
  
     const MetaNameSpace* ns = _findNameSpace(*Str(nameSpace));      const SchemaNameSpace* ns = _findNameSpace(*Str(nameSpace));
  
     if (!ns)     if (!ns)
         Throw((CIM_ERR_INVALID_NAMESPACE, "%s", *Str(nameSpace)));         Throw((CIM_ERR_INVALID_NAMESPACE, "%s", *Str(nameSpace)));
  
     // Get reference meta-classes:      // Get reference schema-classes:
  
     Array<const MetaClass*> mcs;      Array<const SchemaClass*> mcs;
     _references(ns, className, resultClass, role, mcs);     _references(ns, className, resultClass, role, mcs);
  
     // Convert meta-classes to object paths.      // Convert schema-classes to object paths.
  
     Array<CIMObjectPath> result;     Array<CIMObjectPath> result;
  
Line 706 
Line 706 
 { {
     // Lookup namespace:     // Lookup namespace:
  
     const MetaNameSpace* ns = _findNameSpace(*Str(nameSpace));      const SchemaNameSpace* ns = _findNameSpace(*Str(nameSpace));
  
     if (!ns)     if (!ns)
         Throw((CIM_ERR_INVALID_NAMESPACE, "%s", *Str(nameSpace)));         Throw((CIM_ERR_INVALID_NAMESPACE, "%s", *Str(nameSpace)));
  
     // Lookup qualifier:     // Lookup qualifier:
  
     const MetaQualifierDecl* mqd = FindQualifierDecl(ns, *Str(qualifierName));      const SchemaQualifierDecl* mqd = FindQualifierDecl(ns, *Str(qualifierName));
  
     if (!mqd)     if (!mqd)
         Throw((CIM_ERR_NOT_FOUND,         Throw((CIM_ERR_NOT_FOUND,
Line 736 
Line 736 
 { {
     // Lookup namespace:     // Lookup namespace:
  
     const MetaNameSpace* ns = _findNameSpace(*Str(nameSpace));      const SchemaNameSpace* ns = _findNameSpace(*Str(nameSpace));
  
     if (!ns)     if (!ns)
         Throw((CIM_ERR_INVALID_NAMESPACE, "%s", *Str(nameSpace)));         Throw((CIM_ERR_INVALID_NAMESPACE, "%s", *Str(nameSpace)));
Line 747 
Line 747 
  
     for (size_t i = 0; ns->qualifiers[i]; i++)     for (size_t i = 0; ns->qualifiers[i]; i++)
     {     {
         const MetaQualifierDecl* mqd = ns->qualifiers[i];          const SchemaQualifierDecl* mqd = ns->qualifiers[i];
         CIMQualifierDecl cqd;         CIMQualifierDecl cqd;
  
         if (MakeQualifierDecl(ns, mqd, cqd) != 0)         if (MakeQualifierDecl(ns, mqd, cqd) != 0)
Line 768 
Line 768 
  
     for (size_t i = 0; i < _nameSpaceTableSize; i++)     for (size_t i = 0; i < _nameSpaceTableSize; i++)
     {     {
         const MetaNameSpace* ns = _nameSpaceTable[i];          const SchemaNameSpace* ns = _nameSpaceTable[i];
         result.append(ns->name);         result.append(ns->name);
     }     }
  
Line 784 
Line 784 
  
     // Lookup namespace:     // Lookup namespace:
  
     const MetaNameSpace* ns = _findNameSpace(*Str(nameSpace));      const SchemaNameSpace* ns = _findNameSpace(*Str(nameSpace));
  
     if (!ns)     if (!ns)
         Throw((CIM_ERR_INVALID_NAMESPACE, "%s", *Str(nameSpace)));         Throw((CIM_ERR_INVALID_NAMESPACE, "%s", *Str(nameSpace)));
  
     // Lookup class:     // Lookup class:
  
     const MetaClass* mc = FindClass(ns, *Str(className));      const SchemaClass* mc = FindClass(ns, *Str(className));
  
     if (!mc)     if (!mc)
         Throw((CIM_ERR_NOT_FOUND, "unknown class: %s", *Str(className)));         Throw((CIM_ERR_NOT_FOUND, "unknown class: %s", *Str(className)));
  
     // Append superclass names:     // Append superclass names:
  
     for (const MetaClass* p = mc->super; p; p = p->super)      for (const SchemaClass* p = mc->super; p; p = p->super)
         superClassNames.append(p->name);         superClassNames.append(p->name);
 } }
  
Line 813 
Line 813 
 static void (*_loadCallback)(Buffer& buffer, void* data); static void (*_loadCallback)(Buffer& buffer, void* data);
 static void* _loadData; static void* _loadData;
  
 MemoryResidentRepository::MemoryResidentRepository(  MemoryResidentRepository::MemoryResidentRepository()
     const String& repositoryRoot,  
     Uint32 repositoryMode)  
     :  
     Repository(repositoryRoot, repositoryMode)  
 { {
     // Load users data if any:     // Load users data if any:
     _processLoadHandler();     _processLoadHandler();
Line 838 
Line 834 
 { {
     // Lookup namespace:     // Lookup namespace:
  
     const MetaNameSpace* ns = _findNameSpace(*Str(nameSpace));      const SchemaNameSpace* ns = _findNameSpace(*Str(nameSpace));
  
     if (!ns)     if (!ns)
         Throw((CIM_ERR_INVALID_NAMESPACE, "%s", *Str(nameSpace)));         Throw((CIM_ERR_INVALID_NAMESPACE, "%s", *Str(nameSpace)));
  
     // Lookup class:     // Lookup class:
  
     const MetaClass* mc = FindClass(ns, *Str(className));      const SchemaClass* mc = FindClass(ns, *Str(className));
  
     if (!mc)     if (!mc)
     {     {
Line 977 
Line 973 
     const CIMObjectPath& cop = modifiedInstance.getPath();     const CIMObjectPath& cop = modifiedInstance.getPath();
     CIMName className = cop.getClassName();     CIMName className = cop.getClassName();
  
     // Get the meta class for this instance.      // Get the schema-class for this instance.
  
     const MetaClass* mc = _findMetaClass(*Str(nameSpace), *Str(className));      const SchemaClass* mc = _findSchemaClass(*Str(nameSpace), *Str(className));
  
     if (!mc)     if (!mc)
     {     {
Line 1028 
Line 1024 
 { {
     // Lookup namespace:     // Lookup namespace:
  
     const MetaNameSpace* ns = _findNameSpace(*Str(nameSpace));      const SchemaNameSpace* ns = _findNameSpace(*Str(nameSpace));
  
     if (!ns)     if (!ns)
         Throw((CIM_ERR_INVALID_NAMESPACE, "%s", *Str(nameSpace)));         Throw((CIM_ERR_INVALID_NAMESPACE, "%s", *Str(nameSpace)));
  
     // Lookup class:     // Lookup class:
  
     const MetaClass* super = 0;      const SchemaClass* super = 0;
  
     if (!className.isNull())     if (!className.isNull())
     {     {
Line 1051 
Line 1047 
  
     for (size_t i = 0; ns->classes[i]; i++)     for (size_t i = 0; ns->classes[i]; i++)
     {     {
         MetaClass* mc = ns->classes[i];          SchemaClass* mc = ns->classes[i];
  
         bool flag = false;         bool flag = false;
  
Line 1545 
Line 1541 
     }     }
 } }
  
 Boolean MemoryResidentRepository::addNameSpace(const MetaNameSpace* nameSpace)  Boolean MemoryResidentRepository::addNameSpace(const SchemaNameSpace* nameSpace)
 { {
     if (!nameSpace)     if (!nameSpace)
         return false;         return false;


Legend:
Removed from v.1.1.2.6  
changed lines
  Added in v.1.1.2.7

No CVS admin address has been configured
Powered by
ViewCVS 0.9.2