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

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

No CVS admin address has been configured
Powered by
ViewCVS 0.9.2