(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.1 and 1.58

version 1.1, 2001/02/18 18:39:06 version 1.58, 2008/04/11 17:14:03
Line 1 
Line 1 
 //BEGIN_LICENSE  //%2006////////////////////////////////////////////////////////////////////////
 // //
 // Copyright (c) 2000 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
   // of this software and associated documentation files (the "Software"), to
   // deal in the Software without restriction, including without limitation the
   // rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
   // sell copies of the Software, and to permit persons to whom the Software is
   // furnished to do so, subject to the following conditions:
   //
   // THE ABOVE COPYRIGHT NOTICE AND THIS PERMISSION NOTICE SHALL BE INCLUDED IN
   // ALL COPIES OR SUBSTANTIAL PORTIONS OF THE SOFTWARE. THE SOFTWARE IS PROVIDED
   // "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT
   // LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
   // PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
   // HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
   // ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
   // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
 // //
 // Permission is hereby granted, free of charge, to any person obtaining a  //==============================================================================
 // copy of this software and associated documentation files (the "Software"),  
 // to deal in the Software without restriction, including without limitation  
 // the rights to use, copy, modify, merge, publish, distribute, sublicense,  
 // and/or sell copies of the Software, and to permit persons to whom the  
 // Software is furnished to do so, subject to the following conditions:  
 // //
 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR  //%/////////////////////////////////////////////////////////////////////////////
 // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,  
 // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL  
 // THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER  
 // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING  
 // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER  
 // DEALINGS IN THE SOFTWARE.  
 //  
 //END_LICENSE  
 //BEGIN_HISTORY  
 //  
 // Author:  
 //  
 // $Log$  
 // Revision 1.1  2001/02/18 18:39:06  mike  
 // new  
 //  
 // Revision 1.2  2001/02/18 03:56:01  mike  
 // Changed more class names (e.g., ConstClassDecl -> CIMConstClass)  
 //  
 // Revision 1.1  2001/02/16 02:07:06  mike  
 // Renamed many classes and headers (using new CIM prefixes).  
 //  
 // Revision 1.3  2001/01/23 01:25:35  mike  
 // Reworked resolve scheme.  
 //  
 // Revision 1.2  2001/01/22 00:45:47  mike  
 // more work on resolve scheme  
 //  
 // Revision 1.1.1.1  2001/01/14 19:52:58  mike  
 // Pegasus import  
 //  
 //  
 //END_HISTORY  
  
 #include <cassert>  #include <Pegasus/Common/Config.h>
 #include "CIMMethod.h" #include "CIMMethod.h"
 #include "Indentor.h"  #include "CIMMethodRep.h"
   #include "Resolver.h"
 #include "CIMName.h" #include "CIMName.h"
 #include "CIMScope.h" #include "CIMScope.h"
 #include "XmlWriter.h"  #include <Pegasus/Common/MessageLoader.h>
   #include "StrLit.h"
  
 PEGASUS_NAMESPACE_BEGIN PEGASUS_NAMESPACE_BEGIN
  
 CIMMethodRep::CIMMethodRep(  CIMMethodRep::CIMMethodRep(const CIMMethodRep& x) :
     const String& name,      Sharable(),
     CIMType type,      _name(x._name),
     const String& classOrigin,      _type(x._type),
     Boolean propagated)      _classOrigin(x._classOrigin),
     : _name(name), _type(type),      _propagated(x._propagated),
     _classOrigin(classOrigin), _propagated(propagated)      _ownerCount(0)
 { {
     if (!CIMName::legal(name))      x._qualifiers.cloneTo(_qualifiers);
         throw IllegalName();      // Set the CIM name tag.
       _nameTag = generateCIMNameTag(_name);
     if (classOrigin.getLength() && !CIMName::legal(classOrigin))  
         throw IllegalName();  
  
     if (type == CIMType::NONE)      _parameters.reserveCapacity(x._parameters.size());
         throw NullType();  
 }  
  
 CIMMethodRep::~CIMMethodRep()      for (Uint32 i = 0, n = x._parameters.size(); i < n; i++)
 { {
           _parameters.append(x._parameters[i].clone());
 } }
   
 void CIMMethodRep::setName(const String& name)  
 {  
     if (!CIMName::legal(name))  
         throw IllegalName();  
   
     _name = name;  
 } }
  
 void CIMMethodRep::setClassOrigin(const String& classOrigin)  CIMMethodRep::CIMMethodRep(
       const CIMName& name,
       CIMType type,
       const CIMName& classOrigin,
       Boolean propagated)
       : _name(name), _type(type),
       _classOrigin(classOrigin),
       _propagated(propagated),
       _ownerCount(0)
 { {
     if (!CIMName::legal(classOrigin))      // ensure name is not null
         throw IllegalName();      if (name.isNull())
   
     _classOrigin = classOrigin;  
 }  
   
 void CIMMethodRep::addParameter(const CIMParameter& x)  
 { {
     if (!x)          throw UninitializedObjectException();
         throw UnitializedHandle();      }
       // Set the CIM name tag.
     if (findParameter(x.getName()) != Uint32(-1))      _nameTag = generateCIMNameTag(_name);
         throw AlreadyExists();  
   
     _parameters.append(x);  
 } }
  
 Uint32 CIMMethodRep::findParameter(const String& name)  void CIMMethodRep::setName(const CIMName& name)
 { {
     for (Uint32 i = 0, n = _parameters.getSize(); i < n; i++)      // ensure name is not null
       if (name.isNull())
     {     {
         if (CIMName::equal(_parameters[i].getName(), name))          throw UninitializedObjectException();
             return i;  
     }     }
       if (_ownerCount != 0 && _name != name)
     return Uint32(-1);      {
           MessageLoaderParms parms(
               "Common.CIMMethodRep.CONTAINED_METHOD_NAMECHANGEDEXCEPTION",
               "Attempted to change the name of a method"
                   " already in a container.");
           throw Exception(parms);
       }
       _name = name;
       // Set the CIM name tag.
       _nameTag = generateCIMNameTag(_name);
 } }
  
 CIMParameter CIMMethodRep::getParameter(Uint32 pos)  void CIMMethodRep::addParameter(const CIMParameter& x)
 { {
     if (pos >= _parameters.getSize())      if (x.isUninitialized())
         throw OutOfBounds();          throw UninitializedObjectException();
  
     return _parameters[pos];      if (findParameter(x.getName()) != PEG_NOT_FOUND)
       {
           MessageLoaderParms parms("Common.CIMMethodRep.PARAMETER",
               "parameter \"$0\"",
               x.getName().getString());
           throw AlreadyExistsException(parms);
 } }
  
 Uint32 CIMMethodRep::getParameterCount() const      _parameters.append(x);
 {  
     return _parameters.getSize();  
 } }
  
 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 137 
Line 127 
  
     // Check for type mismatch between return types.     // Check for type mismatch between return types.
  
     assert (inheritedMethod);      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 148 
Line 138 
         nameSpace,         nameSpace,
         CIMScope::METHOD,         CIMScope::METHOD,
         false,         false,
         inheritedMethod._rep->_qualifiers);          inheritedMethod._rep->_qualifiers,
           true);
  
     // Validate each of the parameters:     // Validate each of the parameters:
  
     for (size_t i = 0; i < _parameters.getSize(); 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 171 
Line 162 
         nameSpace,         nameSpace,
         CIMScope::METHOD,         CIMScope::METHOD,
         false,         false,
         dummy);          dummy,
           true);
  
     // Validate each of the parameters:     // Validate each of the parameters:
  
     for (size_t i = 0; i < _parameters.getSize(); 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)  
 {  
     return x ? "true" : "false";  
 }  
   
 void CIMMethodRep::toXml(Array<Sint8>& out) const  
 {  
     out << "<METHOD";  
   
     out << " NAME=\"" << _name << "\"";  
   
     out << " TYPE=\"" << TypeToString(_type) << "\"";  
   
     if (_classOrigin.getLength())  
         out << " CLASSORIGIN=\"" << _classOrigin << "\"";  
   
     if (_propagated != false)  
         out << " PROPAGATED=\"" << _toString(_propagated) << "\"";  
   
     out << ">\n";  
   
     _qualifiers.toXml(out);  
   
     for (Uint32 i = 0, n = _parameters.getSize(); i < n; i++)  
         _parameters[i].toXml(out);  
   
     out << "</METHOD>\n";  
 }  
   
 void CIMMethodRep::print() const  
 {  
     Array<Sint8> tmp;  
     toXml(tmp);  
     tmp.append('\0');  
     std::cout << tmp.getData() << std::endl;  
 }  
   
 CIMMethodRep::CIMMethodRep()  
 {  
   
 } }
  
 CIMMethodRep::CIMMethodRep(const CIMMethodRep& x) :  Boolean CIMMethodRep::identical(const CIMMethodRep* x) const
     Sharable(),  
     _name(x._name),  
     _type(x._type),  
     _classOrigin(x._classOrigin),  
     _propagated(x._propagated)  
 { {
     x._qualifiers.cloneTo(_qualifiers);      // If the pointers are the same, the objects must be identical
       if (this == x)
     _parameters.reserve(x._parameters.getSize());  
   
     for (Uint32 i = 0, n = x._parameters.getSize(); i < n; i++)  
         _parameters.append(x._parameters[i].clone());  
 }  
   
 CIMMethodRep& CIMMethodRep::operator=(const CIMMethodRep& x)  
 { {
     return *this;          return true;
 } }
  
 Boolean CIMMethodRep::identical(const CIMMethodRep* x) const      if (!_name.equal (x->_name))
 {  
     if (_name != x->_name)  
         return false;         return false;
  
     if (_type != x->_type)     if (_type != x->_type)
Line 252 
Line 188 
     if (!_qualifiers.identical(x->_qualifiers))     if (!_qualifiers.identical(x->_qualifiers))
         return false;         return false;
  
     if (_parameters.getSize() != x->_parameters.getSize())      if (_parameters.size() != x->_parameters.size())
         return false;         return false;
  
     for (Uint32 i = 0, n = _parameters.getSize(); i < n; i++)      for (Uint32 i = 0, n = _parameters.size(); i < n; i++)
     {     {
         if (!_parameters[i].identical(x->_parameters[i]))         if (!_parameters[i].identical(x->_parameters[i]))
             return false;             return false;


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

No CVS admin address has been configured
Powered by
ViewCVS 0.9.2