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

  1 mike  1.9 //%/////////////////////////////////////////////////////////////////////////////
  2           //
  3 kumpf 1.19 // Copyright (c) 2000, 2001, 2002 BMC Software, Hewlett-Packard Company, IBM,
  4            // The Open Group, Tivoli Systems
  5 mike  1.9  //
  6            // Permission is hereby granted, free of charge, to any person obtaining a copy
  7 kumpf 1.19 // of this software and associated documentation files (the "Software"), to
  8            // deal in the Software without restriction, including without limitation the
  9            // rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
 10 mike  1.9  // sell copies of the Software, and to permit persons to whom the Software is
 11            // furnished to do so, subject to the following conditions:
 12            // 
 13 kumpf 1.19 // THE ABOVE COPYRIGHT NOTICE AND THIS PERMISSION NOTICE SHALL BE INCLUDED IN
 14 mike  1.9  // ALL COPIES OR SUBSTANTIAL PORTIONS OF THE SOFTWARE. THE SOFTWARE IS PROVIDED
 15            // "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT
 16 kumpf 1.19 // LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
 17            // PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
 18            // HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
 19 mike  1.9  // ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
 20            // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
 21            //
 22            //==============================================================================
 23            //
 24            // Author: Mike Brasher (mbrasher@bmc.com)
 25            //
 26 kumpf 1.20 // Modified By: Carol Ann Krug Graves, Hewlett-Packard Company
 27            //                (carolann_graves@hp.com)
 28 mike  1.9  //
 29            //%/////////////////////////////////////////////////////////////////////////////
 30            
 31 sage  1.11 #include <Pegasus/Common/Config.h>
 32 mike  1.9  #include <cstdio>
 33            #include "CIMParameter.h"
 34 kumpf 1.16 #include "CIMParameterRep.h"
 35 mike  1.9  #include "Indentor.h"
 36            #include "CIMName.h"
 37            #include "CIMScope.h"
 38            #include "XmlWriter.h"
 39            
 40            PEGASUS_NAMESPACE_BEGIN
 41            
 42            CIMParameterRep::CIMParameterRep(
 43 kumpf 1.21     const CIMName& name, 
 44 mike  1.9      CIMType type,
 45                Boolean isArray,
 46                Uint32 arraySize,
 47 kumpf 1.21     const CIMName& referenceClassName) 
 48 mike  1.9      : _name(name), _type(type), 
 49                _isArray(isArray), _arraySize(arraySize), 
 50                _referenceClassName(referenceClassName)
 51            {
 52                if (_arraySize && !_isArray)
 53 kumpf 1.27 	throw TypeMismatchException();
 54 mike  1.9  
 55 kumpf 1.21     if (!referenceClassName.isNull())
 56 mike  1.9      {
 57 kumpf 1.20 	if (_type != CIMTYPE_REFERENCE)
 58 mike  1.9  	{
 59 kumpf 1.27 	    throw TypeMismatchException();
 60 mike  1.9  	}
 61                }
 62                else
 63                {
 64 kumpf 1.21         // ATTN: revisit this later!
 65 mike  1.9  #if 0
 66 kumpf 1.20 	if (_type == CIMTYPE_REFERENCE)
 67 kumpf 1.27 	    throw TypeMismatchException();
 68 mike  1.9  #endif
 69                }
 70            }
 71            
 72            CIMParameterRep::~CIMParameterRep()
 73            {
 74            
 75            }
 76            
 77 kumpf 1.21 void CIMParameterRep::setName(const CIMName& name) 
 78 mike  1.9  {
 79                _name = name; 
 80            }
 81            
 82 kumpf 1.26 void CIMParameterRep::removeQualifier(Uint32 index)
 83 kumpf 1.23 {
 84 kumpf 1.26     if (index >= _qualifiers.getCount())
 85 kumpf 1.24         throw IndexOutOfBoundsException();
 86 kumpf 1.23 
 87 kumpf 1.26     _qualifiers.removeQualifier (index);
 88 kumpf 1.23 }
 89            
 90 mike  1.9  void CIMParameterRep::resolve(
 91                DeclContext* declContext,
 92 kumpf 1.21     const CIMNamespaceName& nameSpace)
 93 mike  1.9  {
 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            
100                _qualifiers.resolve(
101            	declContext,
102            	nameSpace,
103            	CIMScope::PARAMETER,
104            	false,
105 mike  1.14 	dummy,
106            	true);
107 mike  1.9  }
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 kumpf 1.20 	out << " TYPE=\"" << cimTypeToString (_type) << "\"";
118 mike  1.9  
119            	if (_arraySize)
120            	{
121            	    char buffer[32];
122            	    sprintf(buffer, "%d", _arraySize);
123            	    out << " ARRAYSIZE=\"" << buffer << "\"";
124            	}
125            
126            	out << ">\n";
127            
128            	_qualifiers.toXml(out);
129            
130            	out << "</PARAMETER.ARRAY>\n";
131                }
132 kumpf 1.20     else if (_type == CIMTYPE_REFERENCE)
133 mike  1.10     {
134            	out << "<PARAMETER.REFERENCE";
135            	out << " NAME=\"" << _name << "\" ";
136            	out << " REFERENCECLASS=\"" << _referenceClassName << "\"";
137            	out << ">\n";
138            
139            	_qualifiers.toXml(out);
140            
141            	out << "</PARAMETER.REFERENCE>\n";
142                }
143 mike  1.9      else
144                {
145            	out << "<PARAMETER";
146            	out << " NAME=\"" << _name << "\" ";
147 kumpf 1.20 	out << " TYPE=\"" << cimTypeToString (_type) << "\"";
148 mike  1.9  	out << ">\n";
149            
150            	_qualifiers.toXml(out);
151            
152            	out << "</PARAMETER>\n";
153                }
154            }
155 mike  1.10 
156            /** toMof - puts the Mof representation of teh Parameter object to
157                the output parameter array
158                The BNF for this conversion is:
159                parameterList    = 	parameter *( "," parameter )
160            
161            	parameter    = 	[ qualifierList ] (dataType|objectRef) parameterName
162            				[ array ]
163            
164            	parameterName= 	IDENTIFIER
165            	
166            	array 	     = 	"[" [positiveDecimalValue] "]"
167            	
168                Format on a single line.
169                */
170            void CIMParameterRep::toMof(Array<Sint8>& out) const
171            {
172                // Output the qualifiers for the parameter
173                _qualifiers.toMof(out);
174            
175                if (_qualifiers.getCount())
176 mike  1.10 	out << " ";
177            
178                // Output the data type and name
179 kumpf 1.20     out << cimTypeToString (_type) << " " <<  _name;
180 mike  1.10 
181                if (_isArray)
182                {
183            	//Output the array indicator "[ [arraysize] ]"
184            	if (_arraySize)
185            	{
186            	    char buffer[32];
187            	    sprintf(buffer, "[%d]", _arraySize);
188            	    out << buffer;
189            	}
190            	else
191            	    out << "[]";
192                }
193            }
194            
195 mike  1.9  
196            Boolean CIMParameterRep::identical(const CIMParameterRep* x) const
197            {
198 kumpf 1.28     if (!_name.equal (x->_name))
199 mike  1.9  	return false;
200            
201                if (_type != x->_type)
202            	return false;
203            
204 kumpf 1.28     if (!_referenceClassName.equal (x->_referenceClassName))
205 mike  1.9  	return false;
206            
207                if (!_qualifiers.identical(x->_qualifiers))
208            	return false;
209            
210                return true;
211            }
212            
213            CIMParameterRep::CIMParameterRep()
214            {
215            
216            }
217            
218            CIMParameterRep::CIMParameterRep(const CIMParameterRep& x) :
219                Sharable(),
220                _name(x._name),
221                _type(x._type),
222                _isArray(x._isArray),
223                _arraySize(x._arraySize),
224                _referenceClassName(x._referenceClassName)
225            {
226 mike  1.9      x._qualifiers.cloneTo(_qualifiers);
227            }
228            
229            PEGASUS_NAMESPACE_END

No CVS admin address has been configured
Powered by
ViewCVS 0.9.2