(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 mike          1.38 #include "StrLit.h"
 48 mike          1.9  
 49                    PEGASUS_NAMESPACE_BEGIN
 50                    
 51 chip          1.36 CIMParameterRep::CIMParameterRep()
 52                    {
 53                    }
 54                    
 55                    CIMParameterRep::CIMParameterRep(const CIMParameterRep& x) :
 56                        Sharable(),
 57                        _name(x._name),
 58                        _type(x._type),
 59                        _isArray(x._isArray),
 60                        _arraySize(x._arraySize),
 61                        _referenceClassName(x._referenceClassName)
 62                    {
 63                        x._qualifiers.cloneTo(_qualifiers);
 64                    }
 65                    
 66 mike          1.9  CIMParameterRep::CIMParameterRep(
 67 chip          1.36     const CIMName& name,
 68 mike          1.9      CIMType type,
 69                        Boolean isArray,
 70                        Uint32 arraySize,
 71 chip          1.36     const CIMName& referenceClassName)
 72                        : _name(name), _type(type),
 73                        _isArray(isArray), _arraySize(arraySize),
 74 mike          1.9      _referenceClassName(referenceClassName)
 75                    {
 76 chip          1.36     // ensure name is not null
 77                        if(name.isNull())
 78                        {
 79                            throw UninitializedObjectException();
 80                        }
 81                    
 82                        if((_arraySize != 0) && !_isArray)
 83                        {
 84                            throw TypeMismatchException();
 85                        }
 86 mike          1.9  
 87 kumpf         1.21     if (!referenceClassName.isNull())
 88 mike          1.9      {
 89 chip          1.36         if (_type != CIMTYPE_REFERENCE)
 90                            {
 91                                throw TypeMismatchException();
 92                            }
 93 mike          1.9      }
 94                        else
 95                        {
 96 chip          1.36         if (_type == CIMTYPE_REFERENCE)
 97                            {
 98                                throw TypeMismatchException();
 99                            }
100 mike          1.9      }
101                    }
102                    
103                    CIMParameterRep::~CIMParameterRep()
104                    {
105                    }
106                    
107 chip          1.36 void CIMParameterRep::setName(const CIMName& name)
108 mike          1.9  {
109 chip          1.36     // ensure name is not null
110                        if(name.isNull())
111                        {
112                            throw UninitializedObjectException();
113                        }
114                    
115                        _name = name;
116 mike          1.9  }
117                    
118 kumpf         1.26 void CIMParameterRep::removeQualifier(Uint32 index)
119 kumpf         1.23 {
120 kumpf         1.26     if (index >= _qualifiers.getCount())
121 kumpf         1.24         throw IndexOutOfBoundsException();
122 kumpf         1.23 
123 kumpf         1.26     _qualifiers.removeQualifier (index);
124 kumpf         1.23 }
125                    
126 mike          1.9  void CIMParameterRep::resolve(
127                        DeclContext* declContext,
128 kumpf         1.21     const CIMNamespaceName& nameSpace)
129 mike          1.9  {
130                        // Validate the qualifiers of the method (according to
131                        // superClass's method with the same name). This method
132                        // will throw an exception if the validation fails.
133                    
134                        CIMQualifierList dummy;
135                    
136                        _qualifiers.resolve(
137 a.dunfey      1.38.2.1         declContext,
138                                nameSpace,
139                                CIMScope::PARAMETER,
140                                false,
141                                dummy,
142                                true);
143 mike          1.9      }
144                        
145 mike          1.37     void CIMParameterRep::toXml(Buffer& out) const
146 mike          1.9      {
147                            if (_isArray)
148                            {
149 kumpf         1.30             if (_type == CIMTYPE_REFERENCE)
150                                {
151 mike          1.38                 out << STRLIT("<PARAMETER.REFARRAY NAME=\"") << _name;
152                        	    out.append('"');
153 kumpf         1.30     
154                                    if (!_referenceClassName.isNull())
155                                    {
156 mike          1.38                     out << STRLIT(" REFERENCECLASS=\"");
157                        		out << _referenceClassName.getString();
158                        		out.append('"');
159 kumpf         1.30                 }
160                        
161 mike          1.38     	    if (_arraySize)
162 h.sterling    1.32                 {
163                                        char buffer[32];
164 mike          1.38                     int n = sprintf(buffer, "%d", _arraySize);
165                                        out << STRLIT(" ARRAYSIZE=\"");
166                        		out.append(buffer, n);
167                        		out.append('"');
168 h.sterling    1.32                 }
169                        
170 mike          1.38                 out << STRLIT(">\n");
171 kumpf         1.30     
172                                    _qualifiers.toXml(out);
173                        
174 mike          1.38                 out << STRLIT("</PARAMETER.REFARRAY>\n");
175 kumpf         1.30             }
176                                else
177                                {
178 mike          1.38                 out << STRLIT("<PARAMETER.ARRAY");
179                                    out << STRLIT(" NAME=\"") << _name;
180                        	    out << STRLIT("\" ");
181                                    out << STRLIT(" TYPE=\"") << cimTypeToString(_type);
182                        	    out.append('"');
183 kumpf         1.30     
184                                    if (_arraySize)
185                                    {
186                                        char buffer[32];
187                                        sprintf(buffer, "%d", _arraySize);
188 mike          1.38                     out << STRLIT(" ARRAYSIZE=\"") << buffer;
189                        		out.append('"');
190 kumpf         1.30                 }
191 mike          1.9      
192 mike          1.38                 out << STRLIT(">\n");
193 mike          1.9      
194 kumpf         1.30                 _qualifiers.toXml(out);
195 mike          1.9      
196 mike          1.38                 out << STRLIT("</PARAMETER.ARRAY>\n");
197 kumpf         1.30             }
198 mike          1.9          }
199 kumpf         1.20         else if (_type == CIMTYPE_REFERENCE)
200 mike          1.10         {
201 mike          1.38     	out << STRLIT("<PARAMETER.REFERENCE");
202                        	out << STRLIT(" NAME=\"") << _name;
203                        	out.append('"');
204                        
205 kumpf         1.30             if (!_referenceClassName.isNull())
206                                {
207 mike          1.38     	    out << STRLIT(" REFERENCECLASS=\"");
208                        	    out << _referenceClassName.getString();
209                        	    out.append('"');
210 kumpf         1.30             }
211 mike          1.38     	out << STRLIT(">\n");
212 mike          1.10     
213                        	_qualifiers.toXml(out);
214                        
215 mike          1.38     	out << STRLIT("</PARAMETER.REFERENCE>\n");
216 mike          1.10         }
217 mike          1.9          else
218                            {
219 mike          1.38     	out << STRLIT("<PARAMETER");
220                        	out << STRLIT(" NAME=\"") << _name;
221                        	out << STRLIT("\" ");
222                        	out << STRLIT(" TYPE=\"") << cimTypeToString(_type);
223                        	out << STRLIT("\">\n");
224 mike          1.9      
225                        	_qualifiers.toXml(out);
226                        
227 mike          1.38     	out << STRLIT("</PARAMETER>\n");
228 mike          1.9          }
229                        }
230 mike          1.10     
231                        /** toMof - puts the Mof representation of teh Parameter object to
232                            the output parameter array
233                            The BNF for this conversion is:
234                            parameterList    = 	parameter *( "," parameter )
235                        
236                        	parameter    = 	[ qualifierList ] (dataType|objectRef) parameterName
237                        				[ array ]
238                        
239                        	parameterName= 	IDENTIFIER
240 chip          1.36     
241 mike          1.10     	array 	     = 	"[" [positiveDecimalValue] "]"
242 chip          1.36     
243 mike          1.10         Format on a single line.
244                            */
245 mike          1.37     void CIMParameterRep::toMof(Buffer& out) const
246 mike          1.10     {
247                            // Output the qualifiers for the parameter
248                            _qualifiers.toMof(out);
249                        
250                            if (_qualifiers.getCount())
251 mike          1.38     	out.append(' ');
252 mike          1.10     
253                            // Output the data type and name
254 mike          1.38         out << cimTypeToString(_type);
255                            out.append(' ');
256                            out <<  _name;
257 mike          1.10     
258                            if (_isArray)
259                            {
260                        	//Output the array indicator "[ [arraysize] ]"
261                        	if (_arraySize)
262                        	{
263                        	    char buffer[32];
264 mike          1.38     	    int n = sprintf(buffer, "[%d]", _arraySize);
265                        	    out.append(buffer, n);
266 mike          1.10     	}
267                        	else
268 mike          1.38     	    out << STRLIT("[]");
269 mike          1.10         }
270                        }
271                        
272 mike          1.9      
273                        Boolean CIMParameterRep::identical(const CIMParameterRep* x) const
274                        {
275 kumpf         1.28         if (!_name.equal (x->_name))
276 mike          1.9      	return false;
277                        
278                            if (_type != x->_type)
279                        	return false;
280                        
281 kumpf         1.28         if (!_referenceClassName.equal (x->_referenceClassName))
282 mike          1.9      	return false;
283                        
284                            if (!_qualifiers.identical(x->_qualifiers))
285                        	return false;
286                        
287                            return true;
288                        }
289                        
290                        PEGASUS_NAMESPACE_END

No CVS admin address has been configured
Powered by
ViewCVS 0.9.2