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

Diff for /pegasus/src/Pegasus/Common/CIMFlavor.cpp between version 1.10 and 1.17

version 1.10, 2002/01/29 14:46:14 version 1.17, 2002/08/14 21:09:00
Line 1 
Line 1 
 //%///////////////////////////////////////////////////////////////////////////// //%/////////////////////////////////////////////////////////////////////////////
 // //
 // Copyright (c) 2000, 2001 The Open group, BMC Software, Tivoli Systems, IBM  // Copyright (c) 2000, 2001, 2002 BMC Software, Hewlett-Packard Company, IBM,
   // The Open Group, Tivoli Systems
 // //
 // 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 22 
Line 23 
 // //
 // Author: Mike Brasher (mbrasher@bmc.com) // Author: Mike Brasher (mbrasher@bmc.com)
 // //
 // Modified By:  // Modified By: Roger Kumpf, Hewlett-Packard Company (roger_kumpf@hp.com)
   //              Carol Ann Krug Graves, Hewlett-Packard Company
   //                (carolann_graves@hp.com)
 // //
 //%///////////////////////////////////////////////////////////////////////////// //%/////////////////////////////////////////////////////////////////////////////
  
 #include <cstring>  
 #include "CIMFlavor.h" #include "CIMFlavor.h"
 #include "Exception.h"  #include <Pegasus/Common/Exception.h>
 #include "XmlWriter.h"  
  
 PEGASUS_NAMESPACE_BEGIN PEGASUS_NAMESPACE_BEGIN
  
 const Uint32 CIMFlavor::NONE = 0;  const CIMFlavor CIMFlavor::NONE = 0;
 const Uint32 CIMFlavor::OVERRIDABLE = 1;  const CIMFlavor CIMFlavor::OVERRIDABLE = 1;
 const Uint32 CIMFlavor::TOSUBCLASS = 2;  const CIMFlavor CIMFlavor::ENABLEOVERRIDE = 1;
 const Uint32 CIMFlavor::TOINSTANCE = 4;  const CIMFlavor CIMFlavor::TOSUBCLASS = 2;
 const Uint32 CIMFlavor::TRANSLATABLE = 8;  const CIMFlavor CIMFlavor::TOINSTANCE = 4;
 const Uint32 CIMFlavor::DEFAULTS = OVERRIDABLE | TOSUBCLASS;  const CIMFlavor CIMFlavor::TRANSLATABLE = 8;
   const CIMFlavor CIMFlavor::TOSUBELEMENTS = TOSUBCLASS + TOINSTANCE;
 static const char* _toString(Boolean x)  const CIMFlavor CIMFlavor::DISABLEOVERRIDE = 16;
 {  const CIMFlavor CIMFlavor::RESTRICTED = 32;
     return x ? "true" : "false";  const CIMFlavor CIMFlavor::DEFAULTS = OVERRIDABLE + TOSUBCLASS;
 }  // ATTN: P1 KS 24 March 2002 Change here to make TOINSTANCE part of the defaults
 /** FlavorToMof Convert the Qualifier flavors to a string of MOF  //const CIMFlavor CIMFlavor::DEFAULTS = OVERRIDABLE + TOSUBCLASS + TOINSTANCE;
     flavor keywords.  const CIMFlavor CIMFlavor::ALL =
                    OVERRIDABLE + TOSUBCLASS + TOINSTANCE + TRANSLATABLE +
   <pre>                   DISABLEOVERRIDE + RESTRICTED;
   Keyword            Function                             Default  
     EnableOverride  Qualifier is overridable.               yes  
     DisableOverride Qualifier cannot be overriden.          no  
     ToSubclass      Qualifier is inherited by any subclass. yes  
     Restricted      Qualifier applies only to the class     no  
                     in which it is declared  
     Translatable    Indicates the value of the qualifier  
                     can be specified inmultiple languages   no  
     NOTE: There is an open issue with the keyword toinstance.  
   
     flavor            = ENABLEOVERRIDE | DISABLEOVERRIDE | RESTRICTED |  
                         TOSUBCLASS | TRANSLATABLE  
     DISABLEOVERRIDE   = "disableOverride"  
   
     ENABLEOVERRIDE    = "enableoverride"  
   
     RESTRICTED        = "restricted"  
   
     TOSUBCLASS        = "tosubclass"  
   
     TRANSLATABLE      = "translatable"  
    </pre>  
    The keyword toinstance is not in the CIMspecification and so is not  
    included in out output..  
 */  
 String FlavorToMof(Uint32 flavor)  
 {  
     Boolean overridable = (flavor & CIMFlavor::OVERRIDABLE) != 0;  
     Boolean toSubClass = (flavor & CIMFlavor::TOSUBCLASS) != 0;  
     Boolean toInstance = (flavor & CIMFlavor::TOINSTANCE) != 0;  
     Boolean translatable = (flavor & CIMFlavor::TRANSLATABLE) != 0;  
  
     String tmp;  
  
     tmp = "";  CIMFlavor::CIMFlavor ()
       : cimFlavor (CIMFlavor::NONE.cimFlavor)
   {
   }
  
     if (overridable)  CIMFlavor::CIMFlavor (const CIMFlavor & flavor)
         tmp += "EnableOverride, ";      : cimFlavor (flavor.cimFlavor)
     else  {
         tmp += "DisableOverride, ";  }
  
     if (!toSubClass)  CIMFlavor::CIMFlavor (const Uint32 flavor)
         tmp += "Restricted, ";      : cimFlavor (flavor)
   {
       //
       //  Test that no undefined bits are set
       //
       //  Note that conflicting bits may be set in the Uint32 flavor
       //  For example, OVERRIDABLE and DISABLEOVERRIDE may both be set
       //  or TOSUBCLASS and RESTRICTED may both be set
       //  Currently, the flavor is not checked for these conflicts
       //  That is corrected later when a CIMQualifierDecl object is constructed
       //  with the CIMFlavor object
       //
       PEGASUS_ASSERT (flavor < 64);
   }
  
     /* this is not a legal MOF flavor  CIMFlavor & CIMFlavor::operator= (const CIMFlavor & flavor)
     if (toInstance)  {
         tmp += "TOINSTANCE ";      this->cimFlavor = flavor.cimFlavor;
     */      return *this;
   }
  
     if (translatable)  void CIMFlavor::addFlavor (const CIMFlavor & flavor)
         tmp += "Translatable, ";  {
       this->cimFlavor |= flavor.cimFlavor;
   }
  
     if (tmp.size())  void CIMFlavor::removeFlavor (const CIMFlavor & flavor)
         tmp.remove(tmp.size() - 2);  {
       this->cimFlavor &= (~flavor.cimFlavor);
   }
  
     return tmp;  Boolean CIMFlavor::hasFlavor (const CIMFlavor & flavor) const
   {
       return ((this->cimFlavor & flavor.cimFlavor) == flavor.cimFlavor) ?
           true : false;
 } }
  
 void FlavorToXml(Array<Sint8>& out, Uint32 flavor)  Boolean CIMFlavor::equal (const CIMFlavor & flavor) const
 { {
     Boolean overridable = (flavor & CIMFlavor::OVERRIDABLE) != 0;      return (this->cimFlavor == flavor.cimFlavor) ? true : false;
     Boolean toSubClass = (flavor & CIMFlavor::TOSUBCLASS) != 0;  }
     Boolean toInstance = (flavor & CIMFlavor::TOINSTANCE) != 0;  
     Boolean translatable = (flavor & CIMFlavor::TRANSLATABLE) != 0;  
  
     if (!overridable)  CIMFlavor CIMFlavor::operator+ (const CIMFlavor & flavor) const
         out << " OVERRIDABLE=\"" << _toString(overridable) << "\"";  {
       return CIMFlavor(this->cimFlavor | flavor.cimFlavor);
   }
  
     if (!toSubClass)  String CIMFlavor::toString () const
         out << " TOSUBCLASS=\"" << _toString(toSubClass) << "\"";  {
       String tmp;
  
     if (toInstance)      if (this->hasFlavor (CIMFlavor::OVERRIDABLE))
         out << " TOINSTANCE=\"" << _toString(toInstance) << "\"";          tmp += "OVERRIDABLE ";
  
     if (translatable)      if (this->hasFlavor (CIMFlavor::TOSUBCLASS))
         out << " TRANSLATABLE=\"" << _toString(translatable) << "\"";          tmp += "TOSUBCLASS ";
 }  
  
       if (this->hasFlavor (CIMFlavor::TOINSTANCE))
           tmp += "TOINSTANCE ";
   
       if (this->hasFlavor (CIMFlavor::TRANSLATABLE))
           tmp += "TRANSLATABLE ";
   
       if (this->hasFlavor (CIMFlavor::DISABLEOVERRIDE))
           tmp += "DISABLEOVERRIDE ";
   
       if (this->hasFlavor (CIMFlavor::RESTRICTED))
           tmp += "RESTRICTED ";
   
       if (tmp.size ())
           tmp.remove (tmp.size () - 1);
   
       return tmp;
   }
  
 PEGASUS_NAMESPACE_END PEGASUS_NAMESPACE_END


Legend:
Removed from v.1.10  
changed lines
  Added in v.1.17

No CVS admin address has been configured
Powered by
ViewCVS 0.9.2