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

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

No CVS admin address has been configured
Powered by
ViewCVS 0.9.2