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

Diff for /pegasus/src/Pegasus/Common/CIMMethodRep.cpp between version 1.23 and 1.51

version 1.23, 2002/05/15 12:28:21 version 1.51, 2006/11/10 18:14:57
Line 1 
Line 1 
 //%/////////////////////////////////////////////////////////////////////////////  //%2006////////////////////////////////////////////////////////////////////////
 // //
 // Copyright (c) 2000, 2001 The Open group, BMC Software, Tivoli Systems, IBM  // Copyright (c) 2000, 2001, 2002 BMC Software; Hewlett-Packard Development
   // Company, L.P.; IBM Corp.; The Open Group; Tivoli Systems.
   // Copyright (c) 2003 BMC Software; Hewlett-Packard Development Company, L.P.;
   // IBM Corp.; EMC Corporation, The Open Group.
   // Copyright (c) 2004 BMC Software; Hewlett-Packard Development Company, L.P.;
   // IBM Corp.; EMC Corporation; VERITAS Software Corporation; The Open Group.
   // Copyright (c) 2005 Hewlett-Packard Development Company, L.P.; IBM Corp.;
   // EMC Corporation; VERITAS Software Corporation; The Open Group.
   // Copyright (c) 2006 Hewlett-Packard Development Company, L.P.; IBM Corp.;
   // EMC Corporation; Symantec Corporation; The Open Group.
 // //
 // Permission is hereby granted, free of charge, to any person obtaining a copy // Permission is hereby granted, free of charge, to any person obtaining a copy
 // of this software and associated documentation files (the "Software"), to // of this software and associated documentation files (the "Software"), to
Line 20 
Line 29 
 // //
 //============================================================================== //==============================================================================
 // //
 // Author: Mike Brasher (mbrasher@bmc.com)  
 //  
 // Modified By:  
 //  
 //%///////////////////////////////////////////////////////////////////////////// //%/////////////////////////////////////////////////////////////////////////////
  
 #include <Pegasus/Common/Config.h> #include <Pegasus/Common/Config.h>
 #include <cassert>  
 #include "CIMMethod.h" #include "CIMMethod.h"
 #include "CIMMethodRep.h" #include "CIMMethodRep.h"
   #include "Resolver.h"
 #include "Indentor.h" #include "Indentor.h"
 #include "CIMName.h" #include "CIMName.h"
 #include "CIMScope.h" #include "CIMScope.h"
 #include "XmlWriter.h" #include "XmlWriter.h"
 #include "MofWriter.h" #include "MofWriter.h"
   #include <Pegasus/Common/MessageLoader.h>
   #include "StrLit.h"
  
 PEGASUS_NAMESPACE_BEGIN PEGASUS_NAMESPACE_BEGIN
  
   CIMMethodRep::CIMMethodRep()
   {
   }
   
   CIMMethodRep::CIMMethodRep(const CIMMethodRep& x) :
       Sharable(),
       _name(x._name),
       _type(x._type),
       _classOrigin(x._classOrigin),
       _propagated(x._propagated)
   {
       x._qualifiers.cloneTo(_qualifiers);
   
       _parameters.reserveCapacity(x._parameters.size());
   
       for (Uint32 i = 0, n = x._parameters.size(); i < n; i++)
       {
           _parameters.append(x._parameters[i].clone());
       }
   }
   
 CIMMethodRep::CIMMethodRep( CIMMethodRep::CIMMethodRep(
     const String& name,      const CIMName& name,
     CIMType type,     CIMType type,
     const String& classOrigin,      const CIMName& classOrigin,
     Boolean propagated)     Boolean propagated)
     : _name(name), _type(type),     : _name(name), _type(type),
     _classOrigin(classOrigin), _propagated(propagated)     _classOrigin(classOrigin), _propagated(propagated)
 { {
     if (!CIMName::legal(name))      // ensure name is not null
         throw IllegalName();      if (name.isNull())
       {
     if (classOrigin.size() && !CIMName::legal(classOrigin))          throw UninitializedObjectException();
         throw IllegalName();      }
   
     if (type == CIMType::NONE)  
         throw NullType();  
 } }
  
 CIMMethodRep::~CIMMethodRep() CIMMethodRep::~CIMMethodRep()
 { {
   
 } }
  
 void CIMMethodRep::setName(const String& name)  void CIMMethodRep::setName(const CIMName& name)
 { {
     if (!CIMName::legal(name))      // ensure name is not null
         throw IllegalName();      if (name.isNull())
       {
           throw UninitializedObjectException();
       }
  
     _name = name;     _name = name;
 } }
  
 void CIMMethodRep::setClassOrigin(const String& classOrigin)  void CIMMethodRep::setClassOrigin(const CIMName& classOrigin)
 { {
     if (!CIMName::legal(classOrigin))  
         throw IllegalName();  
   
     _classOrigin = classOrigin;     _classOrigin = classOrigin;
 } }
  
 void CIMMethodRep::addParameter(const CIMParameter& x) void CIMMethodRep::addParameter(const CIMParameter& x)
 { {
     if (x.isNull())      if (x.isUninitialized())
         throw UninitializedHandle();          throw UninitializedObjectException();
  
     if (findParameter(x.getName()) != PEG_NOT_FOUND)     if (findParameter(x.getName()) != PEG_NOT_FOUND)
         throw AlreadyExists();      {
           MessageLoaderParms parms("Common.CIMMethodRep.PARAMETER",
               "parameter \"$0\"",
               x.getName().getString());
           throw AlreadyExistsException(parms);
       }
  
     _parameters.append(x);     _parameters.append(x);
 } }
  
 Uint32 CIMMethodRep::findParameter(const String& name) const  Uint32 CIMMethodRep::findParameter(const CIMName& name) const
 { {
     for (Uint32 i = 0, n = _parameters.size(); i < n; i++)     for (Uint32 i = 0, n = _parameters.size(); i < n; i++)
     {     {
         if (CIMName::equal(_parameters[i].getName(), name))          if (name.equal(_parameters[i].getName()))
             return i;             return i;
     }     }
  
     return PEG_NOT_FOUND;     return PEG_NOT_FOUND;
 } }
  
 CIMParameter CIMMethodRep::getParameter(Uint32 pos)  CIMParameter CIMMethodRep::getParameter(Uint32 index)
   {
       if (index >= _parameters.size())
           throw IndexOutOfBoundsException();
   
       return _parameters[index];
   }
   
   void CIMMethodRep::removeParameter(Uint32 index)
 { {
     if (pos >= _parameters.size())      if (index >= _parameters.size())
         throw OutOfBounds();          throw IndexOutOfBoundsException();
  
     return _parameters[pos];      _parameters.remove (index);
 } }
  
 Uint32 CIMMethodRep::getParameterCount() const Uint32 CIMMethodRep::getParameterCount() const
Line 114 
Line 151 
  
 void CIMMethodRep::resolve( void CIMMethodRep::resolve(
     DeclContext* declContext,     DeclContext* declContext,
     const String& nameSpace,      const CIMNamespaceName& nameSpace,
     const CIMConstMethod& inheritedMethod)     const CIMConstMethod& inheritedMethod)
 { {
     // ATTN: Check to see if this method has same signature as     // ATTN: Check to see if this method has same signature as
Line 122 
Line 159 
  
     // Check for type mismatch between return types.     // Check for type mismatch between return types.
  
     assert (!inheritedMethod.isNull());      PEGASUS_ASSERT(!inheritedMethod.isUninitialized());
  
     // Validate the qualifiers of the method (according to     // Validate the qualifiers of the method (according to
     // superClass's method with the same name). This method     // superClass's method with the same name). This method
Line 138 
Line 175 
  
     // Validate each of the parameters:     // Validate each of the parameters:
  
     for (size_t i = 0; i < _parameters.size(); i++)      for (Uint32 i = 0; i < _parameters.size(); i++)
         _parameters[i].resolve(declContext, nameSpace);          Resolver::resolveParameter (_parameters[i], declContext, nameSpace);
  
     _classOrigin = inheritedMethod.getClassOrigin();     _classOrigin = inheritedMethod.getClassOrigin();
 } }
  
 void CIMMethodRep::resolve( void CIMMethodRep::resolve(
     DeclContext* declContext,     DeclContext* declContext,
     const String& nameSpace)      const CIMNamespaceName& nameSpace)
 { {
     // Validate the qualifiers:     // Validate the qualifiers:
  
Line 162 
Line 199 
  
     // Validate each of the parameters:     // Validate each of the parameters:
  
     for (size_t i = 0; i < _parameters.size(); i++)      for (Uint32 i = 0; i < _parameters.size(); i++)
         _parameters[i].resolve(declContext, nameSpace);          Resolver::resolveParameter (_parameters[i], declContext, nameSpace);
 } }
  
 static const char* _toString(Boolean x) static const char* _toString(Boolean x)
Line 171 
Line 208 
     return x ? "true" : "false";     return x ? "true" : "false";
 } }
  
 void CIMMethodRep::toXml(Array<Sint8>& out) const  void CIMMethodRep::toXml(Buffer& out) const
 { {
     out << "<METHOD";      out << STRLIT("<METHOD NAME=\"") << _name;
       out.append('"');
  
     out << " NAME=\"" << _name << "\"";      out << STRLIT(" TYPE=\"") << cimTypeToString(_type);
       out.append('"');
  
     out << " TYPE=\"" << _type.toString() << "\"";      if (!_classOrigin.isNull())
       {
     if (_classOrigin.size())          out << STRLIT(" CLASSORIGIN=\"") << _classOrigin;
         out << " CLASSORIGIN=\"" << _classOrigin << "\"";          out.append('"');
       }
  
     if (_propagated != false)     if (_propagated != false)
         out << " PROPAGATED=\"" << _toString(_propagated) << "\"";      {
           out << STRLIT(" PROPAGATED=\"") << _toString(_propagated);
           out.append('"');
       }
  
     out << ">\n";      out << STRLIT(">\n");
  
     _qualifiers.toXml(out);     _qualifiers.toXml(out);
  
     for (Uint32 i = 0, n = _parameters.size(); i < n; i++)     for (Uint32 i = 0, n = _parameters.size(); i < n; i++)
         XmlWriter::appendParameterElement(out, _parameters[i]);         XmlWriter::appendParameterElement(out, _parameters[i]);
  
     out << "</METHOD>\n";      out << STRLIT("</METHOD>\n");
 } }
  
 /** /**
Line 204 
Line 247 
     Format with qualifiers on one line and declaration on another. Start     Format with qualifiers on one line and declaration on another. Start
     with newline but none at the end.     with newline but none at the end.
 */ */
 void CIMMethodRep::toMof(Array<Sint8>& out) const   //ATTNKS:  void CIMMethodRep::toMof(Buffer& out) const   //ATTNKS:
 { {
     // Output the qualifier list starting on new line     // Output the qualifier list starting on new line
     if (_qualifiers.getCount())     if (_qualifiers.getCount())
         out << "\n";          out.append('\n');
  
     _qualifiers.toMof(out);     _qualifiers.toMof(out);
  
     // output the type, MethodName and ParmeterList left enclosure     // output the type, MethodName and ParmeterList left enclosure
     out << "\n" << _type.toString() << " " << _name << "(";      out.append('\n');
       out << cimTypeToString(_type);
       out.append(' ');
       out << _name;
       out.append('(');
  
     // output the param list separated by commas.     // output the param list separated by commas.
  
Line 221 
Line 268 
     {     {
         // If not first, output comma separator         // If not first, output comma separator
         if (i)         if (i)
             out << ", ";              out << STRLIT(", ");
  
         MofWriter::appendParameterElement(out, _parameters[i]);         MofWriter::appendParameterElement(out, _parameters[i]);
     }     }
  
     // output the parameterlist and method terminator     // output the parameterlist and method terminator
     out << ");";      out << STRLIT(");");
 } }
  
  
 CIMMethodRep::CIMMethodRep()  
 {  
   
 }  
   
 CIMMethodRep::CIMMethodRep(const CIMMethodRep& x) :  
     Sharable(),  
     _name(x._name),  
     _type(x._type),  
     _classOrigin(x._classOrigin),  
     _propagated(x._propagated)  
 {  
     x._qualifiers.cloneTo(_qualifiers);  
   
     _parameters.reserve(x._parameters.size());  
   
     for (Uint32 i = 0, n = x._parameters.size(); i < n; i++)  
         _parameters.append(x._parameters[i].clone());  
 }  
   
 Boolean CIMMethodRep::identical(const CIMMethodRep* x) const Boolean CIMMethodRep::identical(const CIMMethodRep* x) const
 { {
     if (_name != x->_name)      if (!_name.equal (x->_name))
         return false;         return false;
  
     if (_type != x->_type)     if (_type != x->_type)
Line 277 
Line 304 
 void CIMMethodRep::setType(CIMType type) void CIMMethodRep::setType(CIMType type)
 { {
     _type = type;     _type = type;
   
     if (type == CIMType::NONE)  
         throw NullType();  
 } }
  
 PEGASUS_NAMESPACE_END PEGASUS_NAMESPACE_END


Legend:
Removed from v.1.23  
changed lines
  Added in v.1.51

No CVS admin address has been configured
Powered by
ViewCVS 0.9.2