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

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