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

  1 karl  1.41 //%2006////////////////////////////////////////////////////////////////////////
  2 mike  1.10 //
  3 karl  1.35 // 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.34 // IBM Corp.; EMC Corporation, The Open Group.
  7 karl  1.35 // 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.37 // Copyright (c) 2005 Hewlett-Packard Development Company, L.P.; IBM Corp.;
 10            // EMC Corporation; VERITAS Software Corporation; The Open Group.
 11 karl  1.41 // 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 kumpf 1.26 // 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.41 // 
 21 kumpf 1.26 // 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 kumpf 1.26 // 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 "CIMQualifier.h"
 35 kumpf 1.19 #include "CIMQualifierRep.h"
 36 mike  1.10 #include "Indentor.h"
 37            #include "CIMName.h"
 38 kumpf 1.32 #include "InternalException.h"
 39 mike  1.10 #include "XmlWriter.h"
 40 kumpf 1.24 #include "MofWriter.h"
 41 mike  1.40 #include "StrLit.h"
 42 mike  1.10 
 43            PEGASUS_NAMESPACE_BEGIN
 44 karl  1.13 PEGASUS_USING_STD;
 45 kumpf 1.19 
 46 mike  1.10 ////////////////////////////////////////////////////////////////////////////////
 47            //
 48            // CIMQualifierRep
 49            //
 50            ////////////////////////////////////////////////////////////////////////////////
 51            
 52 chip  1.38 CIMQualifierRep::CIMQualifierRep()
 53            {
 54            }
 55            
 56            CIMQualifierRep::CIMQualifierRep(const CIMQualifierRep& x) :
 57                Sharable(),
 58                _name(x._name),
 59                _value(x._value),
 60                _flavor(x._flavor),
 61                _propagated(x._propagated)
 62            {
 63            }
 64            
 65 mike  1.10 CIMQualifierRep::CIMQualifierRep(
 66 chip  1.38     const CIMName& name,
 67                const CIMValue& value,
 68 kumpf 1.30     const CIMFlavor & flavor,
 69 mike  1.10     Boolean propagated)
 70 chip  1.38     :
 71                _name(name),
 72                _value(value),
 73 mike  1.10     _flavor(flavor),
 74                _propagated(propagated)
 75            {
 76 chip  1.38     // ensure name is not null
 77 kumpf 1.43     if (name.isNull())
 78 chip  1.38     {
 79                    throw UninitializedObjectException();
 80                }
 81 mike  1.10 }
 82            
 83            CIMQualifierRep::~CIMQualifierRep()
 84            {
 85            }
 86            
 87 chip  1.38 void CIMQualifierRep::setName(const CIMName& name)
 88 mike  1.10 {
 89 chip  1.38     // ensure name is not null
 90 kumpf 1.43     if (name.isNull())
 91 chip  1.38     {
 92                    throw UninitializedObjectException();
 93                }
 94            
 95                _name = name;
 96 mike  1.10 }
 97            
 98 kumpf 1.30 void CIMQualifierRep::resolveFlavor (
 99 chip  1.38     const CIMFlavor & inheritedFlavor,
100 kumpf 1.30     Boolean inherited)
101            {
102                // ATTN: KS P3 Needs more tests and expansion so we treate first different
103                // from inheritance
104 karl  1.17 
105 kumpf 1.30     // if the turnoff flags set, reset the flavor bits
106 chip  1.38     if (inheritedFlavor.hasFlavor (CIMFlavor::RESTRICTED))
107 kumpf 1.30     {
108 kumpf 1.31         _flavor.removeFlavor (CIMFlavor::TOSUBCLASS);
109                    _flavor.removeFlavor (CIMFlavor::TOINSTANCE);
110 kumpf 1.30     }
111 chip  1.38     if (inheritedFlavor.hasFlavor (CIMFlavor::DISABLEOVERRIDE))
112 kumpf 1.30     {
113                    _flavor.removeFlavor (CIMFlavor::ENABLEOVERRIDE);
114                }
115            
116                _flavor.addFlavor (inheritedFlavor);
117            }
118 karl  1.17 
119 mike  1.10 static const char* _toString(Boolean x)
120            {
121                return x ? "true" : "false";
122            }
123            
124 mike  1.39 void CIMQualifierRep::toXml(Buffer& out) const
125 mike  1.10 {
126 mike  1.40     out << STRLIT("<QUALIFIER NAME=\"") << _name;
127                out.append('"');
128                out << STRLIT(" TYPE=\"") << cimTypeToString(_value.getType ());
129                out.append('"');
130 mike  1.10 
131                if (_propagated != false)
132 mike  1.40     {
133 kumpf 1.42         out << STRLIT(" PROPAGATED=\"") << _toString(_propagated);
134                    out.append('"');
135 mike  1.40     }
136 mike  1.10 
137 kumpf 1.25     XmlWriter::appendQualifierFlavorEntity(out, _flavor);
138 mike  1.10 
139 mike  1.40     out << STRLIT(">\n");
140 chip  1.38 
141 kumpf 1.22     XmlWriter::appendValueElement(out, _value);
142 mike  1.10 
143 mike  1.40     out << STRLIT("</QUALIFIER>\n");
144 mike  1.10 }
145            
146 mike  1.11 /** toMof Generates MOF output for a qualifier.
147                The BNF for this is:
148                <pre>
149 kumpf 1.42     qualifier          = qualifierName [ qualifierParameter ] [ ":" 1*flavor]
150 mike  1.11 
151                qualifierParameter = "(" constantValue ")" | arrayInitializer
152            
153                arrayInitializer   = "{" constantValue*( "," constantValue)"}"
154                </pre>
155            */
156 mike  1.39 void CIMQualifierRep::toMof(Buffer& out) const
157 mike  1.11 {
158                // Output Qualifier name
159                out << _name;
160            
161                /* If the qualifier is Boolean, we do not put out a value. This is
162                   the way MOF is shown.  Note that we should really be checking
163 karl  1.17        the qualifierdecl to compare with the default.
164 mike  1.11        Also if the value is Null, we do not put out a value because
165                   no value has been set.  Assumes that qualifiers are built
166                   with NULL set if no value has been placed in the qualifier.
167                */
168                Boolean hasValueField = false;
169 karl  1.17     if (!_value.isNull())
170 mike  1.11     {
171 kumpf 1.42         if (_value.getType() == CIMTYPE_BOOLEAN)
172                    {
173                        Boolean b;
174                        _value.get(b);
175 kumpf 1.43             if (!b)
176 kumpf 1.42                 out << STRLIT(" (false)");
177                    }
178                    else
179                    {
180 dave.sudlik 1.44             if( !_value.isArray() )
181                                  out << STRLIT(" (");
182                              else
183                                  out << STRLIT(" ");
184 kumpf       1.42             hasValueField = true;
185                              MofWriter::appendValueElement(out, _value);
186 dave.sudlik 1.44             if( !_value.isArray() )
187                                  out.append(')');
188 kumpf       1.42         }
189 mike        1.11     }
190                  
191                      // output the flavors
192                      String flavorString;
193 kumpf       1.25     flavorString = MofWriter::getQualifierFlavor(_flavor);
194 mike        1.11     if (flavorString.size())
195                      {
196 kumpf       1.42         out << STRLIT(" : ");
197                          out << flavorString;
198 mike        1.11     }
199 karl        1.15 }
200                  
201                  
202 mike        1.10 Boolean CIMQualifierRep::identical(const CIMQualifierRep* x) const
203                  {
204                      return
205 kumpf       1.42         this == x ||
206                          _name.equal(x->_name) &&
207                          _value == x->_value &&
208                          (_flavor.equal (x->_flavor)) &&
209                          _propagated == x->_propagated;
210 mike        1.10 }
211                  
212 chip        1.38 void CIMQualifierRep::setValue(const CIMValue& value)
213 mike        1.10 {
214 chip        1.38     _value = value;
215 mike        1.10 }
216                  
217                  PEGASUS_NAMESPACE_END

No CVS admin address has been configured
Powered by
ViewCVS 0.9.2