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

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

No CVS admin address has been configured
Powered by
ViewCVS 0.9.2