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

  1 mike  1.7 //%/////////////////////////////////////////////////////////////////////////////
  2           //
  3           // Copyright (c) 2000, 2001 The Open group, BMC Software, Tivoli Systems, IBM
  4           //
  5           // Permission is hereby granted, free of charge, to any person obtaining a copy
  6           // of this software and associated documentation files (the "Software"), to 
  7           // deal in the Software without restriction, including without limitation the 
  8           // rights to use, copy, modify, merge, publish, distribute, sublicense, and/or 
  9           // sell copies of the Software, and to permit persons to whom the Software is
 10           // furnished to do so, subject to the following conditions:
 11           // 
 12           // THE ABOVE COPYRIGHT NOTICE AND THIS PERMISSION NOTICE SHALL BE INCLUDED IN 
 13           // ALL COPIES OR SUBSTANTIAL PORTIONS OF THE SOFTWARE. THE SOFTWARE IS PROVIDED
 14           // "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT
 15           // LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR 
 16           // PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT 
 17           // HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN 
 18           // ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
 19           // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
 20           //
 21           //==============================================================================
 22 mike  1.7 //
 23           // Author: Mike Brasher (mbrasher@bmc.com)
 24           //
 25           // Modified By:
 26           //
 27           //%/////////////////////////////////////////////////////////////////////////////
 28           
 29           #include <cstdio>
 30           #include "CIMParameter.h"
 31           #include "Indentor.h"
 32           #include "CIMName.h"
 33           #include "CIMScope.h"
 34           #include "XmlWriter.h"
 35           
 36           PEGASUS_NAMESPACE_BEGIN
 37           
 38           CIMParameterRep::CIMParameterRep(
 39               const String& name, 
 40               CIMType type,
 41               Boolean isArray,
 42               Uint32 arraySize,
 43 mike  1.7     const String& referenceClassName) 
 44               : _name(name), _type(type), 
 45               _isArray(isArray), _arraySize(arraySize), 
 46               _referenceClassName(referenceClassName)
 47           {
 48               if (!CIMName::legal(name))
 49           	throw IllegalName();
 50           
 51               if (_type == CIMType::NONE)
 52           	throw NullType();
 53           
 54               if (_arraySize && !_isArray)
 55           	throw IncompatibleTypes();
 56           
 57               if (referenceClassName.size())
 58               {
 59           	if (!CIMName::legal(referenceClassName))
 60           	    throw IllegalName();
 61           
 62           	if (_type != CIMType::REFERENCE)
 63           	{
 64 mike  1.7 	    throw ExpectedReferenceValue();
 65           	}
 66               }
 67               else
 68               {
 69           
 70               // ATTN: revisit this later!
 71           #if 0
 72           	if (_type == CIMType::REFERENCE)
 73           	    throw MissingReferenceClassName();
 74           #endif
 75               }
 76           }
 77           
 78           CIMParameterRep::~CIMParameterRep()
 79           {
 80           
 81           }
 82           
 83           void CIMParameterRep::setName(const String& name) 
 84           {
 85 mike  1.7     if (!CIMName::legal(name))
 86           	throw IllegalName();
 87           
 88               _name = name; 
 89           }
 90           
 91           void CIMParameterRep::resolve(
 92               DeclContext* declContext,
 93               const String& nameSpace)
 94           {
 95               // Validate the qualifiers of the method (according to
 96               // superClass's method with the same name). This method
 97               // will throw an exception if the validation fails.
 98           
 99               CIMQualifierList dummy;
100           
101               _qualifiers.resolve(
102           	declContext,
103           	nameSpace,
104           	CIMScope::PARAMETER,
105           	false,
106 mike  1.7 	dummy);
107           }
108           
109           void CIMParameterRep::toXml(Array<Sint8>& out) const
110           {
111               if (_isArray)
112               {
113           	out << "<PARAMETER.ARRAY";
114           
115           	out << " NAME=\"" << _name << "\" ";
116           
117           	out << " TYPE=\"" << TypeToString(_type) << "\"";
118           
119           	if (_arraySize)
120           	{
121           	    char buffer[32];
122           	    sprintf(buffer, "%d", _arraySize);
123           	    out << " ARRAYSIZE=\"" << buffer << "\"";
124           	}
125           
126           	out << ">\n";
127 mike  1.7 
128           	_qualifiers.toXml(out);
129           
130           	out << "</PARAMETER.ARRAY>\n";
131               }
132               else
133               {
134           	out << "<PARAMETER";
135           
136           	out << " NAME=\"" << _name << "\" ";
137           
138           	out << " TYPE=\"" << TypeToString(_type) << "\"";
139           
140           	out << ">\n";
141           
142           	_qualifiers.toXml(out);
143           
144           	out << "</PARAMETER>\n";
145               }
146           }
147           
148 mike  1.7 void CIMParameterRep::print(PEGASUS_STD(ostream) &os) const 
149           {
150               Array<Sint8> tmp;
151               toXml(tmp);
152               tmp.append('\0');
153               os << tmp.getData() << PEGASUS_STD(endl);
154           }
155           
156           Boolean CIMParameterRep::identical(const CIMParameterRep* x) const
157           {
158               if (_name != x->_name)
159           	return false;
160           
161               if (_type != x->_type)
162           	return false;
163           
164               if (_referenceClassName != x->_referenceClassName)
165           	return false;
166           
167               if (!_qualifiers.identical(x->_qualifiers))
168           	return false;
169 mike  1.7 
170               return true;
171           }
172           
173           CIMParameterRep::CIMParameterRep()
174           {
175           
176           }
177           
178           CIMParameterRep::CIMParameterRep(const CIMParameterRep& x) :
179               Sharable(),
180               _name(x._name),
181               _type(x._type),
182               _isArray(x._isArray),
183               _arraySize(x._arraySize),
184               _referenceClassName(x._referenceClassName)
185           {
186               x._qualifiers.cloneTo(_qualifiers);
187           }
188           
189           CIMParameterRep& CIMParameterRep::operator=(const CIMParameterRep& x) 
190 mike  1.7 { 
191               return *this; 
192           }
193           
194           void CIMParameterRep::setType(CIMType type)
195           { 
196               _type = type;
197           
198               if (_referenceClassName.size() == 0 && _type == CIMType::REFERENCE)
199               {
200           	throw MissingReferenceClassName();
201               }
202           }
203           
204           PEGASUS_NAMESPACE_END

No CVS admin address has been configured
Powered by
ViewCVS 0.9.2