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

Diff for /pegasus/src/Pegasus/Common/CIMQualifierList.cpp between version 1.51.10.1 and 1.64

version 1.51.10.1, 2005/09/30 16:28:15 version 1.64, 2008/02/29 18:55:06
Line 1 
Line 1 
 //%2005////////////////////////////////////////////////////////////////////////  //%2006////////////////////////////////////////////////////////////////////////
 // //
 // Copyright (c) 2000, 2001, 2002 BMC Software; Hewlett-Packard Development // Copyright (c) 2000, 2001, 2002 BMC Software; Hewlett-Packard Development
 // Company, L.P.; IBM Corp.; The Open Group; Tivoli Systems. // Company, L.P.; IBM Corp.; The Open Group; Tivoli Systems.
Line 8 
Line 8 
 // IBM Corp.; EMC Corporation; VERITAS Software Corporation; The Open Group. // IBM Corp.; EMC Corporation; VERITAS Software Corporation; The Open Group.
 // Copyright (c) 2005 Hewlett-Packard Development Company, L.P.; IBM Corp.; // Copyright (c) 2005 Hewlett-Packard Development Company, L.P.; IBM Corp.;
 // EMC Corporation; VERITAS Software Corporation; The Open Group. // EMC Corporation; VERITAS Software Corporation; The Open Group.
   // Copyright (c) 2006 Hewlett-Packard Development Company, L.P.; IBM Corp.;
   // EMC Corporation; Symantec Corporation; The Open Group.
 // //
 // Permission is hereby granted, free of charge, to any person obtaining a copy // Permission is hereby granted, free of charge, to any person obtaining a copy
 // of this software and associated documentation files (the "Software"), to // of this software and associated documentation files (the "Software"), to
Line 27 
Line 29 
 // //
 //============================================================================== //==============================================================================
 // //
 // Author: Mike Brasher (mbrasher@bmc.com)  
 //  
 // Modified By: Karl Schopmeyer (k.schopmeyer@opengroup.org)  
 //              Carol Ann Krug Graves, Hewlett-Packard Company  
 //                  (carolann_graves@hp.com)  
 //              David Dillard, VERITAS Software Corp.  
 //                  (david.dillard@veritas.com)  
 //  
 //%///////////////////////////////////////////////////////////////////////////// //%/////////////////////////////////////////////////////////////////////////////
  
 #include "CIMQualifierList.h" #include "CIMQualifierList.h"
Line 42 
Line 36 
 #include "Resolver.h" #include "Resolver.h"
 #include "CIMQualifierDecl.h" #include "CIMQualifierDecl.h"
 #include "CIMName.h" #include "CIMName.h"
 #include "Indentor.h"  
 #include "XmlWriter.h" #include "XmlWriter.h"
 #include "MofWriter.h" #include "MofWriter.h"
 #include <Pegasus/Common/Tracer.h> #include <Pegasus/Common/Tracer.h>
 #include <Pegasus/Common/MessageLoader.h> //l10n  #include <Pegasus/Common/MessageLoader.h>
   #include "StrLit.h"
   #include "ArrayIterator.h"
   #include "CIMQualifierRep.h"
  
 PEGASUS_NAMESPACE_BEGIN PEGASUS_NAMESPACE_BEGIN
 PEGASUS_USING_STD; PEGASUS_USING_STD;
  
 CIMQualifierList::CIMQualifierList()  static CIMName _KEY("Key");
   
   CIMQualifierList::CIMQualifierList() :
                       _keyIndex(PEGASUS_ORDEREDSET_INDEX_UNKNOWN)
 { {
  
 } }
Line 66 
Line 65 
     if (qualifier.isUninitialized())     if (qualifier.isUninitialized())
         throw UninitializedObjectException();         throw UninitializedObjectException();
  
     if (find(qualifier.getName()) != PEG_NOT_FOUND){      if (find(qualifier.getName()) != PEG_NOT_FOUND)
         //l10n      {
                 //throw AlreadyExistsException  
             //("qualifier \"" + qualifier.getName().getString () + "\"");  
         MessageLoaderParms parms("Common.CIMQualifierList.QUALIFIER",         MessageLoaderParms parms("Common.CIMQualifierList.QUALIFIER",
                                                          "qualifier \"$0\"",                                                          "qualifier \"$0\"",
                                                          qualifier.getName().getString());                                                          qualifier.getName().getString());
Line 78 
Line 75 
  
     _qualifiers.append(qualifier);     _qualifiers.append(qualifier);
  
       // Update key index:
       if (_keyIndex == PEGASUS_ORDEREDSET_INDEX_UNKNOWN &&
               qualifier._rep->_name == _KEY)
           _keyIndex = _qualifiers.size()-1;
   
     return *this;     return *this;
 } }
 //ATTN: Why do we not do the outofbounds check here. KS 18 May 2k  
 CIMQualifier& CIMQualifierList::getQualifier(Uint32 index) CIMQualifier& CIMQualifierList::getQualifier(Uint32 index)
 { {
     return _qualifiers[index];     return _qualifiers[index];
 } }
  
 //ATTN: added ks 18 may 2001. Should we have outofbounds?  
 void CIMQualifierList::removeQualifier(Uint32 index) void CIMQualifierList::removeQualifier(Uint32 index)
 { {
     _qualifiers.remove(index);     _qualifiers.remove(index);
       _keyIndex = PEGASUS_ORDEREDSET_INDEX_UNKNOWN;
 } }
  
 Uint32 CIMQualifierList::find(const CIMName& name) const  void CIMQualifierList::clear()
 {  
     for (Uint32 i = 0, n = _qualifiers.size(); i < n; i++)  
     {     {
         if (name.equal(_qualifiers[i].getName()))      _qualifiers.clear();
             return i;  
     }     }
  
     return PEG_NOT_FOUND;  Uint32 CIMQualifierList::find(const CIMName& name) const
   {
       return _qualifiers.find(name, generateCIMNameTag(name));
 } }
   
 Boolean CIMQualifierList::isTrue(const CIMName& name) const Boolean CIMQualifierList::isTrue(const CIMName& name) const
 { {
     Uint32 index = find(name);     Uint32 index = find(name);
Line 119 
Line 121 
     return flag;     return flag;
 } }
  
 Uint32 CIMQualifierList::findReverse(const CIMName& name) const  
 {  
     for (Uint32 i = _qualifiers.size(); i; --i)  
     {  
         if (name.equal(_qualifiers[i-1].getName()))  
             return i - 1;  
     }  
   
     return PEG_NOT_FOUND;  
 }  
   
 void CIMQualifierList::resolve( void CIMQualifierList::resolve(
     DeclContext* declContext,     DeclContext* declContext,
     const CIMNamespaceName & nameSpace,     const CIMNamespaceName & nameSpace,
Line 138 
Line 129 
     CIMQualifierList& inheritedQualifiers,     CIMQualifierList& inheritedQualifiers,
     Boolean propagateQualifiers)        // Apparently not used ks 24 mar 2002     Boolean propagateQualifiers)        // Apparently not used ks 24 mar 2002
 { {
       _keyIndex = PEGASUS_ORDEREDSET_INDEX_UNKNOWN;
   
     PEG_METHOD_ENTER(TRC_OBJECTRESOLUTION, "CIMQualifierList::resolve()");     PEG_METHOD_ENTER(TRC_OBJECTRESOLUTION, "CIMQualifierList::resolve()");
     // For each qualifier in the qualifiers array, the following     // For each qualifier in the qualifiers array, the following
     // is checked:     // is checked:
Line 167 
Line 160 
                         nameSpace, q.getName());                         nameSpace, q.getName());
  
                 if (qd.isUninitialized())                 if (qd.isUninitialized())
           {
               PEG_METHOD_EXIT();
                         throw UndeclaredQualifier(q.getName().getString ());                         throw UndeclaredQualifier(q.getName().getString ());
           }
  
                 //----------------------------------------------------------------------                 //----------------------------------------------------------------------
                 // 2. Check the type and isArray.  Must be the same:                 // 2. Check the type and isArray.  Must be the same:
                 //----------------------------------------------------------------------                 //----------------------------------------------------------------------
  
                 if (!(q.getType() == qd.getType() && q.isArray() == qd.isArray()))                 if (!(q.getType() == qd.getType() && q.isArray() == qd.isArray()))
           {
               PEG_METHOD_EXIT();
                         throw BadQualifierType(q.getName().getString ());                         throw BadQualifierType(q.getName().getString ());
           }
  
   #ifdef PEGASUS_EMBEDDED_INSTANCE_SUPPORT
                 //----------------------------------------------------------------------                 //----------------------------------------------------------------------
                 // 3. Check the scope: Must be legal for this qualifier          // 3. If the qualifier is the EmbeddedInstance qualifier, then check
           // that the class specified by the qualifier exists in the namespace.
           //----------------------------------------------------------------------
           if (q.getName().equal(CIMName("EmbeddedInstance")))
           {
               String className;
               q.getValue().get(className);
               CIMClass classDef = declContext->lookupClass(nameSpace,
                       CIMName(className));
               if (classDef.isUninitialized())
               {
                   String embeddedInstType("EmbeddedInstance(\"");
                   embeddedInstType = embeddedInstType + className + "\")";
                   PEG_METHOD_EXIT();
                   throw BadQualifierType(embeddedInstType);
               }
           }
   #endif // PEGASUS_EMBEDDED_INSTANCE_SUPPORT
   
           //----------------------------------------------------------------------
           // 4. Check the scope: Must be legal for this qualifier
                 //----------------------------------------------------------------------                 //----------------------------------------------------------------------
 //#if 0  
                         // ATTN:  These lines throw a bogus exception if the qualifier has                         // ATTN:  These lines throw a bogus exception if the qualifier has
                         // a valid scope (such as Scope::ASSOCIATION) which is not Scope::CLASS                         // a valid scope (such as Scope::ASSOCIATION) which is not Scope::CLASS
                         // ks Mar 2002. Reinstalled 23 March 2002 to test.                         // ks Mar 2002. Reinstalled 23 March 2002 to test.
  
                 if (!(qd.getScope().hasScope (scope)))                 if (!(qd.getScope().hasScope (scope)))
           {
               PEG_METHOD_EXIT();
                         throw BadQualifierScope                         throw BadQualifierScope
                             (qd.getName().getString (), scope.toString ());                             (qd.getName().getString (), scope.toString ());
 //#endif          }
   
                 //----------------------------------------------------------------------                 //----------------------------------------------------------------------
                 // Resolve the qualifierflavor. Since Flavors are a combination of inheritance          // Resolve the qualifierflavor. Since Flavors are a combination of
                 // and input characteristics, resolve the inherited characteristics          // inheritance and input characteristics, resolve the inherited
                 // against those provided with the creation.  If there is a superclass          // characteristics against those provided with the creation.  If
                 // the flavor is resolved against that superclass.  If not, it is resolved          // there is a superclass the flavor is resolved against that
                 // against the declaration. If the flavor is disableoverride and tosubclass          // superclass.  If not, it is resolved against the declaration. If
                 // the resolved qualifier value must be identical to the original          // the flavor is disableoverride and tosubclass the resolved
           // qualifier value must be identical to the original
                 //----------------------------------------------------------------------                 //----------------------------------------------------------------------
                 // Test for Qualifier found in SuperClass. If found and qualifier                 // Test for Qualifier found in SuperClass. If found and qualifier
                 // is not overridable.                 // is not overridable.
                 // Abstract (not Overridable and restricted) can be found in subclasses                 // Abstract (not Overridable and restricted) can be found in subclasses
                 // Can have nonabstracts below abstracts. That is function of nottosubclass          // Can have nonabstracts below abstracts. That is function of
                 // Association (notOverridable and tosubclass) can be found in subclasses but          // nottosubclass Association (notOverridable and tosubclass) can be
                 // cannot be changed. No non-associatons below associations. In other words          // found in subclasses but cannot be changed. No non-associatons below
                 // once a class becomes an association, no subclass can override that definition          // associations. In other words once a class becomes an association,
                 // apparently          // no subclass can override that definition apparently
                 // Throw exception if DisableOverride and tosubclass and different value.          // Throw exception if DisableOverride and tosubclass and different
                 // Gets the source from superclass if qualifier exists or from declaraction          // value.  Gets the source from superclass if qualifier exists or from
                 // If we do not throw the exception, resolve the flavor from the inheritance          // declaraction.
                 // point and resolve against current input.          // If we do not throw the exception, resolve the flavor from the
                 // Diableoverride is defined in the CIM Spec to mean that the value cannot change          // inheritance point and resolve against current input.
                 // The other characteristics including the flavor can change apparently. Thus, we          // Diableoverride is defined in the CIM Spec to mean that the value
                 // need only confirm that the value is the same (2.2 pp 33).  Strange since we          // cannot change.
                 // would think that  override implies that you cannot override any of the          // The other characteristics including the flavor can change
                 // characteristics (value, type, flavor, etc.) This also leaves the question          // apparently. Thus, we need only confirm that the value is the same
                 // of NULL or no values.  The implication is that we must move the value          // (2.2 pp 33).  Strange since we would think that override implies
                 // from the superclass or declaration.          // that you cannot override any of the characteristics (value, type,
           // flavor, etc.) This also leaves the question of NULL or no values.
           // The implication is that we must move the value from the superclass
           // or declaration.
  
                 Uint32 index = inheritedQualifiers.find(q.getName());                 Uint32 index = inheritedQualifiers.find(q.getName());
  
                 //cout << "KSTEST Qualifier resolve inherit test " << q.getName()  
                 //<< " Inherited From " << ((index == PEG_NOT_FOUND) ? "Declaration" : "superclass")  
                 //<< " Flavor " << q.getFlavor()  
                 //<< " inherited Flavor ";  
   
                 if (index == PEG_NOT_FOUND)                 if (index == PEG_NOT_FOUND)
                 {   // Qualifier does not exist in superclass                 {   // Qualifier does not exist in superclass
                         /* If from declaration, we can override the default value.                         /* If from declaration, we can override the default value.
                            However, we need some way to get the value if we have a Null.                            However, we need some way to get the value if we have a Null.
                         if (!(qd.getFlavor ().hasFlavor              if (!qd.getFlavor().hasFlavor(CIMFlavor::OVERRIDABLE) &&
                                (CIMFlavor::OVERRIDABLE))                  qd.getFlavor().hasFlavor(CIMFlavor::TOSUBCLASS))
                             && qd.getFlavor ().hasFlavor              {
                                (CIMFlavor::TOSUBCLASS))  
                         {  
                                 if(!(q.getValue() == qd.getValue()))  
                                         cout << "KSTEST QL err NSCL " << q.getName()  
                                         << " decl flavor " << qd.getFlavor() << " Flavor " << q.getFlavor()  
                                         << " Not override "  
                                         << !(qd.getFlavor ().hasFlavor  
                                            (CIMFlavor::OVERRIDABLE))  
                                         << " tosubclass "  
                                         <<  qd.getFlavor ().hasFlavor  
                                             (CIMFlavor::TOSUBCLASS) << endl;  
                                 XmlWriter::printQualifierDeclElement(qd);  
                                 XmlWriter::printQualifierElement(q);  
                                         //throw BadQualifierOverride(q.getName());                                         //throw BadQualifierOverride(q.getName());
                         }                         }
                         //cout <<  qd.getFlavor() << endl;*/              */
                         // Do not allow change from disable override to enable override.                         // Do not allow change from disable override to enable override.
                         if ((!qd.getFlavor ().hasFlavor              if ((!qd.getFlavor ().hasFlavor(CIMFlavor::OVERRIDABLE))
                                (CIMFlavor::OVERRIDABLE))                    && (q.getFlavor ().hasFlavor(CIMFlavor::OVERRIDABLE)))
                            && (q.getFlavor ().hasFlavor              {
                                (CIMFlavor::OVERRIDABLE)))                  PEG_METHOD_EXIT();
                                 throw BadQualifierOverride                  throw BadQualifierOverride(q.getName().getString ());
                                     (q.getName().getString ());              }
   
                         Resolver::resolveQualifierFlavor              Resolver::resolveQualifierFlavor(
                             (q, CIMFlavor (qd.getFlavor ()), false);                  q, CIMFlavor (qd.getFlavor ()), false);
                         /*if(!(q.getValue() == qd.getValue()))  
                                 cout << "KSTEST Flavor resolved from decl. " << q.getName()  
                                 << " decl flavor " << qd.getFlavor().toString ()  
                                 << " Flavor " << q.getFlavor().toString ()  
                                 << " Not override "  
                                 << !(qd.getFlavor ().hasFlavor  
                                        (CIMFlavor::OVERRIDABLE))  
                                 << " tosubclass " <<  qd.getFlavor ().hasFlavor  
                                        (CIMFlavor::TOSUBCLASS) << endl;  
                          XmlWriter::printQualifierDeclElement(qd);  
                          XmlWriter::printQualifierElement(q); */  
                 }                 }
                 else                    // qualifier exists in superclass                 else                    // qualifier exists in superclass
                 {       ////// Make Const again                 {       ////// Make Const again
                         CIMQualifier iq = inheritedQualifiers.getQualifier(index);                         CIMQualifier iq = inheritedQualifiers.getQualifier(index);
                         // don't allow change override to notoverride.                         // don't allow change override to notoverride.
                         if (!(iq.getFlavor ().hasFlavor              if (!(iq.getFlavor ().hasFlavor(CIMFlavor::OVERRIDABLE))
                                (CIMFlavor::OVERRIDABLE))  
                            && q.getFlavor ().hasFlavor (CIMFlavor::OVERRIDABLE))                            && q.getFlavor ().hasFlavor (CIMFlavor::OVERRIDABLE))
                                 throw BadQualifierOverride              {
                                     (q.getName().getString ());                  PEG_METHOD_EXIT();
                   throw BadQualifierOverride(q.getName().getString ());
               }
  
                         if (!(iq.getFlavor ().hasFlavor              if (!(iq.getFlavor ().hasFlavor(CIMFlavor::OVERRIDABLE))
                                (CIMFlavor::OVERRIDABLE))                    && iq.getFlavor ().hasFlavor(CIMFlavor::TOSUBCLASS))
                             && iq.getFlavor ().hasFlavor              {
                                (CIMFlavor::TOSUBCLASS))  
                         {  
                                 /*if(!(q.getValue() == iq.getvalue()))  
                                         cout << "KSTEST QL err inherit " << q.getName()  
                                         << " from superclass " << iq.getName()  
                                         << "   Superclass flavor " << iq.getFlavor().toString ()  
                                         << " Flavor " << q.getFlavor().toString ()  
                                         << endl;  
                                 XmlWriter::printQualifierElement(iq);  
                                 XmlWriter::printQualifierElement(q); */  
                                 // test if values the same.                                 // test if values the same.
                                 CIMValue qv = q.getValue();                                 CIMValue qv = q.getValue();
                                 CIMValue iqv = iq.getValue();                                 CIMValue iqv = iq.getValue();
                                 if(!(qv == iqv)) {                  if (!(qv == iqv))
                                         throw BadQualifierOverride                  {
                                             (q.getName().getString ());                      PEG_METHOD_EXIT();
                       throw BadQualifierOverride(q.getName().getString());
                           }                           }
                         }                         }
                         //cout << iq.getFlavor()  << endl;  
                         Resolver::resolveQualifierFlavor              Resolver::resolveQualifierFlavor(
                             (q, CIMFlavor (iq.getFlavor ()), true);                  q, CIMFlavor(iq.getFlavor()), true);
                 }                 }
     }                                   // end of this objects qualifier loop     }                                   // end of this objects qualifier loop
  
Line 309 
Line 298 
     // Propagate qualifiers to subclass or to instance that do not have     // Propagate qualifiers to subclass or to instance that do not have
     // already have those qualifiers:     // already have those qualifiers:
     //--------------------------------------------------------------------------     //--------------------------------------------------------------------------
     //cout << "KSTEST. Inherited qualifiers ct = " << inheritedQualifiers.getCount() << endl;  
  
     for (Uint32 i = 0, n = inheritedQualifiers.getCount(); i < n; i++)     for (Uint32 i = 0, n = inheritedQualifiers.getCount(); i < n; i++)
     {     {
                 CIMQualifier iq = inheritedQualifiers.getQualifier(i);                 CIMQualifier iq = inheritedQualifiers.getQualifier(i);
                 //cout << "KSTEST inherited qualifier propagate loop " <<  iq.getName()  
                 //<< " flavor " << iq.getFlavor << " count " << i << endl;  
  
                 if (isInstancePart)                 if (isInstancePart)
                 {                 {
Line 332 
Line 318 
  
                 // If the qualifiers list does not already contain this qualifier,                 // If the qualifiers list does not already contain this qualifier,
                 // then propagate it (and set the propagated flag to true).      Else we                 // then propagate it (and set the propagated flag to true).      Else we
                 // keep current value. Note we have already eliminated any possibity that          // keep current value. Note we have already eliminated any possibity
                 // a nonoverridable qualifier can be in the list.          // that a nonoverridable qualifier can be in the list.
                 // Note that there is no exists() function ATTN:KS 25 Mar 2002                 // Note that there is no exists() function ATTN:KS 25 Mar 2002
                 if(find(iq.getName()) != PEG_NOT_FOUND)                 if(find(iq.getName()) != PEG_NOT_FOUND)
                         continue;                         continue;
  
                 CIMQualifier q = iq.clone();                 CIMQualifier q = iq.clone();
                 q.setPropagated(true);                 q.setPropagated(true);
                 _qualifiers.prepend(q);          _qualifiers.insert(0, q);
     }     }
       PEG_METHOD_EXIT();
 } }
  
 void CIMQualifierList::toXml(Buffer& out) const void CIMQualifierList::toXml(Buffer& out) const
Line 365 
Line 352 
         return;         return;
  
     // Qualifier leading bracket.     // Qualifier leading bracket.
     out <<"[";      out.append('[');
  
     // Loop to list qualifiers     // Loop to list qualifiers
     for (Uint32 i = 0, n = _qualifiers.size(); i < n; i++)     for (Uint32 i = 0, n = _qualifiers.size(); i < n; i++)
     {     {
         // if second or greater, add comma separator         // if second or greater, add comma separator
         if (i > 0)         if (i > 0)
             out << ", \n";              out << STRLIT(", \n");
         MofWriter::appendQualifierElement(out, _qualifiers[i]);         MofWriter::appendQualifierElement(out, _qualifiers[i]);
     }     }
  
     // Terminating bracket     // Terminating bracket
     out << "]";      out.append(']');
 } }
  
  
Line 385 
Line 372 
 { {
     Buffer tmp;     Buffer tmp;
     toXml(tmp);     toXml(tmp);
     tmp.append('\0');  
     os << tmp.getData() << PEGASUS_STD(endl);     os << tmp.getData() << PEGASUS_STD(endl);
 } }
  
Line 407 
Line 393 
  
 void CIMQualifierList::cloneTo(CIMQualifierList& x) const void CIMQualifierList::cloneTo(CIMQualifierList& x) const
 { {
       x._keyIndex = PEGASUS_ORDEREDSET_INDEX_UNKNOWN;
     x._qualifiers.clear();     x._qualifiers.clear();
     x._qualifiers.reserveCapacity(_qualifiers.size());     x._qualifiers.reserveCapacity(_qualifiers.size());
  
     for (Uint32 i = 0, n = _qualifiers.size(); i < n; i++)     for (Uint32 i = 0, n = _qualifiers.size(); i < n; i++)
         x._qualifiers.append(_qualifiers[i].clone());         x._qualifiers.append(_qualifiers[i].clone());
       x._keyIndex = _keyIndex;
   }
   
   Boolean CIMQualifierList::isKey() const
   {
       static Uint32 _KEY_TAG = generateCIMNameTag(_KEY);
   
       // Resolve key index if unresolved.
   
       if (_keyIndex == PEGASUS_ORDEREDSET_INDEX_UNKNOWN)
       {
           Uint32 pos = _qualifiers.find(_KEY, _KEY_TAG);
           ((CIMQualifierList*)this)->_keyIndex = int(pos);
       }
   
       // If no key qualifier in list, then return false (default key value).
   
       if (_keyIndex == PEGASUS_ORDEREDSET_INDEX_NOTFOUND)
           return false;
   
       // Obtain value of key qualifier.
   
       const CIMValue& value = _qualifiers[_keyIndex]._rep->_value;
       if (!value.isNull() &&
           value.getType() == CIMTYPE_BOOLEAN)
       {
           Boolean boolVal;
           value.get(boolVal);
           return boolVal;
       }
   
       return false;
 } }
  
 PEGASUS_NAMESPACE_END PEGASUS_NAMESPACE_END


Legend:
Removed from v.1.51.10.1  
changed lines
  Added in v.1.64

No CVS admin address has been configured
Powered by
ViewCVS 0.9.2