(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.16 and 1.31

version 1.16, 2002/03/22 00:48:56 version 1.31, 2002/07/31 22:05:08
Line 1 
Line 1 
 //%///////////////////////////////////////////////////////////////////////////// //%/////////////////////////////////////////////////////////////////////////////
 // //
 // Copyright (c) 2000, 2001 The Open group, BMC Software, Tivoli Systems, IBM  // Copyright (c) 2000, 2001, 2002 BMC Software, Hewlett-Packard Company, IBM,
   // The Open Group, Tivoli Systems
 // //
 // 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 22 
Line 23 
 // //
 // Author: Mike Brasher (mbrasher@bmc.com) // Author: Mike Brasher (mbrasher@bmc.com)
 // //
 // Modified By:  // Modified By: Carol Ann Krug Graves, Hewlett-Packard Company
   //                (carolann_graves@hp.com)
 // //
 //%///////////////////////////////////////////////////////////////////////////// //%/////////////////////////////////////////////////////////////////////////////
  
 #include <Pegasus/Common/Config.h> #include <Pegasus/Common/Config.h>
 #include <cassert>  
 #include "CIMMethod.h" #include "CIMMethod.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"
  
 PEGASUS_NAMESPACE_BEGIN PEGASUS_NAMESPACE_BEGIN
  
 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))      if (type == CIMTYPE_NONE)
         throw IllegalName();  
   
     if (classOrigin.size() && !CIMName::legal(classOrigin))  
         throw IllegalName();  
   
     if (type == CIMType::NONE)  
         throw NullType();         throw NullType();
 } }
  
Line 59 
Line 57 
  
 } }
  
 void CIMMethodRep::setName(const String& name)  void CIMMethodRep::setName(const CIMName& name)
 { {
     if (!CIMName::legal(name))  
         throw IllegalName();  
   
     _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)      if (x.isUninitialized())
         throw UnitializedHandle();          throw UninitializedObject();
  
     if (findParameter(x.getName()) != PEG_NOT_FOUND)     if (findParameter(x.getName()) != PEG_NOT_FOUND)
         throw AlreadyExists();         throw AlreadyExists();
Line 86 
Line 78 
     _parameters.append(x);     _parameters.append(x);
 } }
  
 Uint32 CIMMethodRep::findParameter(const String& name)  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;
     }     }
  
Line 112 
Line 104 
  
 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 120 
Line 112 
  
     // 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 137 
Line 129 
     // Validate each of the parameters:     // Validate each of the parameters:
  
     for (size_t i = 0; i < _parameters.size(); i++)     for (size_t 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 161 
Line 153 
     // Validate each of the parameters:     // Validate each of the parameters:
  
     for (size_t i = 0; i < _parameters.size(); i++)     for (size_t 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 175 
Line 167 
  
     out << " NAME=\"" << _name << "\"";     out << " NAME=\"" << _name << "\"";
  
     out << " TYPE=\"" << TypeToString(_type) << "\"";      out << " TYPE=\"" << cimTypeToString (_type) << "\"";
  
     if (_classOrigin.size())      if (!_classOrigin.isNull())
         out << " CLASSORIGIN=\"" << _classOrigin << "\"";         out << " CLASSORIGIN=\"" << _classOrigin << "\"";
  
     if (_propagated != false)     if (_propagated != false)
Line 188 
Line 180 
     _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++)
         _parameters[i].toXml(out);          XmlWriter::appendParameterElement(out, _parameters[i]);
  
     out << "</METHOD>\n";     out << "</METHOD>\n";
 } }
  
 void CIMMethodRep::print(PEGASUS_STD(ostream) &os) const  
 {  
     Array<Sint8> tmp;  
     toXml(tmp);  
     tmp.append('\0');  
     os << tmp.getData() << PEGASUS_STD(endl);  
 }  
   
 /** /**
     The BNF for this is;     The BNF for this is;
     methodDeclaration   =  [ qualifierList ] dataType methodName     methodDeclaration   =  [ qualifierList ] dataType methodName
Line 219 
Line 203 
     _qualifiers.toMof(out);     _qualifiers.toMof(out);
  
     // output the type, MethodName and ParmeterList left enclosure     // output the type, MethodName and ParmeterList left enclosure
     out << "\n" << TypeToString(_type) << " " << _name << "(";      out << "\n" << cimTypeToString (_type) << " " << _name << "(";
  
     // output the param list separated by commas.     // output the param list separated by commas.
  
Line 229 
Line 213 
         if (i)         if (i)
             out << ", ";             out << ", ";
  
         _parameters[i].toMof(out);          MofWriter::appendParameterElement(out, _parameters[i]);
     }     }
  
     // output the parameterlist and method terminator     // output the parameterlist and method terminator
Line 251 
Line 235 
 { {
     x._qualifiers.cloneTo(_qualifiers);     x._qualifiers.cloneTo(_qualifiers);
  
     _parameters.reserve(x._parameters.size());      _parameters.reserveCapacity(x._parameters.size());
  
     for (Uint32 i = 0, n = x._parameters.size(); i < n; i++)     for (Uint32 i = 0, n = x._parameters.size(); i < n; i++)
         _parameters.append(x._parameters[i].clone());         _parameters.append(x._parameters[i].clone());
 } }
  
 CIMMethodRep& CIMMethodRep::operator=(const CIMMethodRep& x)  
 {  
     return *this;  
 }  
   
 Boolean CIMMethodRep::identical(const CIMMethodRep* x) const Boolean CIMMethodRep::identical(const CIMMethodRep* x) const
 { {
     if (_name != x->_name)     if (_name != x->_name)
Line 289 
Line 268 
 { {
     _type = type;     _type = type;
  
     if (type == CIMType::NONE)      if (type == CIMTYPE_NONE)
         throw NullType();         throw NullType();
 } }
  


Legend:
Removed from v.1.16  
changed lines
  Added in v.1.31

No CVS admin address has been configured
Powered by
ViewCVS 0.9.2