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

File: [Pegasus] / pegasus / src / Pegasus / Common / CIMObject.cpp (download)
Revision: 1.45, Wed Oct 22 07:19:40 2008 UTC (15 years, 8 months ago) by thilo.boehm
Branch: MAIN
Changes since 1.44: +41 -15 lines
BUG#: 8023
TITLE: Performance rework reference count in common CIM classes

DESCRIPTION: Re-implementation of reference counting for Common/CIM*Rep classes.

//%2006////////////////////////////////////////////////////////////////////////
//
// 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.
// Copyright (c) 2006 Hewlett-Packard Development Company, L.P.; IBM Corp.;
// EMC Corporation; Symantec Corporation; The Open Group.
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to
// deal in the Software without restriction, including without limitation the
// rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
// sell copies of the Software, and to permit persons to whom the Software is
// 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.
//
//==============================================================================
//
//%/////////////////////////////////////////////////////////////////////////////

#include "CIMClassRep.h"
#include "CIMInstanceRep.h"
#include "CIMObjectRep.h"
#include "CIMObject.h"
#include "CIMClass.h"
#include "CIMInstance.h"
#include "XmlWriter.h"

PEGASUS_NAMESPACE_BEGIN

#define PEGASUS_ARRAY_T CIMObject
# include "ArrayImpl.h"
#undef PEGASUS_ARRAY_T

////////////////////////////////////////////////////////////////////////////////
//
// CIMObject
//
////////////////////////////////////////////////////////////////////////////////

CIMObject::CIMObject()
    : _rep(0)
{
}

CIMObject::CIMObject(const CIMObject& x)
{
    _rep = x._rep;
    if (_rep)
        _rep->Inc();
}

CIMObject::CIMObject(const CIMClass& x)
{
    _rep = x._rep;
    if (_rep)
        _rep->Inc();
}

CIMObject::CIMObject(const CIMInstance& x)
{
    _rep = x._rep;
    if (_rep)
        _rep->Inc();
}

CIMObject::CIMObject(CIMObjectRep* rep)
    : _rep(rep)
{
}

CIMObject& CIMObject::operator=(const CIMObject& x)
{
    if (x._rep != _rep)
    {
        if (_rep)
            _rep->Dec();
        _rep = x._rep;
        if (_rep)
            _rep->Inc();
    }
    return *this;
}

CIMObject::~CIMObject()
{
    if (_rep)
        _rep->Dec();
}

const CIMName& CIMObject::getClassName() const
{
    CheckRep(_rep);
    return _rep->getClassName();
}

const CIMObjectPath& CIMObject::getPath() const
{
    CheckRep(_rep);
    return _rep->getPath();
}

void CIMObject::setPath(const CIMObjectPath & path)
{
    CheckRep(_rep);
    _rep->setPath(path);
}

CIMObject& CIMObject::addQualifier(const CIMQualifier& qualifier)
{
    CheckRep(_rep);
    _rep->addQualifier(qualifier);
    return *this;
}

Uint32 CIMObject::findQualifier(const CIMName& name) const
{
    CheckRep(_rep);
    return _rep->findQualifier(name);
}

CIMQualifier CIMObject::getQualifier(Uint32 index)
{
    CheckRep(_rep);
    return _rep->getQualifier(index);
}

CIMConstQualifier CIMObject::getQualifier(Uint32 index) const
{
    CheckRep(_rep);
    return _rep->getQualifier(index);
}

void CIMObject::removeQualifier(Uint32 index)
{
    CheckRep(_rep);
    _rep->removeQualifier(index);
}

Uint32 CIMObject::getQualifierCount() const
{
    CheckRep(_rep);
    return _rep->getQualifierCount();
}

CIMObject& CIMObject::addProperty(const CIMProperty& x)
{
    CheckRep(_rep);
    _rep->addProperty(x);
    return *this;
}

Uint32 CIMObject::findProperty(const CIMName& name) const
{
    CheckRep(_rep);
    return _rep->findProperty(name);
}

CIMProperty CIMObject::getProperty(Uint32 index)
{
    CheckRep(_rep);
    return _rep->getProperty(index);
}

CIMConstProperty CIMObject::getProperty(Uint32 index) const
{
    CheckRep(_rep);
    return _rep->getProperty(index);
}

void CIMObject::removeProperty(Uint32 index)
{
    CheckRep(_rep);
    _rep->removeProperty(index);
}

Uint32 CIMObject::getPropertyCount() const
{
    CheckRep(_rep);
    return _rep->getPropertyCount();
}

Boolean CIMObject::isUninitialized() const
{
    return _rep == 0;
}

String CIMObject::toString() const
{
    CheckRep(_rep);
    Buffer out;

    XmlWriter::appendObjectElement(out, *this);

    return out.getData();
}

Boolean CIMObject::isClass() const
{
    return Boolean(dynamic_cast<CIMClassRep*>(this->_rep));
}

Boolean CIMObject::isInstance() const
{
    return Boolean(dynamic_cast<CIMInstanceRep*>(this->_rep));
}

Boolean CIMObject::identical(const CIMConstObject& x) const
{
    CheckRep(x._rep);
    CheckRep(_rep);
    return _rep->identical(x._rep);
}

CIMObject CIMObject::clone() const
{
    CheckRep(_rep);
    return CIMObject(_rep->clone());
}


////////////////////////////////////////////////////////////////////////////////
//
// CIMConstObject
//
////////////////////////////////////////////////////////////////////////////////

CIMConstObject::CIMConstObject()
    : _rep(0)
{
}

CIMConstObject::CIMConstObject(const CIMConstObject& x)
{
    _rep = x._rep;
    if (_rep)
        _rep->Inc();
}

CIMConstObject::CIMConstObject(const CIMObject& x)
{
    _rep = x._rep;
    if (_rep)
        _rep->Inc();
}

CIMConstObject::CIMConstObject(const CIMClass& x)
{
    _rep = x._rep;
    if (_rep)
        _rep->Inc();
}

CIMConstObject::CIMConstObject(const CIMConstClass& x)
{
    _rep = x._rep;
    if (_rep)
        _rep->Inc();
}

CIMConstObject::CIMConstObject(const CIMInstance& x)
{
    _rep = x._rep;
    if (_rep)
        _rep->Inc();
}

CIMConstObject::CIMConstObject(const CIMConstInstance& x)
{
    _rep = x._rep;
    if (_rep)
        _rep->Inc();
}

CIMConstObject& CIMConstObject::operator=(const CIMConstObject& x)
{
    if (x._rep != _rep)
    {
        if (_rep)
            _rep->Dec();
        _rep = x._rep;
        if (_rep)
            _rep->Inc();
    }
    return *this;
}

CIMConstObject::~CIMConstObject()
{
    if (_rep)
        _rep->Dec();
}

const CIMName& CIMConstObject::getClassName() const
{
    CheckRep(_rep);
    return _rep->getClassName();
}

const CIMObjectPath& CIMConstObject::getPath() const
{
    CheckRep(_rep);
    return _rep->getPath();
}

Uint32 CIMConstObject::findQualifier(const CIMName& name) const
{
    CheckRep(_rep);
    return _rep->findQualifier(name);
}

CIMConstQualifier CIMConstObject::getQualifier(Uint32 index) const
{
    CheckRep(_rep);
    return _rep->getQualifier(index);
}

Uint32 CIMConstObject::getQualifierCount() const
{
    CheckRep(_rep);
    return _rep->getQualifierCount();
}

Uint32 CIMConstObject::findProperty(const CIMName& name) const
{
    CheckRep(_rep);
    return _rep->findProperty(name);
}

CIMConstProperty CIMConstObject::getProperty(Uint32 index) const
{
    CheckRep(_rep);
    return _rep->getProperty(index);
}

Uint32 CIMConstObject::getPropertyCount() const
{
    CheckRep(_rep);
    return _rep->getPropertyCount();
}

Boolean CIMConstObject::isUninitialized() const
{
    return _rep == 0;
}

String CIMConstObject::toString() const
{
    CheckRep(_rep);
    Buffer out;

    XmlWriter::appendObjectElement(out, *this);

    return out.getData();
}

Boolean CIMConstObject::isClass() const
{
    return Boolean(dynamic_cast<CIMClassRep*>(this->_rep));
}

Boolean CIMConstObject::isInstance() const
{
    return Boolean(dynamic_cast<CIMInstanceRep*>(this->_rep));
}

Boolean CIMConstObject::identical(const CIMConstObject& x) const
{
    CheckRep(x._rep);
    CheckRep(_rep);
    return _rep->identical(x._rep);
}

CIMObject CIMConstObject::clone() const
{
    return CIMObject(_rep->clone());
}

PEGASUS_NAMESPACE_END

No CVS admin address has been configured
Powered by
ViewCVS 0.9.2