version 1.8.2.2, 2001/08/06 14:39:03
|
version 1.17, 2002/08/14 21:09:00
|
|
|
//%///////////////////////////////////////////////////////////////////////////// | //%///////////////////////////////////////////////////////////////////////////// |
// | // |
// 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 |
|
|
// | // |
// 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; |
|
| |
if (!overridable) |
CIMFlavor::CIMFlavor () |
tmp += "DisableOverride, "; |
: cimFlavor (CIMFlavor::NONE.cimFlavor) |
|
{ |
|
} |
| |
if (!toSubClass) |
CIMFlavor::CIMFlavor (const CIMFlavor & flavor) |
tmp += "Restricted, "; |
: cimFlavor (flavor.cimFlavor) |
|
{ |
|
} |
| |
/* this is not a legal MOF flavor |
CIMFlavor::CIMFlavor (const Uint32 flavor) |
if (toInstance) |
: cimFlavor (flavor) |
tmp += "TOINSTANCE, "; |
{ |
*/ |
// |
|
// 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); |
|
} |
| |
if (translatable) |
CIMFlavor & CIMFlavor::operator= (const CIMFlavor & flavor) |
tmp += "Translatable, "; |
{ |
|
this->cimFlavor = flavor.cimFlavor; |
|
return *this; |
|
} |
| |
if (tmp.size()) |
void CIMFlavor::addFlavor (const CIMFlavor & flavor) |
tmp.remove(tmp.size() - 2); |
{ |
|
this->cimFlavor |= flavor.cimFlavor; |
|
} |
| |
return tmp; |
void CIMFlavor::removeFlavor (const CIMFlavor & flavor) |
|
{ |
|
this->cimFlavor &= (~flavor.cimFlavor); |
} | } |
| |
void FlavorToXml(Array<Sint8>& out, Uint32 flavor) |
Boolean CIMFlavor::hasFlavor (const CIMFlavor & flavor) const |
{ | { |
Boolean overridable = (flavor & CIMFlavor::OVERRIDABLE) != 0; |
return ((this->cimFlavor & flavor.cimFlavor) == flavor.cimFlavor) ? |
Boolean toSubClass = (flavor & CIMFlavor::TOSUBCLASS) != 0; |
true : false; |
Boolean toInstance = (flavor & CIMFlavor::TOINSTANCE) != 0; |
} |
Boolean translatable = (flavor & CIMFlavor::TRANSLATABLE) != 0; |
|
| |
if (!overridable) |
Boolean CIMFlavor::equal (const CIMFlavor & flavor) const |
out << " OVERRIDABLE=\"" << _toString(overridable) << "\""; |
{ |
|
return (this->cimFlavor == flavor.cimFlavor) ? true : false; |
|
} |
| |
if (!toSubClass) |
CIMFlavor CIMFlavor::operator+ (const CIMFlavor & flavor) const |
out << " TOSUBCLASS=\"" << _toString(toSubClass) << "\""; |
{ |
|
return CIMFlavor(this->cimFlavor | flavor.cimFlavor); |
|
} |
| |
if (toInstance) |
String CIMFlavor::toString () const |
out << " TOINSTANCE=\"" << _toString(toInstance) << "\""; |
{ |
|
String tmp; |
| |
if (translatable) |
if (this->hasFlavor (CIMFlavor::OVERRIDABLE)) |
out << " TRANSLATABLE=\"" << _toString(translatable) << "\""; |
tmp += "OVERRIDABLE "; |
} |
|
|
if (this->hasFlavor (CIMFlavor::TOSUBCLASS)) |
|
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 |