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

No CVS admin address has been configured
Powered by
ViewCVS 0.9.2