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

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

No CVS admin address has been configured
Powered by
ViewCVS 0.9.2