Loading...
Searching...
No Matches
IObject.h
//-*****************************************************************************
//
// 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
Alembic::Abc::ALEMBIC_VERSION_NS::Argument
Definition Argument.h:120
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::ALEMBIC_OPERATOR_BOOL
ALEMBIC_OPERATOR_BOOL(valid())
Alembic::Abc::ALEMBIC_VERSION_NS::IObject::getHeader
const AbcA::ObjectHeader & getHeader() const
Definition IObject.cpp:67
Alembic::Abc::ALEMBIC_VERSION_NS::IObject::getPtr
AbcA::ObjectReaderPtr getPtr() const
Definition IObject.h:244
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(const IObject &iParent, const std::string &iName, const Argument &iArg0=Argument())
Definition IObject.h:74
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::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
Alembic namespace ...
Definition ArchiveInfo.cpp:39
Alembic::Util::ALEMBIC_VERSION_NS::Digest
Definition Digest.h:51