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

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

No CVS admin address has been configured
Powered by
ViewCVS 0.9.2