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

Diff for /pegasus/src/Pegasus/Repository/InheritanceTree.h between version 1.2 and 1.3

version 1.2, 2001/04/27 02:09:03 version 1.3, 2001/04/27 03:22:37
Line 30 
Line 30 
  
 #include <iostream> #include <iostream>
 #include <Pegasus/Common/Config.h> #include <Pegasus/Common/Config.h>
 #include <Pegasus/Common/HashTable.h>  
 #include <Pegasus/Common/String.h> #include <Pegasus/Common/String.h>
 #include <Pegasus/Common/HashTable.h>  
  
 PEGASUS_NAMESPACE_BEGIN PEGASUS_NAMESPACE_BEGIN
  
   struct InheritanceTreeRep;
   
 /** The InheritanceTree class tracks inheritance relationships of CIM classes. /** The InheritanceTree class tracks inheritance relationships of CIM classes.
  
     This class is a memory resident version of the repository's persistent     This class is a memory resident version of the repository's persistent
Line 47 
Line 47 
 { {
 public: public:
  
     InheritanceTree()      InheritanceTree();
     {  
   
     }  
   
     Boolean insert(const String& className, const String& superClassName)  
     {  
         // ATTN: need found flag!  
   
         // -- Insert superclass:  
  
         Node* superClassNode = 0;      ~InheritanceTree();
   
         if (superClassName.getLength() &&  
             !_table.lookup(superClassName, superClassNode))  
         {  
             superClassNode = new Node(superClassName);  
             _table.insert(superClassName, superClassNode);  
         }  
  
         // -- Insert class:      Boolean insert(const String& className, const String& superClassName);
  
         Node* classNode = 0;      void print(std::ostream& os) const;
   
         if (!_table.lookup(className, classNode))  
         {  
             classNode = new Node(className);  
             _table.insert(className, classNode);  
         }  
   
         // -- Link the class and superclass nodes:  
   
         if (superClassNode)  
             superClassNode->addSubClass(classNode);  
   
         return true;  
     }  
   
     void print() const  
     {  
         for (Table::Iterator i = _table.start(); i; i++)  
             i.value()->print();  
     }  
  
 private: private:
  
     struct Node      InheritanceTreeRep* _rep;
     {  
         Node(const String& className) : _className(className), _superClass(0),  
             _sibling(0), _subClasses(0)  
         {  
   
         }  
   
         void addSubClass(Node* child)  
         {  
             child->_superClass = this;  
             child->_sibling = _subClasses;  
             _subClasses = child;  
         }  
   
         String _className;  
         Node* _superClass;  
         Node* _sibling;  
         Node* _subClasses;  
   
         void print() const  
         {  
             std::cout << "*** ClassName: " << _className << std::endl;  
   
             std::cout << "Subclasses: ";  
   
             for (Node* p = _subClasses; p; p = p->_sibling)  
                 std::cout << p->_className << ' ';  
             std::cout << std::endl;  
   
             std::cout << "Superclass: ";  
   
             if (_superClass)  
                 std::cout << _superClass->_className;  
             else  
                 std::cout << "#";  
   
             std::cout << std::endl;  
         }  
     };  
   
     typedef HashTable<String, Node*> Table;  
     Table _table;  
 }; };
  
 PEGASUS_NAMESPACE_END PEGASUS_NAMESPACE_END


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

No CVS admin address has been configured
Powered by
ViewCVS 0.9.2