Loading...
Searching...
No Matches
IObject.h
Go to the documentation of this file.
//-*****************************************************************************
//
// Copyright (c) 2009-2013,
// Sony Pictures Imageworks, Inc. and
// Industrial Light & Magic, a division of Lucasfilm Entertainment Company Ltd.
//
// All rights reserved.
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are
// met:
// * Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
// * Redistributions in binary form must reproduce the above
// copyright notice, this list of conditions and the following disclaimer
// in the documentation and/or other materials provided with the
// distribution.
// * Neither the name of Sony Pictures Imageworks, nor
// Industrial Light & Magic nor the names of their contributors may be used
// to endorse or promote products derived from this software without specific
// prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
//
//-*****************************************************************************
#ifndef Alembic_Abc_IObject_h
#define Alembic_Abc_IObject_h
#include <Alembic/Util/Export.h>
#include <Alembic/Abc/Foundation.h>
#include <Alembic/Abc/Base.h>
#include <Alembic/Abc/Argument.h>
#include <Alembic/Abc/IArchive.h>
namespace Alembic {
namespace Abc {
namespace ALEMBIC_VERSION_NS {
class ICompoundProperty;
//-*****************************************************************************
class ALEMBIC_EXPORT IObject : public Base
{
public:
typedef IObject this_type;
typedef IObject operator_bool_base_type;
//-*************************************************************************
// CONSTRUCTION, DESTRUCTION, ASSIGNMENT
//-*************************************************************************
IObject() {}
IObject( const IObject & iParent,
const std::string &iName,
const Argument &iArg0 = Argument() )
{
init( iParent.getPtr(),
iName,
GetErrorHandlerPolicy( iParent, iArg0 ) );
initInstance();
}
IObject( AbcA::ObjectReaderPtr iPtr,
const Argument &iArg0 = Argument() )
: m_object( GetObjectReaderPtr( iPtr ) )
{
// Set the error handling policy
getErrorHandler().setPolicy(
GetErrorHandlerPolicy( iPtr, iArg0 ) );
initInstance();
}
// Deprecated in favor of the constructor above
IObject( AbcA::ObjectReaderPtr iPtr,
WrapExistingFlag /* iFlag */,
const Argument &iArg0 = Argument() )
: m_object( GetObjectReaderPtr( iPtr ) )
{
// Set the error handling policy
getErrorHandler().setPolicy(
GetErrorHandlerPolicy( iPtr, iArg0 ) );
initInstance();
}
IObject( IArchive & iArchive,
const Argument &iArg0 = Argument() )
{
init( iArchive, iArg0 );
}
// Deprecated in favor of the constructor above
IObject( IArchive & iArchive,
TopFlag iFlag,
const Argument &iArg0 = Argument() )
{
init( iArchive, iArg0 );
}
virtual ~IObject();
//-*************************************************************************
// OBJECT READER FUNCTIONALITY
//-*************************************************************************
const AbcA::ObjectHeader &getHeader() const;
const std::string &getName() const;
const std::string &getFullName() const;
const AbcA::MetaData &getMetaData() const
{ return getHeader().getMetaData(); }
IArchive getArchive() const;
IObject getParent() const;
size_t getNumChildren() const;
const AbcA::ObjectHeader & getChildHeader( size_t i ) const;
const AbcA::ObjectHeader *
getChildHeader( const std::string &iName ) const;
ICompoundProperty getProperties() const;
//-*************************************************************************
// ADVANCED TOOLS
// Unless you really know why you need to be using these next few
// functions, they're probably best left alone. The right way to create
// an IObject is to actually call its constructor.
//-*************************************************************************
IObject getChild( size_t iChildIndex ) const;
IObject getChild( const std::string &iChildName ) const;
// INSTANCE METHODS
// An IObject can refer to another IObject in the same cache and stand in
// as an instance for that target hierarchy. On disk only the instance
// object is required. When read in however, a normal hierarchy is
// returned. Optionally, client code could use the isInstanceRoot() and
// instanceSourcePath() methods to discover that the hierarchies are
// duplicate and instance them appropriately in memory.
bool isInstanceRoot() const;
bool isInstanceDescendant() const;
std::string instanceSourcePath() const;
bool isChildInstance(size_t iChildIndex) const;
bool isChildInstance(const std::string &iChildName) const;
AbcA::ObjectReaderPtr getInstancePtr() const { return m_instanceObject; }
//-*************************************************************************
// ABC BASE MECHANISMS
// These functions are used by Abc to deal with errors, rewrapping,
// and so on.
//-*************************************************************************
AbcA::ObjectReaderPtr getPtr() const { return m_object; }
void reset();
bool valid() const
{
return ( Base::valid() && m_object );
}
bool getPropertiesHash( Util::Digest & oDigest );
bool getChildrenHash( Util::Digest & oDigest );
ALEMBIC_OPERATOR_BOOL( valid() );
public:
AbcA::ObjectReaderPtr m_object;
private:
void init( IArchive & iArchive, const Argument &iArg0 );
void init( AbcA::ObjectReaderPtr iParentObject,
const std::string &iName,
ErrorHandler::Policy iPolicy );
void initInstance();
void setInstancedFullName(const std::string& parentPath) const;
// This is the "original" object when it is an instance (not the source)
AbcA::ObjectReaderPtr m_instanceObject;
// All IObject ancestors of an instance object have these set.
mutable std::string m_instancedFullName;
};
typedef Alembic::Util::shared_ptr< IObject > IObjectPtr;
//-*****************************************************************************
inline AbcA::ObjectReaderPtr
GetObjectReaderPtr( IObject& iPrp ) { return iPrp.getPtr(); }
//-*****************************************************************************
// TEMPLATE AND INLINE FUNCTIONS
//-*****************************************************************************
template <class OBJ>
inline ErrorHandler::Policy GetErrorHandlerPolicy( OBJ iObj,
ErrorHandler::Policy iPcy )
{
Argument arg( iPcy );
return GetErrorHandlerPolicy( iObj, arg );
}
} // End namespace ALEMBIC_VERSION_NS
using namespace ALEMBIC_VERSION_NS;
} // End namespace Abc
} // End namespace Alembic
#endif
Foundation.h
Argument.h
Base.h
Export.h
ALEMBIC_EXPORT
#define ALEMBIC_EXPORT
Definition Export.h:51
IArchive.h
ALEMBIC_VERSION_NS
#define ALEMBIC_VERSION_NS
Definition Foundation.h:105
Alembic::Abc::ALEMBIC_VERSION_NS::Argument
Definition Argument.h:120
Alembic::Abc::ALEMBIC_VERSION_NS::Base::valid
bool valid() const
Definition Base.h:65
Alembic::Abc::ALEMBIC_VERSION_NS::Base::getErrorHandler
ErrorHandler & getErrorHandler() const
Definition Base.h:76
Alembic::Abc::ALEMBIC_VERSION_NS::Base::Base
Base()
Definition Base.h:51
Alembic::Abc::ALEMBIC_VERSION_NS::ErrorHandler::Policy
Policy
Definition ErrorHandler.h:52
Alembic::Abc::ALEMBIC_VERSION_NS::IArchive
Definition IArchive.h:53
Alembic::Abc::ALEMBIC_VERSION_NS::ICompoundProperty
Definition ICompoundProperty.h:53
Alembic::Abc::ALEMBIC_VERSION_NS::IObject
Definition IObject.h:54
Alembic::Abc::ALEMBIC_VERSION_NS::IObject::IObject
IObject()
Definition IObject.h:68
Alembic::Abc::ALEMBIC_VERSION_NS::IObject::getChildHeader
const AbcA::ObjectHeader & getChildHeader(size_t i) const
Alembic::Abc::ALEMBIC_VERSION_NS::IObject::getName
const std::string & getName() const
Alembic::Abc::ALEMBIC_VERSION_NS::IObject::getChildHeader
const AbcA::ObjectHeader * getChildHeader(const std::string &iName) const
Alembic::Abc::ALEMBIC_VERSION_NS::IObject::getChild
IObject getChild(const std::string &iChildName) const
Alembic::Abc::ALEMBIC_VERSION_NS::IObject::isInstanceDescendant
bool isInstanceDescendant() const
Alembic::Abc::ALEMBIC_VERSION_NS::IObject::ALEMBIC_OPERATOR_BOOL
ALEMBIC_OPERATOR_BOOL(valid())
Alembic::Abc::ALEMBIC_VERSION_NS::IObject::isChildInstance
bool isChildInstance(const std::string &iChildName) const
Alembic::Abc::ALEMBIC_VERSION_NS::IObject::getHeader
const AbcA::ObjectHeader & getHeader() const
Alembic::Abc::ALEMBIC_VERSION_NS::IObject::getPropertiesHash
bool getPropertiesHash(Util::Digest &oDigest)
Alembic::Abc::ALEMBIC_VERSION_NS::IObject::getPtr
AbcA::ObjectReaderPtr getPtr() const
Definition IObject.h:244
Alembic::Abc::ALEMBIC_VERSION_NS::IObject::getArchive
IArchive getArchive() const
Alembic::Abc::ALEMBIC_VERSION_NS::IObject::IObject
IObject(AbcA::ObjectReaderPtr iPtr, const Argument &iArg0=Argument())
Definition IObject.h:87
Alembic::Abc::ALEMBIC_VERSION_NS::IObject::IObject
IObject(IArchive &iArchive, TopFlag iFlag, const Argument &iArg0=Argument())
Definition IObject.h:120
Alembic::Abc::ALEMBIC_VERSION_NS::IObject::getNumChildren
size_t getNumChildren() const
Alembic::Abc::ALEMBIC_VERSION_NS::IObject::getProperties
ICompoundProperty getProperties() const
Alembic::Abc::ALEMBIC_VERSION_NS::IObject::getChildrenHash
bool getChildrenHash(Util::Digest &oDigest)
Alembic::Abc::ALEMBIC_VERSION_NS::IObject::instanceSourcePath
std::string instanceSourcePath() const
Alembic::Abc::ALEMBIC_VERSION_NS::IObject::IObject
IObject(const IObject &iParent, const std::string &iName, const Argument &iArg0=Argument())
Definition IObject.h:74
Alembic::Abc::ALEMBIC_VERSION_NS::IObject::getFullName
const std::string & getFullName() const
Alembic::Abc::ALEMBIC_VERSION_NS::IObject::IObject
IObject(AbcA::ObjectReaderPtr iPtr, WrapExistingFlag, const Argument &iArg0=Argument())
Definition IObject.h:99
Alembic::Abc::ALEMBIC_VERSION_NS::IObject::isChildInstance
bool isChildInstance(size_t iChildIndex) const
Alembic::Abc::ALEMBIC_VERSION_NS::IObject::m_object
AbcA::ObjectReaderPtr m_object
Definition IObject.h:269
Alembic::Abc::ALEMBIC_VERSION_NS::IObject::getInstancePtr
AbcA::ObjectReaderPtr getInstancePtr() const
Returns the original ObjectReaderPtr, if this object is an instance.
Definition IObject.h:232
Alembic::Abc::ALEMBIC_VERSION_NS::IObject::getMetaData
const AbcA::MetaData & getMetaData() const
Definition IObject.h:161
Alembic::Abc::ALEMBIC_VERSION_NS::IObject::reset
void reset()
Reset returns this function set to an empty, default state.
Alembic::Abc::ALEMBIC_VERSION_NS::IObject::getParent
IObject getParent() const
Alembic::Abc::ALEMBIC_VERSION_NS::IObject::IObject
IObject(IArchive &iArchive, const Argument &iArg0=Argument())
Definition IObject.h:113
Alembic::Abc::ALEMBIC_VERSION_NS::IObject::this_type
IObject this_type
Definition IObject.h:59
Alembic::Abc::ALEMBIC_VERSION_NS::IObject::valid
bool valid() const
Definition IObject.h:251
Alembic::Abc::ALEMBIC_VERSION_NS::IObject::isInstanceRoot
bool isInstanceRoot() const
-************************************************************************
Alembic::Abc::ALEMBIC_VERSION_NS::IObject::operator_bool_base_type
IObject operator_bool_base_type
Definition IObject.h:60
Alembic::Abc::ALEMBIC_VERSION_NS::IObject::~IObject
virtual ~IObject()
Alembic::Abc::ALEMBIC_VERSION_NS::IObject::getChild
IObject getChild(size_t iChildIndex) const
Alembic::Abc::ALEMBIC_VERSION_NS
Definition ArchiveInfo.h:48
Alembic::Abc::ALEMBIC_VERSION_NS::IObjectPtr
Alembic::Util::shared_ptr< IObject > IObjectPtr
Definition IObject.h:290
Alembic::Abc::ALEMBIC_VERSION_NS::GetErrorHandlerPolicy
ErrorHandler::Policy GetErrorHandlerPolicy(SOMETHING iSomething, const Argument &iArg0, const Argument &iArg1=Argument(), const Argument &iArg2=Argument(), const Argument &iArg3=Argument())
Definition Argument.h:242
Alembic::Abc::ALEMBIC_VERSION_NS::WrapExistingFlag
WrapExistingFlag
Definition Foundation.h:94
Alembic::Abc::ALEMBIC_VERSION_NS::TopFlag
TopFlag
Definition Foundation.h:104
Alembic::Abc::ALEMBIC_VERSION_NS::GetObjectReaderPtr
AbcA::ObjectReaderPtr GetObjectReaderPtr(AbcA::ObjectReaderPtr iPtr)
Definition Foundation.h:200
Alembic::Abc
Definition ArchiveInfo.h:47
Alembic
Alembic namespace ...
Definition ArchiveInfo.h:46
Alembic::Util::ALEMBIC_VERSION_NS::Digest
Definition Digest.h:51