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

Diff for /pegasus/src/Pegasus/Repository/Attic/Repository.cpp between version 1.2 and 1.6

version 1.2, 2001/01/25 02:12:05 version 1.6, 2001/02/13 07:00:18
Line 23 
Line 23 
 // Author: // Author:
 // //
 // $Log$ // $Log$
   // Revision 1.6  2001/02/13 07:00:18  mike
   // Added partial createInstance() method to repository.
   //
   // Revision 1.5  2001/02/11 05:45:33  mike
   // Added case insensitive logic for files in Repository
   //
   // Revision 1.4  2001/01/31 08:20:51  mike
   // Added dispatcher framework.
   // Added enumerateInstanceNames.
   //
   // Revision 1.3  2001/01/28 04:11:03  mike
   // fixed qualifier resolution
   //
 // Revision 1.2  2001/01/25 02:12:05  mike // Revision 1.2  2001/01/25 02:12:05  mike
 // Added meta-qualifiers to LoadRepository program. // Added meta-qualifiers to LoadRepository program.
 // //
Line 41 
Line 54 
 #include <Pegasus/Common/XmlReader.h> #include <Pegasus/Common/XmlReader.h>
 #include <Pegasus/Common/XmlWriter.h> #include <Pegasus/Common/XmlWriter.h>
 #include <Pegasus/Common/DeclContext.h> #include <Pegasus/Common/DeclContext.h>
   #include <Pegasus/Common/DeclContext.h>
 #include "Repository.h" #include "Repository.h"
   #include "InstanceIndexFile.h"
  
 #define INDENT_XML_FILES #define INDENT_XML_FILES
  
Line 85 
Line 100 
  
 Array<String> _GlobClassesDir( Array<String> _GlobClassesDir(
     const String& path,     const String& path,
     const String& className,      const String& className_,
     const String& superClassName)      const String& superClassName_)
 { {
       String className = className_;
       String superClassName = superClassName_;
     Array<String> fileNames;     Array<String> fileNames;
  
     if (!FileSystem::getDirectoryContents(path, fileNames))     if (!FileSystem::getDirectoryContents(path, fileNames))
Line 232 
Line 249 
     if (!FileSystem::isDirectory(path))     if (!FileSystem::isDirectory(path))
         throw CimException(CimException::INVALID_NAMESPACE);         throw CimException(CimException::INVALID_NAMESPACE);
  
     path.append('/');  
     path.append(QUALIFIERS);     path.append(QUALIFIERS);
     path.append(qualifierName);     path.append(qualifierName);
 } }
  
   static void _MakeInstanceIndexPath(
       const String& root,
       const String& nameSpace,
       const String& className,
       String& path)
   {
       const char INSTANCES[] = "/instances/";
       _MakeNameSpacePath(root, nameSpace, path);
   
       if (!FileSystem::isDirectory(path))
           throw CimException(CimException::INVALID_NAMESPACE);
   
       path.append(INSTANCES);
       path.append(className);
       path.append(".idx");
   }
   
   static void _MakeInstancePath(
       const String& root,
       const String& nameSpace,
       const String& className,
       Uint32 index,
       String& path)
   {
       const char INSTANCES[] = "/instances/";
       _MakeNameSpacePath(root, nameSpace, path);
   
       if (!FileSystem::isDirectory(path))
           throw CimException(CimException::INVALID_NAMESPACE);
   
       path.append(INSTANCES);
       path.append(className);
       path.append('.');
   
       char buffer[32];
       sprintf(buffer, "%d", index);
       path.append(buffer);
   }
   
 template<class Object> template<class Object>
 void _LoadObject( void _LoadObject(
     const String& path,     const String& path,
     Object& object)     Object& object)
 { {
     // Open the file:      // Get the real path of the file:
  
     Destroyer<char> destroyer(path.allocateCString());      String realPath;
     std::ifstream is(destroyer.getPointer());  
  
     if (!is)      if (!FileSystem::existsIgnoreCase(path, realPath))
         throw CannotOpenFile(path);         throw CannotOpenFile(path);
  
     // Load file into memory:     // Load file into memory:
  
     Array<Sint8> data;     Array<Sint8> data;
     FileSystem::loadFileToMemory(data, path);      FileSystem::loadFileToMemory(data, realPath);
     data.append('\0');     data.append('\0');
  
     XmlParser parser((char*)data.getData());     XmlParser parser((char*)data.getData());
Line 551 
Line 605 
     String path;     String path;
     const String& className = newClass.getClassName();     const String& className = newClass.getClassName();
     const String& superClassName = newClass.getSuperClassName();     const String& superClassName = newClass.getSuperClassName();
     _MakeNewClassPath(_root, nameSpace, className, superClassName, path);      _MakeNewClassPath(
           _root, nameSpace, className, superClassName, path);
  
     if (FileSystem::exists(path))      String realPath;
   
       if (FileSystem::existsIgnoreCase(path, realPath))
         throw CimException(CimException::ALREADY_EXISTS);         throw CimException(CimException::ALREADY_EXISTS);
       else
           realPath = path;
  
     // Validate the new class:     // Validate the new class:
  
Line 562 
Line 621 
  
     // Save the class:     // Save the class:
  
     _SaveObject(path, newClass);      _SaveObject(realPath, newClass);
 } }
  
 void Repository::createInstance( void Repository::createInstance(
     const String& nameSpace,     const String& nameSpace,
     const InstanceDecl& newInstance)      InstanceDecl& newInstance)
 { {
     throw CimException(CimException::NOT_SUPPORTED);      // Form the reference to this instance:
   
       String instanceName;
   
   #if 0
       // ATTN: fix this:
       Reference::referenceToInstanceName(
           newInstance.makeReference(), instanceName);
   #else
       instanceName = "MyClass.key1=123456";
   #endif
   
       // Get the instance-name and create an entry
   
       String indexPath;
   
       _MakeInstanceIndexPath(
           _root, nameSpace, newInstance.getClassName(), indexPath);
   
       Uint32 index;
   
       if (!InstanceIndexFile::insert(indexPath, instanceName, index))
           throw CimException(CimException::FAILED);
   
       // Save the instance to file:
   
       String path;
   
       _MakeInstancePath(
           _root, nameSpace, newInstance.getClassName(), index, path);
   
       newInstance.resolve(_context, nameSpace);
   
       std::cout << "path: " << path << std::endl;
       _SaveObject(path, newInstance);
 } }
  
 void Repository::modifyClass( void Repository::modifyClass(
Line 689 
Line 782 
     return Array<InstanceDecl>();     return Array<InstanceDecl>();
 } }
  
 Array<String> Repository::enumerateInstanceNames(  Array<Reference> Repository::enumerateInstanceNames(
     const String& nameSpace,     const String& nameSpace,
     const String& className)     const String& className)
 { {
     throw CimException(CimException::NOT_SUPPORTED);     throw CimException(CimException::NOT_SUPPORTED);
     return Array<String>();      return Array<Reference>();
 } }
  
 Array<InstanceDecl> Repository::execQuery( Array<InstanceDecl> Repository::execQuery(
Line 784 
Line 877 
  
     // If it does not exist:     // If it does not exist:
  
     if (!FileSystem::exists(path))      String realPath;
   
       if (!FileSystem::existsIgnoreCase(path, realPath))
         throw CimException(CimException::NOT_FOUND);         throw CimException(CimException::NOT_FOUND);
  
     // Load the qualifier:     // Load the qualifier:
  
     QualifierDecl qualifierDecl;     QualifierDecl qualifierDecl;
     _LoadObject(path, qualifierDecl);      _LoadObject(realPath, qualifierDecl);
   
       // Return the qualifier:
  
     return QualifierDecl(qualifierDecl);     return QualifierDecl(qualifierDecl);
 } }
Line 806 
Line 903 
  
     // If the qualifier already exists, delete it:     // If the qualifier already exists, delete it:
  
     if (FileSystem::exists(path))      String realPath;
   
       if (FileSystem::existsIgnoreCase(path, realPath))
     {     {
         if (!FileSystem::removeFile(path))          if (!FileSystem::removeFile(realPath))
             throw FailedToRemoveDirectory(path);             throw FailedToRemoveDirectory(path);
     }     }
       else
           realPath = path;
  
     // Write the qualifier to file:     // Write the qualifier to file:
  
     _SaveObject(path, qualifierDecl);      _SaveObject(realPath, qualifierDecl);
 } }
  
 void Repository::deleteQualifier( void Repository::deleteQualifier(
Line 824 
Line 925 
     String path;     String path;
     _MakeQualfierPath(_root, nameSpace, qualifierName, path);     _MakeQualfierPath(_root, nameSpace, qualifierName, path);
  
     if (!FileSystem::exists(path))      String realPath;
   
       if (!FileSystem::existsIgnoreCase(path, realPath))
         throw CimException(CimException::NOT_FOUND);         throw CimException(CimException::NOT_FOUND);
  
     if (!FileSystem::removeFile(path))      if (!FileSystem::removeFile(realPath))
         throw FailedToRemoveFile(path);         throw FailedToRemoveFile(path);
 } }
  
Line 938 
Line 1041 
     return result;     return result;
 } }
  
   // Recall flavor defaults: TOSUBCLASS | OVERRIDABLE
   
   void Repository::createMetaQualifiers(const String& nameSpace)
   {
       // Qualifier CimType : string = null,
       //     Scope(property, parameter)
   
       setQualifier(nameSpace, QualifierDecl("cimtype", String(),
           Scope::PROPERTY | Scope::REFERENCE | Scope::PARAMETER));
   
       // Qualifier id : sint32 = null,
       //     Scope(any),
       //     Flavor(toinstance)
   
       setQualifier(nameSpace, QualifierDecl("id", Sint32(0),
           Scope::ANY,
           Flavor::TOINSTANCE));
   
       // Qualifier OctetString : boolean = false, Scope(property)
   
       setQualifier(nameSpace, QualifierDecl("octetstring", false,
           Scope::PROPERTY));
   
       // Qualifier Abstract : boolean = false,
       //     Scope(class, association, indication),
       //     Flavor(disableoverride, restricted);
   
       setQualifier(nameSpace, QualifierDecl("abstract", false,
           Scope::CLASS | Scope::ASSOCIATION | Scope::INDICATION,
           Flavor::NONE));
   
       // Qualifier Aggregate : boolean = false,
       //    Scope(reference),
       //    Flavor(disableoverride, tosubclass);
   
       setQualifier(nameSpace, QualifierDecl("aggregate", false,
           Scope::REFERENCE, Flavor::TOSUBCLASS));
   
       // Qualifier Aggregation : boolean = false,
       //     Scope(association),
       //     Flavor(disableoverride, tosubclass);
   
       setQualifier(nameSpace, QualifierDecl("aggregation", false,
           Scope::ASSOCIATION, Flavor::TOSUBCLASS));
   
       // Qualifier Alias : string = null,
       //     Scope(property, reference, method),
       //     Flavor(translatable);
   
       setQualifier(nameSpace, QualifierDecl("alias", String(),
           Scope::PROPERTY | Scope::REFERENCE | Scope::METHOD,
           Flavor::DEFAULTS | Flavor::TRANSLATABLE));
   
       // Qualifier ArrayType : string = "Bag",
       //     Scope(property, parameter);
   
       setQualifier(nameSpace, QualifierDecl("arraytype", "Bag",
           Scope::PROPERTY | Scope::PARAMETER));
   
       // Qualifier Association : boolean = false,
       //     Scope(class, association),
       //     Flavor(disableoverride);
   
       setQualifier(nameSpace, QualifierDecl("association", false,
           Scope::CLASS | Scope::ASSOCIATION,
           Flavor::TOSUBCLASS));
   
       // Qualifier BitMap : string[],
       //     Scope(property, method, parameter);
   
       setQualifier(nameSpace, QualifierDecl("bitmap", Array<String>(),
           Scope::PROPERTY | Scope::METHOD | Scope::PARAMETER));
   
       // Qualifier BitValues : string[],
       //     Scope(property, method, parameter),
       //     Flavor(Translatable);
   
       setQualifier(nameSpace, QualifierDecl("bitvalues", Array<String>(),
           Scope::PROPERTY | Scope::METHOD | Scope::PARAMETER,
           Flavor::DEFAULTS | Flavor::TRANSLATABLE));
   
       // Qualifier Counter : boolean = false,
       //     Scope(property, method, parameter);
   
       setQualifier(nameSpace, QualifierDecl("counter", false,
           Scope::PROPERTY | Scope::METHOD | Scope::PARAMETER));
   
       // Qualifier Delete : boolean = false,
       //     Scope(association, reference);
   
       setQualifier(nameSpace, QualifierDecl("delete", false,
           Scope::ASSOCIATION | Scope::REFERENCE));
   
       // Qualifier Description : string = null,
       //     Scope(any),
       //     Flavor(translatable);
   
       setQualifier(nameSpace, QualifierDecl("description", String(),
           Scope::ANY,
           Flavor::TRANSLATABLE));
   
       // Qualifier DisplayName : string = null,
       //     Scope(any),
       //     Flavor(translatable);
   
       setQualifier(nameSpace, QualifierDecl("displayname", String(),
           Scope::ANY,
           Flavor::DEFAULTS | Flavor::TRANSLATABLE));
   
       // Qualifier Expensive : boolean = false,
       //     Scope(property, reference, method, class, association);
   
       setQualifier(nameSpace, QualifierDecl("expensive", false,
           Scope::PROPERTY | Scope::REFERENCE | Scope::METHOD | Scope::CLASS |
           Scope::ASSOCIATION));
   
       // Qualifier Gauge : boolean = false,
       //     Scope(property, method, parameter);
   
       setQualifier(nameSpace, QualifierDecl("gauge", false,
           Scope::PROPERTY | Scope::METHOD | Scope::PARAMETER));
   
       // Qualifier Ifdeleted : boolean = false,
       //     Scope(association, reference);
   
       setQualifier(nameSpace, QualifierDecl("ifdeleted", false,
           Scope::ASSOCIATION | Scope::REFERENCE));
   
       // Qualifier In : boolean = true,
       //     Scope(parameter),
       //     Flavor(disableoverride);
   
       setQualifier(nameSpace, QualifierDecl("in", true,
           Scope::PARAMETER,
           Flavor::TOSUBCLASS));
   
       // Qualifier Indication : boolean = false,
       //     Scope(class, indication),
       //     Flavor(disableoverride);
   
       setQualifier(nameSpace, QualifierDecl("indication", false,
           Scope::CLASS | Scope::INDICATION,
           Flavor::TOSUBCLASS));
   
       // Qualifier Invisible : boolean = false,
       //     Scope(reference, association, class, property, method);
   
       setQualifier(nameSpace, QualifierDecl("invisible", false,
           Scope::REFERENCE | Scope::ASSOCIATION | Scope::CLASS | Scope::PROPERTY |
           Scope::METHOD));
   
       // Qualifier Key : boolean = false,
       //     Scope(property, reference),
       //     Flavor(disableoverride);
   
       setQualifier(nameSpace, QualifierDecl("key", false,
           Scope::PROPERTY | Scope::REFERENCE,
           Flavor::TOSUBCLASS));
   
       // Qualifier Large : boolean = false,
       //     Scope(property, class);
   
       setQualifier(nameSpace, QualifierDecl("large", false,
           Scope::PROPERTY | Scope::CLASS));
   
       // Qualifier MappingStrings : string[],
       //     Scope(class, property, association, indication, reference);
   
       setQualifier(nameSpace, QualifierDecl("mappingstrings", Array<String>(),
           Scope::CLASS | Scope::PROPERTY | Scope::ASSOCIATION |
           Scope::INDICATION | Scope::REFERENCE));
   
       // Qualifier Max : uint32 = null, Scope(reference);
   
       setQualifier(nameSpace, QualifierDecl("max", Sint32(0),
           Scope::PROPERTY | Scope::REFERENCE));
   
       // Qualifier MaxLen : uint32 = null,
       //     Scope(property, method, parameter);
   
   #if 0
       setQualifier(nameSpace, QualifierDecl("maxlen", Uint32(0),
           Scope::PROPERTY | Scope::METHOD | Scope::PARAMETER));
   #else
       setQualifier(nameSpace, QualifierDecl("maxlen", Sint32(0),
           Scope::PROPERTY | Scope::METHOD | Scope::PARAMETER));
   #endif
   
       // Qualifier MaxValue : sint64 = null,
       //     Scope(property, method, parameter);
       // ATTN: XML schema requires sint32!
   
       setQualifier(nameSpace, QualifierDecl("maxvalue", Sint32(0),
           Scope::PROPERTY | Scope::METHOD | Scope::PARAMETER));
   
       // Qualifier Min : sint32 = null, Scope(reference);
   
       setQualifier(nameSpace, QualifierDecl("min", Sint32(0),
           Scope::REFERENCE));
   
       // Qualifier MinValue : sint64 = null,
       //     Scope(property, method, parameter);
       // ATTN: Type expected by XML spec is sint32!
   
       setQualifier(nameSpace, QualifierDecl("minvalue", Sint32(0),
           Scope::PROPERTY | Scope::METHOD | Scope::PARAMETER));
   
       // Qualifier ModelCorrespondence : string[],
       //     Scope(property);
   
       setQualifier(nameSpace, QualifierDecl("modelcorrespondence",
           Array<String>(),
           Scope::PROPERTY));
   
       // Qualifier NonLocal : string = null,
       //     Scope(reference);
   
       setQualifier(nameSpace, QualifierDecl("nonlocal", String(),
           Scope::REFERENCE));
   
       // Qualifier NullValue : string = null,
       //     Scope(property),
       //     Flavor(tosubclass, disableoverride);
   
       setQualifier(nameSpace, QualifierDecl("nullvalue", String(),
           Scope::PROPERTY,
           Flavor::TOSUBCLASS));
   
       // Qualifier Out : boolean = false,
       //     Scope(parameter),
       //     Flavor(disableoverride);
   
       setQualifier(nameSpace, QualifierDecl("out", false,
           Scope::PARAMETER,
           Flavor::TOSUBCLASS));
   
       // Qualifier Override : string = null,
       //     Scope(property, method, reference),
       //     Flavor(disableoverride);
   
       setQualifier(nameSpace, QualifierDecl("override", String(),
           Scope::PROPERTY | Scope::METHOD | Scope::REFERENCE,
           Flavor::TOSUBCLASS));
   
       // Qualifier Propagated : string = null,
       //     Scope(property, reference),
       //     Flavor(disableoverride);
   
       setQualifier(nameSpace, QualifierDecl("propagated", String(),
           Scope::PROPERTY | Scope::REFERENCE,
           Flavor::TOSUBCLASS));
   
       // Qualifier Provider : string = null,
       //     Scope(any);
   
       setQualifier(nameSpace, QualifierDecl("provider", String(),
           Scope::ANY));
   
       // Qualifier Read : boolean = true, Scope(property);
   
       setQualifier(nameSpace, QualifierDecl("read", true,
           Scope::PROPERTY));
   
       // Qualifier Required : boolean = false,
       //     Scope(property);
   
       setQualifier(nameSpace, QualifierDecl("required", false,
           Scope::PROPERTY));
   
       // Qualifier Revision : string = null,
       //     Scope(schema, class, association, indication),
       //     Flavor(translatable);
       // ATTN: No such scope as Scope::SCHEMA
   
       setQualifier(nameSpace, QualifierDecl("revision", String(),
           Scope::CLASS | Scope::ASSOCIATION | Scope::INDICATION,
           Flavor::DEFAULTS | Flavor::TRANSLATABLE));
   
       // Qualifier Schema : string = null,
       //     Scope(property, method),
       //     Flavor(disableoverride, translatable);
   
       setQualifier(nameSpace, QualifierDecl("schema", String(),
           Scope::PROPERTY | Scope::METHOD,
           Flavor::TOSUBCLASS | Flavor::TRANSLATABLE));
   
       // Qualifier Source : string = null,
       //     Scope(class, association, indication);
   
       setQualifier(nameSpace, QualifierDecl("source", String(),
           Scope::CLASS | Scope::ASSOCIATION | Scope::INDICATION));
   
       // Qualifier SourceType : string = null,
       //     Scope(class, association, indication,reference);
   
       setQualifier(nameSpace, QualifierDecl("sourcetype", String(),
           Scope::CLASS | Scope::ASSOCIATION | Scope:: INDICATION |
           Scope::REFERENCE));
   
       // Qualifier Static : boolean = false,
       //     Scope(property, method), Flavor(disableoverride);
   
       setQualifier(nameSpace, QualifierDecl("static", false,
           Scope::PROPERTY | Scope::METHOD,
           Flavor::TOSUBCLASS));
   
       // Qualifier Syntax : string = null,
       //     Scope(property, reference, method, parameter);
   
       setQualifier(nameSpace, QualifierDecl("syntax", String(),
           Scope::PROPERTY | Scope::REFERENCE | Scope::METHOD | Scope::PARAMETER));
   
       // Qualifier SyntaxType : string = null,
       //     Scope(property, reference, method, parameter);
   
       setQualifier(nameSpace, QualifierDecl("syntaxtype", String(),
           Scope::PROPERTY | Scope::REFERENCE | Scope::METHOD | Scope::PARAMETER));
   
       // Qualifier Terminal : boolean = false,
       //     Scope(class);
   
       setQualifier(nameSpace, QualifierDecl("terminal", false,
           Scope::CLASS));
   
       // Qualifier TriggerType : string = null,
       //     Scope(class, property, reference, method, association, indication);
   
       setQualifier(nameSpace, QualifierDecl("triggertype", String(),
           Scope::CLASS | Scope::PROPERTY | Scope::REFERENCE | Scope::METHOD |
           Scope::ASSOCIATION | Scope::INDICATION));
   
       // Qualifier Units : string = null,
       //     Scope(property, method, parameter),
       //     Flavor(translatable);
   
       setQualifier(nameSpace, QualifierDecl("units", String(),
           Scope::PROPERTY | Scope::METHOD | Scope::PARAMETER,
           Flavor::DEFAULTS | Flavor::TRANSLATABLE));
   
       // Qualifier UnknownValues : string[],
       //     Scope(property),
       //     Flavor(disableoverride, tosubclass);
   
       setQualifier(nameSpace, QualifierDecl("unknownvalues", Array<String>(),
           Scope::PROPERTY,
           Flavor::TOSUBCLASS));
   
       // Qualifier UnsupportedValues : string[],
       //     Scope(property),
       //     Flavor(disableoverride, tosubclass);
   
       setQualifier(nameSpace, QualifierDecl("unsupportedvalues", Array<String>(),
           Scope::PROPERTY,
           Flavor::TOSUBCLASS));
   
       // Qualifier ValueMap : string[],
       //     Scope(property, method, parameter);
   
       setQualifier(nameSpace, QualifierDecl("valuemap", Array<String>(),
           Scope::PROPERTY | Scope::METHOD | Scope::PARAMETER));
   
       // Qualifier Values : string[],
       //     Scope(property, method, parameter),
       //     Flavor(translatable);
   
       setQualifier(nameSpace, QualifierDecl("values", Array<String>(),
           Scope::PROPERTY | Scope::METHOD | Scope::PARAMETER,
           Flavor::DEFAULTS | Flavor::TRANSLATABLE));
   
       // Qualifier Version : string = null,
       //     Scope(schema, class, association, indication),
       //     Flavor(translatable);
       // ATTN: No such scope as Scope::SCHEMA
   
       setQualifier(nameSpace, QualifierDecl("version", String(),
           Scope::CLASS | Scope::ASSOCIATION | Scope::INDICATION,
           Flavor::DEFAULTS | Flavor::TRANSLATABLE));
   
       // Qualifier Weak : boolean = false,
       //     Scope(reference),
       //     Flavor(disableoverride, tosubclass);
   
       setQualifier(nameSpace, QualifierDecl("weak", false,
           Scope::REFERENCE,
           Flavor::TOSUBCLASS));
   
       // Qualifier Write : boolean = false,
       //     Scope(property);
   
       setQualifier(nameSpace, QualifierDecl("write", false,
           Scope::PROPERTY));
   }
   
 PEGASUS_NAMESPACE_END PEGASUS_NAMESPACE_END


Legend:
Removed from v.1.2  
changed lines
  Added in v.1.6

No CVS admin address has been configured
Powered by
ViewCVS 0.9.2