(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.27 and 1.51.10.2

version 1.27, 2002/03/28 02:57:54 version 1.51.10.2, 2005/09/30 20:35:55
Line 1 
Line 1 
 //%/////////////////////////////////////////////////////////////////////////////  //%2005////////////////////////////////////////////////////////////////////////
 // //
 // Copyright (c) 2000, 2001 The Open group, BMC Software, Tivoli Systems, IBM  // Copyright (c) 2000, 2001, 2002 BMC Software; Hewlett-Packard Development
   // Company, L.P.; IBM Corp.; The Open Group; Tivoli Systems.
   // Copyright (c) 2003 BMC Software; Hewlett-Packard Development Company, L.P.;
   // IBM Corp.; EMC Corporation, The Open Group.
   // Copyright (c) 2004 BMC Software; Hewlett-Packard Development Company, L.P.;
   // IBM Corp.; EMC Corporation; VERITAS Software Corporation; The Open Group.
   // Copyright (c) 2005 Hewlett-Packard Development Company, L.P.; IBM Corp.;
   // EMC Corporation; VERITAS Software 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 23 
Line 30 
 // Author: Mike Brasher (mbrasher@bmc.com) // Author: Mike Brasher (mbrasher@bmc.com)
 // //
 // Modified By: Karl Schopmeyer (k.schopmeyer@opengroup.org) // 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"
 #include "DeclContext.h" #include "DeclContext.h"
   #include "Resolver.h"
 #include "CIMQualifierDecl.h" #include "CIMQualifierDecl.h"
 #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>
   #include <Pegasus/Common/MessageLoader.h> //l10n
  
 PEGASUS_NAMESPACE_BEGIN PEGASUS_NAMESPACE_BEGIN
 PEGASUS_USING_STD; PEGASUS_USING_STD;
Line 48 
Line 63 
  
 CIMQualifierList& CIMQualifierList::add(const CIMQualifier& qualifier) CIMQualifierList& CIMQualifierList::add(const CIMQualifier& qualifier)
 { {
     if (!qualifier)      if (qualifier.isUninitialized())
         throw UnitializedHandle();          throw UninitializedObjectException();
  
     if (find(qualifier.getName()) != PEG_NOT_FOUND)      if (find(qualifier.getName()) != PEG_NOT_FOUND){
         throw AlreadyExists();          //l10n
                   //throw AlreadyExistsException
               //("qualifier \"" + qualifier.getName().getString () + "\"");
           MessageLoaderParms parms("Common.CIMQualifierList.QUALIFIER",
                                                            "qualifier \"$0\"",
                                                            qualifier.getName().getString());
           throw AlreadyExistsException(parms);
       }
  
     _qualifiers.append(qualifier);     _qualifiers.append(qualifier);
  
     return *this;     return *this;
 } }
 //ATTN: Why do we not do the outofbounds check here. KS 18 May 2k //ATTN: Why do we not do the outofbounds check here. KS 18 May 2k
 CIMQualifier& CIMQualifierList::getQualifier(Uint32 pos)  CIMQualifier& CIMQualifierList::getQualifier(Uint32 index)
 { {
     return _qualifiers[pos];      return _qualifiers[index];
 } }
  
 //ATTN: added ks 18 may 2001. Should we have outofbounds? //ATTN: added ks 18 may 2001. Should we have outofbounds?
 void CIMQualifierList::removeQualifier(Uint32 pos)  void CIMQualifierList::removeQualifier(Uint32 index)
 { {
     _qualifiers.remove(pos);      _qualifiers.remove(index);
 } }
  
 Uint32 CIMQualifierList::find(const String& name) const  Uint32 CIMQualifierList::find(const CIMName& name) const
 { {
     for (Uint32 i = 0, n = _qualifiers.size(); i < n; i++)     for (Uint32 i = 0, n = _qualifiers.size(); i < n; i++)
     {     {
         if (CIMName::equal(_qualifiers[i].getName(), name))          if (name.equal(_qualifiers[i].getName()))
             return i;             return i;
     }     }
  
     return PEG_NOT_FOUND;     return PEG_NOT_FOUND;
 } }
   Boolean CIMQualifierList::isTrue(const CIMName& name) const
   {
       Uint32 index = find(name);
   
       if (index == PEG_NOT_FOUND)
           return false;
  
 Uint32 CIMQualifierList::findReverse(const String& name) const      Boolean flag;
       const CIMValue& value = getQualifier(index).getValue();
   
       if (value.getType() != CIMTYPE_BOOLEAN)
           return false;
   
       value.get(flag);
       return flag;
   }
   
   Uint32 CIMQualifierList::findReverse(const CIMName& name) const
 { {
     for (Uint32 i = _qualifiers.size(); i; --i)     for (Uint32 i = _qualifiers.size(); i; --i)
     {     {
         if (CIMName::equal(_qualifiers[i - 1].getName(), name))          if (name.equal(_qualifiers[i-1].getName()))
             return i - 1;             return i - 1;
     }     }
  
Line 94 
Line 132 
  
 void CIMQualifierList::resolve( void CIMQualifierList::resolve(
     DeclContext* declContext,     DeclContext* declContext,
     const String& nameSpace,      const CIMNamespaceName & nameSpace,
     Uint32 scope,                                       // Scope of the entity being resolved.      CIMScope scope,                      // Scope of the entity being resolved.
     Boolean isInstancePart,     Boolean isInstancePart,
     CIMQualifierList& inheritedQualifiers,     CIMQualifierList& inheritedQualifiers,
     Boolean propagateQualifiers)        // Apparently not used ks 24 mar 2002     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 127 
Line 166 
                 CIMQualifierDecl qd = declContext->lookupQualifierDecl(                 CIMQualifierDecl qd = declContext->lookupQualifierDecl(
                         nameSpace, q.getName());                         nameSpace, q.getName());
  
                 if (!qd)                  if (qd.isUninitialized())
                         throw UndeclaredQualifier(q.getName());                          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()))
                         throw BadQualifierType(q.getName());                          throw BadQualifierType(q.getName().getString ());
  
                 //----------------------------------------------------------------------                 //----------------------------------------------------------------------
                 // 3. Check the scope: Must be legal for this qualifier                 // 3. Check the scope: Must be legal for this qualifier
Line 145 
Line 184 
                         // 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() & scope))                  if (!(qd.getScope().hasScope (scope)))
                         throw BadQualifierScope(qd.getName(), ScopeToString(scope));                          throw BadQualifierScope
                               (qd.getName().getString (), scope.toString ());
 //#endif //#endif
                 //----------------------------------------------------------------------                 //----------------------------------------------------------------------
                 // Resolve the qualifierflavor. Since Flavors are a combination of inheritance                 // Resolve the qualifierflavor. Since Flavors are a combination of inheritance
Line 156 
Line 196 
                 // against the declaration. If the flavor is disableoverride and tosubclass                 // against the declaration. If the flavor is disableoverride and tosubclass
                 // the resolved qualifier value must be identical to the original                 // 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
Line 177 
Line 215 
                 // characteristics (value, type, flavor, etc.) This also leaves the question                 // characteristics (value, type, flavor, etc.) This also leaves the question
                 // of NULL or no values.  The implication is that we must move the value                 // of NULL or no values.  The implication is that we must move the value
                 // from the superclass or declaration.                 // from the superclass or declaration.
                 //  
  
                   Uint32 index = inheritedQualifiers.find(q.getName());
                 Uint32 pos = inheritedQualifiers.find(q.getName());  
  
                 //cout << "KSTEST Qualifier resolve inherit test " << q.getName()                 //cout << "KSTEST Qualifier resolve inherit test " << q.getName()
                 //<< " Inherited From " << ((pos == PEG_NOT_FOUND) ? "Declaration" : "superclass")                  //<< " Inherited From " << ((index == PEG_NOT_FOUND) ? "Declaration" : "superclass")
                 //<< " Flavor " << q.getFlavor()                 //<< " Flavor " << q.getFlavor()
                 //<< " inherited Flavor ";                 //<< " inherited Flavor ";
  
                 if (pos == 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.isFlavor(CIMFlavor::OVERRIDABLE) && qd.isFlavor(CIMFlavor::TOSUBCLASS))                          if (!(qd.getFlavor ().hasFlavor
                                  (CIMFlavor::OVERRIDABLE))
                               && qd.getFlavor ().hasFlavor
                                  (CIMFlavor::TOSUBCLASS))
                         {                         {
                                 if(!(q.getValue() == qd.getValue()))                                 if(!(q.getValue() == qd.getValue()))
                                         cout << "KSTEST QL err NSCL " << q.getName()                                         cout << "KSTEST QL err NSCL " << q.getName()
                                         << " decl flavor " << qd.getFlavor() << " Flavor " << q.getFlavor()                                         << " decl flavor " << qd.getFlavor() << " Flavor " << q.getFlavor()
                                         << " Not override " << !qd.isFlavor(CIMFlavor::OVERRIDABLE)                                          << " Not override "
                                         << " tosubclass " <<  qd.isFlavor(CIMFlavor::TOSUBCLASS) << endl;                                          << !(qd.getFlavor ().hasFlavor
                                 qd.print(); q.print();                                             (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;*/                         //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.isFlavor(CIMFlavor::OVERRIDABLE) && q.isFlavor(CIMFlavor::OVERRIDABLE ))                          if ((!qd.getFlavor ().hasFlavor
                                 throw BadQualifierOverride(q.getName());                                 (CIMFlavor::OVERRIDABLE))
                              && (q.getFlavor ().hasFlavor
                                  (CIMFlavor::OVERRIDABLE)))
                                   throw BadQualifierOverride
                                       (q.getName().getString ());
  
                         q.resolveFlavor(qd.getFlavor(), false);                          Resolver::resolveQualifierFlavor
                               (q, CIMFlavor (qd.getFlavor ()), false);
                         /*if(!(q.getValue() == qd.getValue()))                         /*if(!(q.getValue() == qd.getValue()))
                                 cout << "KSTEST Flavor resolved from decl. " << q.getName()                                 cout << "KSTEST Flavor resolved from decl. " << q.getName()
                                 << " decl flavor " << qd.getFlavor() << " Flavor " << q.getFlavor()                                  << " decl flavor " << qd.getFlavor().toString ()
                                 << " Not override " << !qd.isFlavor(CIMFlavor::OVERRIDABLE)                                  << " Flavor " << q.getFlavor().toString ()
                                 << " tosubclass " <<  qd.isFlavor(CIMFlavor::TOSUBCLASS) << endl;                                  << " Not override "
                          qd.print(); q.print(); */                                  << !(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(pos);                          CIMQualifier iq = inheritedQualifiers.getQualifier(index);
                         // don't allow change override to notoverride.                         // don't allow change override to notoverride.
                         if(!iq.isFlavor(CIMFlavor::OVERRIDABLE) && q.isFlavor(CIMFlavor::OVERRIDABLE ))                          if (!(iq.getFlavor ().hasFlavor
                                 throw BadQualifierOverride(q.getName());                                 (CIMFlavor::OVERRIDABLE))
                              && q.getFlavor ().hasFlavor (CIMFlavor::OVERRIDABLE))
                         if (!iq.isFlavor(CIMFlavor::OVERRIDABLE) && iq.isFlavor(CIMFlavor::TOSUBCLASS))                                  throw BadQualifierOverride
                                       (q.getName().getString ());
   
                           if (!(iq.getFlavor ().hasFlavor
                                  (CIMFlavor::OVERRIDABLE))
                               && iq.getFlavor ().hasFlavor
                                  (CIMFlavor::TOSUBCLASS))
                         {                         {
                                 /*if(!(q.getValue() == iq.getvalue()))                                 /*if(!(q.getValue() == iq.getvalue()))
                                         cout << "KSTEST QL err inherit " << q.getName()                                         cout << "KSTEST QL err inherit " << q.getName()
                                         << " from superclass " << iq.getName()                                         << " from superclass " << iq.getName()
                                         << "   Superclass flavor " << iq.getFlavor()                                          << "   Superclass flavor " << iq.getFlavor().toString ()
                                         << " Flavor " << q.getFlavor()                                          << " Flavor " << q.getFlavor().toString ()
                                         << endl;                                         << endl;
                                 iq.print(); q.print();*/                                  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());                                          throw BadQualifierOverride
                                               (q.getName().getString ());
                           }                           }
                         }                         }
                         //cout << iq.getFlavor()  << endl;                         //cout << iq.getFlavor()  << endl;
                         q.resolveFlavor(iq.getFlavor(), true);                          Resolver::resolveQualifierFlavor
                               (q, CIMFlavor (iq.getFlavor ()), true);
                 }                 }
     }                                   // end of this objects qualifier loop     }                                   // end of this objects qualifier loop
  
Line 246 
Line 309 
     // 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. Loop of inherited qualifiers. Number = "      //cout << "KSTEST. Inherited qualifiers ct = " << inheritedQualifiers.getCount() << endl;
         //      << inheritedQualifiers.getCount() << endl;  
  
     for (Uint32 i = 0, n = inheritedQualifiers.getCount(); i < n; i++)     for (Uint32 i = 0, n = inheritedQualifiers.getCount(); i < n; i++)
     {     {
Line 255 
Line 317 
                         //cout << "KSTEST inherited qualifier propagate loop " <<  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;  
                 //<< " flavor= " << iq.getFlavor()  
                 //<< " TOSUBCLASS " << (iq.getFlavor() && CIMFlavor::TOSUBCLASS) << endl;  
   
                 if (isInstancePart)                 if (isInstancePart)
                 {                 {
                         if (!iq.isFlavor(CIMFlavor::TOINSTANCE))                          if (!(iq.getFlavor ().hasFlavor
                               (CIMFlavor::TOINSTANCE)))
                                 continue;                                 continue;
                 }                 }
                 else                 else
                 {                 {
                         if (!iq.isFlavor(CIMFlavor::TOSUBCLASS))                          if (!(iq.getFlavor ().hasFlavor
                               (CIMFlavor::TOSUBCLASS)))
                                 continue;                                 continue;
                 }                 }
  
Line 287 
Line 344 
     }     }
 } }
  
 void CIMQualifierList::toXml(Array<Sint8>& out) const  void CIMQualifierList::toXml(Buffer& 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 301 
Line 358 
     </pre>     </pre>
     Produces qualifiers as a string on without nl.     Produces qualifiers as a string on without nl.
     */     */
 void CIMQualifierList::toMof(Array<Sint8>& out) const  void CIMQualifierList::toMof(Buffer& out) const
 { {
     // if no qualifiers, return     // if no qualifiers, return
     if (_qualifiers.size() == 0)     if (_qualifiers.size() == 0)
         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 << LIT(", \n");
         _qualifiers[i].toMof(out);          MofWriter::appendQualifierElement(out, _qualifiers[i]);
     }     }
  
     // Terminating bracket     // Terminating bracket
     out << "]";      out.append(']');
 } }
  
  
 void CIMQualifierList::print(PEGASUS_STD(ostream) &os) const void CIMQualifierList::print(PEGASUS_STD(ostream) &os) const
 { {
     Array<Sint8> tmp;      Buffer tmp;
     toXml(tmp);     toXml(tmp);
     tmp.append('\0');     tmp.append('\0');
     os << tmp.getData() << PEGASUS_STD(endl);     os << tmp.getData() << PEGASUS_STD(endl);
Line 351 
Line 408 
 void CIMQualifierList::cloneTo(CIMQualifierList& x) const void CIMQualifierList::cloneTo(CIMQualifierList& x) const
 { {
     x._qualifiers.clear();     x._qualifiers.clear();
     x._qualifiers.reserve(_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());


Legend:
Removed from v.1.27  
changed lines
  Added in v.1.51.10.2

No CVS admin address has been configured
Powered by
ViewCVS 0.9.2