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

Diff for /pegasus/src/Pegasus/Common/CIMClassRep.cpp between version 1.1 and 1.7

version 1.1, 2001/02/18 18:39:05 version 1.7, 2001/04/29 18:57:33
Line 1 
Line 1 
 //BEGIN_LICENSE  //%/////////////////////////////////////////////////////////////////////////////
 // //
 // Copyright (c) 2000 The Open Group, BMC Software, Tivoli Systems, IBM // Copyright (c) 2000 The Open Group, BMC Software, Tivoli Systems, IBM
 // //
Line 17 
Line 17 
 // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
 // DEALINGS IN THE SOFTWARE. // DEALINGS IN THE SOFTWARE.
 // //
 //END_LICENSE  //==============================================================================
 //BEGIN_HISTORY  
 // //
 // Author:  // Author: Mike Brasher (mbrasher@bmc.com)
 // //
 // $Log$  // Modified By:
 // Revision 1.1  2001/02/18 18:39:05  mike  
 // new  
 // //
 // Revision 1.2  2001/02/18 03:56:00  mike  //%/////////////////////////////////////////////////////////////////////////////
 // Changed more class names (e.g., ConstClassDecl -> CIMConstClass)  
 //  
 // Revision 1.1  2001/02/16 02:06:06  mike  
 // Renamed many classes and headers.  
 //  
 // Revision 1.6  2001/01/28 04:11:03  mike  
 // fixed qualifier resolution  
 //  
 // Revision 1.5  2001/01/26 23:26:53  mike  
 // reworked CGI inteface  
 //  
 // Revision 1.4  2001/01/25 02:12:05  mike  
 // Added meta-qualifiers to LoadRepository program.  
 //  
 // Revision 1.3  2001/01/23 01:25:34  mike  
 // Reworked resolve scheme.  
 //  
 // Revision 1.2  2001/01/15 04:31:43  mike  
 // worked on resolve scheme  
 //  
 // Revision 1.1.1.1  2001/01/14 19:50:39  mike  
 // Pegasus import  
 //  
 //  
 //END_HISTORY  
  
 #include "CIMClass.h" #include "CIMClass.h"
 #include "DeclContext.h" #include "DeclContext.h"
Line 70 
Line 42 
     if (!CIMName::legal(className))     if (!CIMName::legal(className))
         throw IllegalName();         throw IllegalName();
  
     if (superClassName.getLength() && !CIMName::legal(superClassName))      if (superClassName.size() && !CIMName::legal(superClassName))
         throw IllegalName();         throw IllegalName();
 } }
  
Line 140 
Line 112 
     // Set the class origin:     // Set the class origin:
     // ATTN: put this check in other places:     // ATTN: put this check in other places:
  
     if (x.getClassOrigin().getLength() == 0)      if (x.getClassOrigin().size() == 0)
         CIMProperty(x).setClassOrigin(_className);         CIMProperty(x).setClassOrigin(_className);
  
     // Add the property:     // Add the property:
Line 150 
Line 122 
  
 void CIMClassRep::removeProperty(Uint32 pos) void CIMClassRep::removeProperty(Uint32 pos)
 { {
     if (pos >= _properties.getSize())      if (pos >= _properties.size())
         throw OutOfBounds();         throw OutOfBounds();
 } }
  
 Uint32 CIMClassRep::findProperty(const String& name) Uint32 CIMClassRep::findProperty(const String& name)
 { {
     for (Uint32 i = 0, n = _properties.getSize(); i < n; i++)      for (Uint32 i = 0, n = _properties.size(); i < n; i++)
     {     {
         if (CIMName::equal(_properties[i].getName(), name))         if (CIMName::equal(_properties[i].getName(), name))
             return i;             return i;
Line 167 
Line 139 
  
 CIMProperty CIMClassRep::getProperty(Uint32 pos) CIMProperty CIMClassRep::getProperty(Uint32 pos)
 { {
     if (pos >= _properties.getSize())      if (pos >= _properties.size())
         throw OutOfBounds();         throw OutOfBounds();
  
     return _properties[pos];     return _properties[pos];
Line 175 
Line 147 
  
 Uint32 CIMClassRep::getPropertyCount() const Uint32 CIMClassRep::getPropertyCount() const
 { {
     return _properties.getSize();      return _properties.size();
 } }
  
 void CIMClassRep::addMethod(const CIMMethod& x) void CIMClassRep::addMethod(const CIMMethod& x)
Line 195 
Line 167 
  
 Uint32 CIMClassRep::findMethod(const String& name) Uint32 CIMClassRep::findMethod(const String& name)
 { {
     for (Uint32 i = 0, n = _methods.getSize(); i < n; i++)      for (Uint32 i = 0, n = _methods.size(); i < n; i++)
     {     {
         if (CIMName::equal(_methods[i].getName(), name))         if (CIMName::equal(_methods[i].getName(), name))
             return i;             return i;
Line 206 
Line 178 
  
 CIMMethod CIMClassRep::getMethod(Uint32 pos) CIMMethod CIMClassRep::getMethod(Uint32 pos)
 { {
     if (pos >= _methods.getSize())      if (pos >= _methods.size())
         throw OutOfBounds();         throw OutOfBounds();
  
     return _methods[pos];     return _methods[pos];
Line 214 
Line 186 
  
 Uint32 CIMClassRep::getMethodCount() const Uint32 CIMClassRep::getMethodCount() const
 { {
     return _methods.getSize();      return _methods.size();
 } }
  
 void CIMClassRep::resolve( void CIMClassRep::resolve(
Line 229 
Line 201 
     if (!context)     if (!context)
         throw NullPointer();         throw NullPointer();
  
     if (_superClassName.getLength())      if (_superClassName.size())
     {     {
         //----------------------------------------------------------------------         //----------------------------------------------------------------------
         // First check to see if the super-class really exists:         // First check to see if the super-class really exists:
         //----------------------------------------------------------------------         //----------------------------------------------------------------------
  
         CIMConstClass superClass         CIMConstClass superClass
             = context->lookupClassDecl(nameSpace, _superClassName);              = context->lookupClass(nameSpace, _superClassName);
  
         if (!superClass)         if (!superClass)
             throw NoSuchSuperClass(_superClassName);             throw NoSuchSuperClass(_superClassName);
Line 251 
Line 223 
         // set the class-origin:         // set the class-origin:
         //----------------------------------------------------------------------         //----------------------------------------------------------------------
  
         for (Uint32 i = 0, n = _properties.getSize(); i < n; i++)          for (Uint32 i = 0, n = _properties.size(); i < n; i++)
         {         {
             CIMProperty& property = _properties[i];             CIMProperty& property = _properties[i];
             Uint32 pos = superClass.findProperty(property.getName());             Uint32 pos = superClass.findProperty(property.getName());
Line 284 
Line 256 
  
             Uint32 pos = Uint32(-1);             Uint32 pos = Uint32(-1);
  
             for (Uint32 j = m, n = _properties.getSize(); j < n; j++)              for (Uint32 j = m, n = _properties.size(); j < n; j++)
             {             {
                 if (CIMName::equal(                 if (CIMName::equal(
                     _properties[j].getName(),                     _properties[j].getName(),
Line 312 
Line 284 
         // set the class-origin:         // set the class-origin:
         //----------------------------------------------------------------------         //----------------------------------------------------------------------
  
         for (Uint32 i = 0, n = _methods.getSize(); i < n; i++)          for (Uint32 i = 0, n = _methods.size(); i < n; i++)
         {         {
             CIMMethod& method = _methods[i];             CIMMethod& method = _methods[i];
             Uint32 pos = superClass.findMethod(method.getName());             Uint32 pos = superClass.findMethod(method.getName());
Line 343 
Line 315 
  
             Uint32 pos = Uint32(-1);             Uint32 pos = Uint32(-1);
  
             for (Uint32 j = m, n = _methods.getSize(); j < n; j++)              for (Uint32 j = m, n = _methods.size(); j < n; j++)
             {             {
                 if (CIMName::equal(                 if (CIMName::equal(
                     _methods[j].getName(),                     _methods[j].getName(),
Line 383 
Line 355 
         // Resolve each property:         // Resolve each property:
         //----------------------------------------------------------------------         //----------------------------------------------------------------------
  
         for (Uint32 i = 0, n = _properties.getSize(); i < n; i++)          for (Uint32 i = 0, n = _properties.size(); i < n; i++)
             _properties[i].resolve(context, nameSpace, false);             _properties[i].resolve(context, nameSpace, false);
  
         //----------------------------------------------------------------------         //----------------------------------------------------------------------
         // Resolve each method:         // Resolve each method:
         //----------------------------------------------------------------------         //----------------------------------------------------------------------
  
         for (Uint32 i = 0, n = _methods.getSize(); i < n; i++)          for (Uint32 i = 0, n = _methods.size(); i < n; i++)
             _methods[i].resolve(context, nameSpace);             _methods[i].resolve(context, nameSpace);
  
         //----------------------------------------------------------------------         //----------------------------------------------------------------------
Line 417 
Line 389 
     out << "<CLASS ";     out << "<CLASS ";
     out << " NAME=\"" << _className << "\" ";     out << " NAME=\"" << _className << "\" ";
  
     if (_superClassName.getLength())      if (_superClassName.size())
         out << " SUPERCLASS=\"" << _superClassName << "\" ";         out << " SUPERCLASS=\"" << _superClassName << "\" ";
  
     out << ">\n";     out << ">\n";
Line 428 
Line 400 
  
     // Parameters:     // Parameters:
  
     for (Uint32 i = 0, n = _properties.getSize(); i < n; i++)      for (Uint32 i = 0, n = _properties.size(); i < n; i++)
         _properties[i].toXml(out);         _properties[i].toXml(out);
  
     // Methods:     // Methods:
  
     for (Uint32 i = 0, n = _methods.getSize(); i < n; i++)      for (Uint32 i = 0, n = _methods.size(); i < n; i++)
         _methods[i].toXml(out);         _methods[i].toXml(out);
  
     // Class closing element:     // Class closing element:
Line 441 
Line 413 
     out << "</CLASS>\n";     out << "</CLASS>\n";
 } }
  
 void CIMClassRep::print() const  void CIMClassRep::print(std::ostream &os) const
 { {
     Array<Sint8> tmp;     Array<Sint8> tmp;
     toXml(tmp);     toXml(tmp);
     tmp.append('\0');     tmp.append('\0');
     XmlWriter::indentedPrint(std::cout, tmp.getData(), 4);      XmlWriter::indentedPrint(os, tmp.getData(), 4);
     // cout << tmp.getData() << endl;     // cout << tmp.getData() << endl;
 } }
  
Line 463 
Line 435 
 { {
     x._qualifiers.cloneTo(_qualifiers);     x._qualifiers.cloneTo(_qualifiers);
  
     _properties.reserve(x._properties.getSize());      _properties.reserve(x._properties.size());
  
     for (Uint32 i = 0, n = x._properties.getSize(); i < n; i++)      for (Uint32 i = 0, n = x._properties.size(); i < n; i++)
         _properties.append(x._properties[i].clone());         _properties.append(x._properties[i].clone());
  
     _methods.reserve(x._methods.getSize());      _methods.reserve(x._methods.size());
  
     for (Uint32 i = 0, n = x._methods.getSize(); i < n; i++)      for (Uint32 i = 0, n = x._methods.size(); i < n; i++)
         _methods.append(x._methods[i].clone());         _methods.append(x._methods[i].clone());
 } }
  
Line 496 
Line 468 
         const Array<CIMProperty>& tmp1 = _properties;         const Array<CIMProperty>& tmp1 = _properties;
         const Array<CIMProperty>& tmp2 = x->_properties;         const Array<CIMProperty>& tmp2 = x->_properties;
  
         if (tmp1.getSize() != tmp2.getSize())          if (tmp1.size() != tmp2.size())
             return false;             return false;
  
         for (Uint32 i = 0, n = tmp1.getSize(); i < n; i++)          for (Uint32 i = 0, n = tmp1.size(); i < n; i++)
         {         {
             if (!tmp1[i].identical(tmp2[i]))             if (!tmp1[i].identical(tmp2[i]))
                 return false;                 return false;
Line 512 
Line 484 
         const Array<CIMMethod>& tmp1 = _methods;         const Array<CIMMethod>& tmp1 = _methods;
         const Array<CIMMethod>& tmp2 = x->_methods;         const Array<CIMMethod>& tmp2 = x->_methods;
  
         if (tmp1.getSize() != tmp2.getSize())          if (tmp1.size() != tmp2.size())
             return false;             return false;
  
         for (Uint32 i = 0, n = tmp1.getSize(); i < n; i++)          for (Uint32 i = 0, n = tmp1.size(); i < n; i++)
         {         {
             if (!tmp1[i].identical(tmp2[i]))             if (!tmp1[i].identical(tmp2[i]))
                 return false;                 return false;
Line 534 
Line 506 
     return true;     return true;
 } }
  
   void CIMClassRep::getKeyNames(Array<String>& keyNames) const
   {
       keyNames.clear();
   
       for (Uint32 i = 0, n = getPropertyCount(); i < n; i++)
       {
           CIMConstProperty property = getProperty(i);
   
           if (property.isKey())
               keyNames.append(property.getName());
       }
   }
   
 PEGASUS_NAMESPACE_END PEGASUS_NAMESPACE_END


Legend:
Removed from v.1.1  
changed lines
  Added in v.1.7

No CVS admin address has been configured
Powered by
ViewCVS 0.9.2