(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.24 and 1.34

version 1.24, 2002/03/24 13:33:07 version 1.34, 2002/05/15 12:28:21
Line 32 
Line 32 
 #include "CIMName.h" #include "CIMName.h"
 #include "Indentor.h" #include "Indentor.h"
 #include "XmlWriter.h" #include "XmlWriter.h"
   #include "MofWriter.h"
   #include <Pegasus/Common/Tracer.h>
  
 PEGASUS_NAMESPACE_BEGIN PEGASUS_NAMESPACE_BEGIN
 PEGASUS_USING_STD; PEGASUS_USING_STD;
Line 48 
Line 50 
  
 CIMQualifierList& CIMQualifierList::add(const CIMQualifier& qualifier) CIMQualifierList& CIMQualifierList::add(const CIMQualifier& qualifier)
 { {
     if (!qualifier)      if (qualifier.isNull())
         throw UnitializedHandle();          throw UninitializedHandle();
  
     if (find(qualifier.getName()) != PEG_NOT_FOUND)     if (find(qualifier.getName()) != PEG_NOT_FOUND)
         throw AlreadyExists();         throw AlreadyExists();
Line 80 
Line 82 
  
     return PEG_NOT_FOUND;     return PEG_NOT_FOUND;
 } }
   Boolean CIMQualifierList::isTrue(const String& name) const
   {
       Uint32 pos = find(name);
   
       if (pos == PEG_NOT_FOUND)
           return false;
   
       Boolean flag;
       const CIMValue& value = getQualifier(pos).getValue();
   
       if (value.getType() != CIMType::BOOLEAN)
           return false;
   
       value.get(flag);
       return flag;
   }
  
 Uint32 CIMQualifierList::findReverse(const String& name) const Uint32 CIMQualifierList::findReverse(const String& name) const
 { {
Line 95 
Line 113 
 void CIMQualifierList::resolve( void CIMQualifierList::resolve(
     DeclContext* declContext,     DeclContext* declContext,
     const String& nameSpace,     const String& nameSpace,
     Uint32 scope,                                       // Association or class scope      Uint32 scope,                        // Scope of the entity being resolved.
     Boolean isInstancePart,     Boolean isInstancePart,
     CIMQualifierList& inheritedQualifiers,     CIMQualifierList& inheritedQualifiers,
     Boolean propagateQualifiers)      Boolean propagateQualifiers)        // Apparently not used ks 24 mar 2002
 { {
       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 123 
Line 142 
                 //----------------------------------------------------------------------                 //----------------------------------------------------------------------
                 // 1. Check to see if it's declared.                 // 1. Check to see if it's declared.
                 //----------------------------------------------------------------------                 //----------------------------------------------------------------------
                   // set this back to  CIMConstQualifierDecl
                 CIMConstQualifierDecl qd = declContext->lookupQualifierDecl(                  CIMQualifierDecl qd = declContext->lookupQualifierDecl(
                         nameSpace, q.getName());                         nameSpace, q.getName());
  
                 if (!qd)                  if (qd.isNull())
                         throw UndeclaredQualifier(q.getName());                         throw UndeclaredQualifier(q.getName());
  
                 //----------------------------------------------------------------------                 //----------------------------------------------------------------------
Line 149 
Line 168 
                         throw BadQualifierScope(qd.getName(), ScopeToString(scope));                         throw BadQualifierScope(qd.getName(), ScopeToString(scope));
 //#endif //#endif
                 //----------------------------------------------------------------------                 //----------------------------------------------------------------------
                 // See if this qualifier is contained in the inheritedQualifiers. If                  // Resolve the qualifierflavor. Since Flavors are a combination of inheritance
                 // so then we must handle the OVERRIDABLE flavor.                  // and input characteristics, resolve the inherited characteristics
                   // against those provided with the creation.  If there is a superclass
                   // the flavor is resolved against that superclass.  If not, it is resolved
                   // against the declaration. If 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
                   // is not overridable.
                   // Abstract (not Overridable and restricted) can be found in subclasses
                   // Can have nonabstracts below abstracts. That is function of nottosubclass
                   // Association (notOverridable and tosubclass) can be found in subclasses but
                   // cannot be changed. No non-associatons below associations. In other words
                   // once a class becomes an association, no subclass can override that definition
                   // apparently
                   // Throw exception if DisableOverride and tosubclass and different value.
                   // Gets the source from superclass if qualifier exists or from declaraction
                   // If we do not throw the exception, resolve the flavor from the inheritance
                   // point and resolve against current input.
                   // Diableoverride is defined in the CIM Spec to mean that the value cannot change
                   // The other characteristics including the flavor can change apparently. Thus, we
                   // need only confirm that the value is the same (2.2 pp 33).  Strange since we
                   // would think that  override implies 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.
  
                 // ATTN: there seems to be a problem with the CIM schema that marks the  
                 // abstract qualifier as non-overridable but then they override it.  
                 // For now it is just disabled. This problem exists in both XML and  
                 // CIM schema.  
                          //cout << "KSTEST QUal resolve Propagate 1 " << q.getName() << endl;  
 #if 0  
                 Uint32 pos = inheritedQualifiers.find(q.getName());                 Uint32 pos = inheritedQualifiers.find(q.getName());
  
                 if (pos != PEG_NOT_FOUND)                  //cout << "KSTEST Qualifier resolve inherit test " << q.getName()
                   //<< " Inherited From " << ((pos == PEG_NOT_FOUND) ? "Declaration" : "superclass")
                   //<< " Flavor " << q.getFlavor()
                   //<< " inherited Flavor ";
   
                   if (pos == PEG_NOT_FOUND)
                   {   // Qualifier does not exist in superclass
                           /* If from declaration, we can override the default value.
                              However, we need some way to get the value if we have a Null.
                           if (!qd.isFlavor(CIMFlavor::OVERRIDABLE) && qd.isFlavor(CIMFlavor::TOSUBCLASS))
                           {
                                   if(!(q.getValue() == qd.getValue()))
                                           cout << "KSTEST QL err NSCL " << q.getName()
                                           << " decl flavor " << qd.getFlavor() << " Flavor " << q.getFlavor()
                                           << " Not override " << !qd.isFlavor(CIMFlavor::OVERRIDABLE)
                                           << " tosubclass " <<  qd.isFlavor(CIMFlavor::TOSUBCLASS) << endl;
                                   XmlWriter::printQualifierDeclElement(qd);
                                   XmlWriter::printQualifierElement(q);
                                           //throw BadQualifierOverride(q.getName());
                           }
                           //cout <<  qd.getFlavor() << endl;*/
                           // Do not allow change from disable override to enable override.
                           if(!qd.isFlavor(CIMFlavor::OVERRIDABLE) && q.isFlavor(CIMFlavor::OVERRIDABLE ))
                                   throw BadQualifierOverride(q.getName());
   
                           q.resolveFlavor(qd.getFlavor(), false);
                           /*if(!(q.getValue() == qd.getValue()))
                                   cout << "KSTEST Flavor resolved from decl. " << q.getName()
                                   << " decl flavor " << qd.getFlavor() << " Flavor " << q.getFlavor()
                                   << " Not override " << !qd.isFlavor(CIMFlavor::OVERRIDABLE)
                                   << " tosubclass " <<  qd.isFlavor(CIMFlavor::TOSUBCLASS) << endl;
                            XmlWriter::printQualifierDeclElement(qd);
                            XmlWriter::printQualifierElement(q); */
                   }
                   else                    // qualifier exists in superclass
                   {       ////// Make Const again
                           CIMQualifier iq = inheritedQualifiers.getQualifier(pos);
                           // don't allow change override to notoverride.
                           if(!iq.isFlavor(CIMFlavor::OVERRIDABLE) && q.isFlavor(CIMFlavor::OVERRIDABLE ))
                                   throw BadQualifierOverride(q.getName());
   
                           if (!iq.isFlavor(CIMFlavor::OVERRIDABLE) && iq.isFlavor(CIMFlavor::TOSUBCLASS))
                 {                 {
                         CIMConstQualifier iq = inheritedQualifiers.getQualifier(pos);                                  /*if(!(q.getValue() == iq.getvalue()))
                         if (!iq.isFlavor(CIMFlavor::OVERRIDABLE))                                          cout << "KSTEST QL err inherit " << q.getName()
                                           << " from superclass " << iq.getName()
                                           << "   Superclass flavor " << iq.getFlavor()
                                           << " Flavor " << q.getFlavor()
                                           << endl;
                                   XmlWriter::printQualifierElement(iq);
                                   XmlWriter::printQualifierElement(q); */
                                   // test if values the same.
                                   CIMValue qv = q.getValue();
                                   CIMValue iqv = iq.getValue();
                                   if(!(qv == iqv)) {
                                 throw BadQualifierOverride(q.getName());                                 throw BadQualifierOverride(q.getName());
                 }                 }
 #endif  
     }     }
                           //cout << iq.getFlavor()  << endl;
                           q.resolveFlavor(iq.getFlavor(), true);
                   }
       }                                   // end of this objects qualifier loop
  
     //--------------------------------------------------------------------------     //--------------------------------------------------------------------------
     // 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  propagate loop 2 " <<  iq.getName()                  //cout << "KSTEST inherited qualifier propagate loop " <<  iq.getName()
                         //<< " flavor " << iq.getFlavor << " count " << i << endl;                         //<< " flavor " << iq.getFlavor << " count " << i << endl;
  
                         // ATTN-DE-P1-This next test is incorrect. It is a temporary, hard-coded  
                         // HACK to avoid propagating the "Abstract" Qualifier to subclasses  
                 //if (CIMName::equal(iq.getName(), "Abstract"))  
                         //   continue;  
   
                 if (isInstancePart)                 if (isInstancePart)
                 {                 {
                         if (!iq.isFlavor(CIMFlavor::TOINSTANCE))                         if (!iq.isFlavor(CIMFlavor::TOINSTANCE))
Line 197 
Line 284 
                 }                 }
  
                 // 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).                  // then propagate it (and set the propagated flag to true).      Else we
                   // keep current value. Note we have already eliminated any possibity that
                   // a nonoverridable qualifier can be in the list.
                   // 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;
  
                         /*  
                         cout << "KSTEST resolve Propagate " << iq.getName() << " true= " << true  
                         << " flavor= " << iq.getFlavor()  
                         << " TOSUBCLASS " << (iq.getFlavor() && CIMFlavor::TOSUBCLASS) << endl;  
                         */  
                 CIMQualifier q = iq.clone();                 CIMQualifier q = iq.clone();
                 q.setPropagated(true);                 q.setPropagated(true);
                 _qualifiers.prepend(q);                 _qualifiers.prepend(q);
Line 216 
Line 300 
 void CIMQualifierList::toXml(Array<Sint8>& out) const void CIMQualifierList::toXml(Array<Sint8>& out) const
 { {
     for (Uint32 i = 0, n = _qualifiers.size(); i < n; i++)     for (Uint32 i = 0, n = _qualifiers.size(); i < n; i++)
         _qualifiers[i].toXml(out);          XmlWriter::appendQualifierElement(out, _qualifiers[i]);
 } }
  
 /** toMof - Generates MOF output for a list of CIM Qualifiers. /** toMof - Generates MOF output for a list of CIM Qualifiers.
Line 242 
Line 326 
         // if second or greater, add comma separator         // if second or greater, add comma separator
         if (i > 0)         if (i > 0)
             out << ", \n";             out << ", \n";
         _qualifiers[i].toMof(out);          MofWriter::appendQualifierElement(out, _qualifiers[i]);
     }     }
  
     // Terminating bracket     // Terminating bracket


Legend:
Removed from v.1.24  
changed lines
  Added in v.1.34

No CVS admin address has been configured
Powered by
ViewCVS 0.9.2