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

  1 karl  1.39 //%2005////////////////////////////////////////////////////////////////////////
  2 mike  1.10 //
  3 karl  1.37 // 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.36 // IBM Corp.; EMC Corporation, The Open Group.
  7 karl  1.37 // 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.39 // Copyright (c) 2005 Hewlett-Packard Development Company, L.P.; IBM Corp.;
 10            // EMC Corporation; VERITAS Software Corporation; The Open Group.
 11 mike  1.10 //
 12            // Permission is hereby granted, free of charge, to any person obtaining a copy
 13 mike  1.11 // 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.10 // 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.40 //
 19 mike  1.11 // THE ABOVE COPYRIGHT NOTICE AND THIS PERMISSION NOTICE SHALL BE INCLUDED IN
 20 mike  1.10 // 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 mike  1.11 // 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.10 // 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.29 // Modified By: Carol Ann Krug Graves, Hewlett-Packard Company
 33 david.dillard 1.38 //                  (carolann_graves@hp.com)
 34                    //              David Dillard, VERITAS Software Corp.
 35                    //                  (david.dillard@veritas.com)
 36 mike          1.10 //
 37                    //%/////////////////////////////////////////////////////////////////////////////
 38                    
 39                    #include <cstdio>
 40                    #include "CIMQualifierDecl.h"
 41 kumpf         1.19 #include "CIMQualifierDeclRep.h"
 42 mike          1.10 #include "Indentor.h"
 43                    #include "CIMName.h"
 44 kumpf         1.34 #include "InternalException.h"
 45 mike          1.10 #include "XmlWriter.h"
 46 kumpf         1.25 #include "MofWriter.h"
 47 mike          1.10 
 48                    PEGASUS_NAMESPACE_BEGIN
 49 karl          1.15 PEGASUS_USING_STD;
 50 mike          1.10 ////////////////////////////////////////////////////////////////////////////////
 51                    //
 52                    // CIMQualifierDeclRep
 53                    //
 54                    ////////////////////////////////////////////////////////////////////////////////
 55                    
 56                    CIMQualifierDeclRep::CIMQualifierDeclRep(
 57 kumpf         1.30     const CIMName& name,
 58 mike          1.11     const CIMValue& value,
 59 kumpf         1.33     const CIMScope & scope,
 60                        const CIMFlavor & flavor,
 61 mike          1.10     Uint32 arraySize)
 62 mike          1.11     :
 63                        _name(name),
 64                        _value(value),
 65 mike          1.10     _scope(scope),
 66                        _flavor(flavor),
 67                        _arraySize(arraySize)
 68                    {
 69 chip          1.40     // ensure name is not null
 70                        if(name.isNull())
 71                        {
 72                            throw UninitializedObjectException();
 73                        }
 74                    
 75                        // Set the flavor defaults. Must actively set them in case input flavor
 76 karl          1.17 	// sets some but not all the defaults.	Also Make sure no conflicts. This covers
 77                    	// the fact that we have separate flags for on and off for the toelement
 78                    	// and override functions. Something must be set on creation and the
 79                    	// default in the .h file only covers the case where there is no input.
 80                    	// This also assures that there are no conflicts. Note that it favors
 81                    	// restricted and disable override
 82                    	//ATTN: This should become an exception in case conflicting entities are set.
 83 kumpf         1.33     if(!(_flavor.hasFlavor (CIMFlavor::RESTRICTED)))
 84                            _flavor.addFlavor (CIMFlavor::TOSUBCLASS);
 85                        else
 86                            _flavor.removeFlavor (CIMFlavor::TOSUBCLASS);
 87                    
 88                        if(!(_flavor.hasFlavor (CIMFlavor::DISABLEOVERRIDE)))
 89                            _flavor.addFlavor (CIMFlavor::ENABLEOVERRIDE);
 90                        else
 91                            _flavor.removeFlavor (CIMFlavor::ENABLEOVERRIDE);
 92 karl          1.17 
 93 mike          1.10 }
 94                    
 95                    CIMQualifierDeclRep::~CIMQualifierDeclRep()
 96                    {
 97                    
 98                    }
 99                    
100 kumpf         1.30 void CIMQualifierDeclRep::setName(const CIMName& name)
101 mike          1.10 {
102 chip          1.40     // ensure name is not null
103                        if(name.isNull())
104                        {
105                            throw UninitializedObjectException();
106                        }
107                    
108 mike          1.11     _name = name;
109 mike          1.10 }
110                    
111                    static const char* _toString(Boolean x)
112                    {
113                        return x ? "true" : "false";
114                    }
115                    
116 mike          1.40.2.1 void CIMQualifierDeclRep::toXml(Buffer& out) const
117 mike          1.10     {
118                            out << "<QUALIFIER.DECLARATION";
119                            out << " NAME=\"" << _name << "\"";
120 kumpf         1.29         out << " TYPE=\"" << cimTypeToString (_value.getType ()) << "\"";
121 mike          1.10     
122                            if (_value.isArray())
123                            {
124                        	out << " ISARRAY=\"true\"";
125                        
126                        	if (_arraySize)
127                        	{
128                        	    char buffer[64];
129                        	    sprintf(buffer, " ARRAYSIZE=\"%d\"", _arraySize);
130                        	    out << buffer;
131                        	}
132                            }
133                        
134 kumpf         1.26         XmlWriter::appendQualifierFlavorEntity(out, _flavor);
135 mike          1.10     
136                            out << ">\n";
137                        
138 kumpf         1.27         XmlWriter::appendScopeElement(out, _scope);
139 kumpf         1.23         XmlWriter::appendValueElement(out, _value);
140 mike          1.10     
141                            out << "</QUALIFIER.DECLARATION>\n";
142                        }
143                        
144 mike          1.11     /** toMof - Generate the MOF output for the Qualifier Declaration object.
145 chip          1.40     
146 mike          1.11         The BNF for this output is:
147 karl          1.12         <pre>
148 mike          1.11         qualifierDeclaration   = 	QUALIFIER qualifierName qualifierType scope
149                        				[ defaultFlavor ] ";"
150                        
151                            qualifierName 	   = 	IDENTIFIER
152                        
153                            qualifierType 	   = 	":" dataType [ array ] [ defaultValue ]
154                        
155                            scope 		   = 	"," SCOPE "(" metaElement *( "," metaElement )
156                            ")"
157 karl          1.12         </pre>
158 mike          1.11     */
159 mike          1.40.2.1 void CIMQualifierDeclRep::toMof(Buffer& out) const
160 mike          1.11     {
161                            out << "\n";
162                        
163                            // output the "Qualifier" keyword and name
164 kumpf         1.25         out << "Qualifier " << _name;
165 mike          1.11     
166                            // output the qualifiertype
167 kumpf         1.29         out << " : " << cimTypeToString (_value.getType ());
168 mike          1.11     
169                            // If array put the Array indicator "[]" and possible size after name.
170                            if (_value.isArray())
171                            {
172                        	if (_arraySize)
173                        	{
174                        	    char buffer[32];
175                        	    sprintf(buffer, "[%d]", _arraySize);
176                        	    out << buffer;
177                        	}
178                        	else
179                        	    out << "[]";
180                            }
181                        
182                            Boolean hasValueField = false;
183 karl          1.12         // KS think through the following test
184 kumpf         1.29         //if (!_value.isNull() || !(_value.getType() == CIMTYPE_BOOLEAN) )
185 karl          1.12         //{
186                                // KS With CIM Qualifier, this should be =
187 karl          1.13     	out << " = ";
188 mike          1.11     	hasValueField = true;
189 kumpf         1.25     	MofWriter::appendValueElement(out, _value);
190 karl          1.12         //}
191 mike          1.11     
192 karl          1.12         // Output Scope Information
193 mike          1.11         String scopeString;
194 kumpf         1.27         scopeString = MofWriter::getQualifierScope(_scope);
195 karl          1.12         //if (scopeString.size())
196                            //{
197                        	out << ", Scope(" << scopeString << ")";
198                            //}
199                            // Output Flavor Information
200 mike          1.11         String flavorString;
201 kumpf         1.26         flavorString = MofWriter::getQualifierFlavor(_flavor);
202 mike          1.11         if (flavorString.size())
203                            {
204 karl          1.12         out << ", Flavor(" << flavorString << ")";
205 mike          1.11         }
206 karl          1.12         // End each qualifier declaration with newline
207 mike          1.11         out << ";\n";
208 karl          1.16     }
209                        
210 mike          1.10     
211                        CIMQualifierDeclRep::CIMQualifierDeclRep()
212                        {
213                        
214                        }
215                        
216 mike          1.11     CIMQualifierDeclRep::CIMQualifierDeclRep(const CIMQualifierDeclRep& x) :
217 mike          1.10         Sharable(),
218                            _name(x._name),
219                            _value(x._value),
220                            _scope(x._scope),
221                            _flavor(x._flavor),
222                            _arraySize(x._arraySize)
223                        {
224                        
225                        }
226                        
227                        Boolean CIMQualifierDeclRep::identical(const CIMQualifierDeclRep* x) const
228                        {
229                            return
230                        	this == x ||
231 kumpf         1.30     	_name.equal(x->_name) &&
232 mike          1.11     	_value == x->_value &&
233 kumpf         1.32     	(_scope.equal (x->_scope)) &&
234 kumpf         1.33     	(_flavor.equal (x->_flavor)) &&
235 mike          1.10     	_arraySize == x->_arraySize;
236                        }
237                        
238 mike          1.11     void CIMQualifierDeclRep::setValue(const CIMValue& value)
239 mike          1.10     {
240 mike          1.11         _value = value;
241 mike          1.10     }
242                        
243                        PEGASUS_NAMESPACE_END
244 mike          1.11     

No CVS admin address has been configured
Powered by
ViewCVS 0.9.2