version 1.2, 2001/04/04 20:02:27
|
version 1.17, 2002/08/14 21:09:00
|
|
|
//BEGIN_LICENSE |
//%///////////////////////////////////////////////////////////////////////////// |
// | // |
// Copyright (c) 2000 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 |
// Permission is hereby granted, free of charge, to any person obtaining a copy |
// copy of this software and associated documentation files (the "Software"), |
// of this software and associated documentation files (the "Software"), to |
// to deal in the Software without restriction, including without limitation |
// deal in the Software without restriction, including without limitation the |
// the rights to use, copy, modify, merge, publish, distribute, sublicense, |
// rights to use, copy, modify, merge, publish, distribute, sublicense, and/or |
// and/or sell copies of the Software, and to permit persons to whom the |
// sell copies of the Software, and to permit persons to whom the Software is |
// Software is furnished to do so, subject to the following conditions: |
// furnished to do so, subject to the following conditions: |
|
// |
|
// THE ABOVE COPYRIGHT NOTICE AND THIS PERMISSION NOTICE SHALL BE INCLUDED IN |
|
// ALL COPIES OR SUBSTANTIAL PORTIONS OF THE SOFTWARE. THE SOFTWARE IS PROVIDED |
|
// "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT |
|
// LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR |
|
// PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT |
|
// HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN |
|
// ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION |
|
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. |
|
// |
|
//============================================================================== |
|
// |
|
// Author: Mike Brasher (mbrasher@bmc.com) |
|
// |
|
// Modified By: Roger Kumpf, Hewlett-Packard Company (roger_kumpf@hp.com) |
|
// Carol Ann Krug Graves, Hewlett-Packard Company |
|
// (carolann_graves@hp.com) |
// | // |
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR |
//%///////////////////////////////////////////////////////////////////////////// |
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, |
|
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL |
#include "CIMFlavor.h" |
// THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER |
#include <Pegasus/Common/Exception.h> |
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING |
|
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER |
PEGASUS_NAMESPACE_BEGIN |
// DEALINGS IN THE SOFTWARE. |
|
// |
const CIMFlavor CIMFlavor::NONE = 0; |
//END_LICENSE |
const CIMFlavor CIMFlavor::OVERRIDABLE = 1; |
//BEGIN_HISTORY |
const CIMFlavor CIMFlavor::ENABLEOVERRIDE = 1; |
// |
const CIMFlavor CIMFlavor::TOSUBCLASS = 2; |
// Author: |
const CIMFlavor CIMFlavor::TOINSTANCE = 4; |
// |
const CIMFlavor CIMFlavor::TRANSLATABLE = 8; |
// $Log$ |
const CIMFlavor CIMFlavor::TOSUBELEMENTS = TOSUBCLASS + TOINSTANCE; |
// Revision 1.2 2001/04/04 20:02:27 karl |
const CIMFlavor CIMFlavor::DISABLEOVERRIDE = 16; |
// documentation update |
const CIMFlavor CIMFlavor::RESTRICTED = 32; |
// |
const CIMFlavor CIMFlavor::DEFAULTS = OVERRIDABLE + TOSUBCLASS; |
// Revision 1.1 2001/02/16 02:07:06 mike |
// ATTN: P1 KS 24 March 2002 Change here to make TOINSTANCE part of the defaults |
// Renamed many classes and headers (using new CIM prefixes). |
//const CIMFlavor CIMFlavor::DEFAULTS = OVERRIDABLE + TOSUBCLASS + TOINSTANCE; |
|
const CIMFlavor CIMFlavor::ALL = |
|
OVERRIDABLE + TOSUBCLASS + TOINSTANCE + TRANSLATABLE + |
|
DISABLEOVERRIDE + RESTRICTED; |
|
|
|
|
|
CIMFlavor::CIMFlavor () |
|
: cimFlavor (CIMFlavor::NONE.cimFlavor) |
|
{ |
|
} |
|
|
|
CIMFlavor::CIMFlavor (const CIMFlavor & flavor) |
|
: cimFlavor (flavor.cimFlavor) |
|
{ |
|
} |
|
|
|
CIMFlavor::CIMFlavor (const Uint32 flavor) |
|
: cimFlavor (flavor) |
|
{ |
// | // |
// Revision 1.1.1.1 2001/01/14 19:51:52 mike |
// Test that no undefined bits are set |
// Pegasus import |
|
// | // |
|
// 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 |
// | // |
//END_HISTORY |
PEGASUS_ASSERT (flavor < 64); |
|
} |
| |
#include <cstring> |
CIMFlavor & CIMFlavor::operator= (const CIMFlavor & flavor) |
#include "CIMFlavor.h" |
{ |
#include "Exception.h" |
this->cimFlavor = flavor.cimFlavor; |
#include "XmlWriter.h" |
return *this; |
|
} |
| |
PEGASUS_NAMESPACE_BEGIN |
void CIMFlavor::addFlavor (const CIMFlavor & flavor) |
|
{ |
|
this->cimFlavor |= flavor.cimFlavor; |
|
} |
| |
const Uint32 CIMFlavor::NONE = 0; |
void CIMFlavor::removeFlavor (const CIMFlavor & flavor) |
const Uint32 CIMFlavor::OVERRIDABLE = 1; |
{ |
const Uint32 CIMFlavor::TOSUBCLASS = 2; |
this->cimFlavor &= (~flavor.cimFlavor); |
const Uint32 CIMFlavor::TOINSTANCE = 4; |
} |
const Uint32 CIMFlavor::TRANSLATABLE = 8; |
|
const Uint32 CIMFlavor::DEFAULTS = OVERRIDABLE | TOSUBCLASS; |
|
| |
static const char* _toString(Boolean x) |
Boolean CIMFlavor::hasFlavor (const CIMFlavor & flavor) const |
{ | { |
return x ? "true" : "false"; |
return ((this->cimFlavor & flavor.cimFlavor) == flavor.cimFlavor) ? |
|
true : false; |
} | } |
| |
String FlavorToString(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; |
|
| |
|
CIMFlavor CIMFlavor::operator+ (const CIMFlavor & flavor) const |
|
{ |
|
return CIMFlavor(this->cimFlavor | flavor.cimFlavor); |
|
} |
|
|
|
String CIMFlavor::toString () const |
|
{ |
String tmp; | String tmp; |
| |
if (!overridable) |
if (this->hasFlavor (CIMFlavor::OVERRIDABLE)) |
tmp += "OVERRIDABLE "; | tmp += "OVERRIDABLE "; |
| |
if (!toSubClass) |
if (this->hasFlavor (CIMFlavor::TOSUBCLASS)) |
tmp += "TOSUBCLASS "; | tmp += "TOSUBCLASS "; |
| |
if (toInstance) |
if (this->hasFlavor (CIMFlavor::TOINSTANCE)) |
tmp += "TOINSTANCE "; | tmp += "TOINSTANCE "; |
| |
if (translatable) |
if (this->hasFlavor (CIMFlavor::TRANSLATABLE)) |
tmp += "TRANSLATABLE "; | tmp += "TRANSLATABLE "; |
| |
if (tmp.getLength()) |
if (this->hasFlavor (CIMFlavor::DISABLEOVERRIDE)) |
tmp.remove(tmp.getLength() - 1); |
tmp += "DISABLEOVERRIDE "; |
| |
return tmp; |
if (this->hasFlavor (CIMFlavor::RESTRICTED)) |
} |
tmp += "RESTRICTED "; |
| |
void FlavorToXml(Array<Sint8>& out, Uint32 flavor) |
if (tmp.size ()) |
{ |
tmp.remove (tmp.size () - 1); |
Boolean overridable = (flavor & CIMFlavor::OVERRIDABLE) != 0; |
|
Boolean toSubClass = (flavor & CIMFlavor::TOSUBCLASS) != 0; |
|
Boolean toInstance = (flavor & CIMFlavor::TOINSTANCE) != 0; |
|
Boolean translatable = (flavor & CIMFlavor::TRANSLATABLE) != 0; |
|
| |
if (!overridable) |
return tmp; |
out << " OVERRIDABLE=\"" << _toString(overridable) << "\""; |
|
|
|
if (!toSubClass) |
|
out << " TOSUBCLASS=\"" << _toString(toSubClass) << "\""; |
|
|
|
if (toInstance) |
|
out << " TOINSTANCE=\"" << _toString(toInstance) << "\""; |
|
|
|
if (translatable) |
|
out << " TRANSLATABLE=\"" << _toString(translatable) << "\""; |
|
} | } |
| |
PEGASUS_NAMESPACE_END | PEGASUS_NAMESPACE_END |