Loading...
Searching...
No Matches
ISchemaObject.h
Go to the documentation of this file.
//-*****************************************************************************
//
// Copyright (c) 2009-2011,
// 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_ISchemaObject_h
#define Alembic_Abc_ISchemaObject_h
#include <Alembic/Abc/Foundation.h>
#include <Alembic/Abc/IObject.h>
#include <Alembic/Abc/ISchema.h>
#include <Alembic/Abc/Argument.h>
#include <Alembic/Abc/Base.h>
namespace Alembic {
namespace Abc {
namespace ALEMBIC_VERSION_NS {
//-*****************************************************************************
template <class SCHEMA>
class ISchemaObject : public IObject
{
public:
//-*************************************************************************
// TYPEDEFS AND IDENTIFIERS
//-*************************************************************************
typedef SCHEMA schema_type;
typedef ISchemaObject<SCHEMA> this_type;
static std::string getSchemaObjTitle()
{
return SCHEMA::getSchemaTitle() + std::string( ":" )
+ SCHEMA::getDefaultSchemaName();
}
static const char * getSchemaTitle()
{
return SCHEMA::getSchemaTitle();
}
static bool matches( const AbcA::MetaData &iMetaData,
SchemaInterpMatching iMatching = kStrictMatching )
{
if ( std::string() == getSchemaTitle() || iMatching == kNoMatching )
{
return true;
}
if ( iMatching == kStrictMatching )
{
return iMetaData.get( "schemaObjTitle" ) == getSchemaObjTitle() ||
iMetaData.get( "schema" ) == getSchemaObjTitle();
}
if ( iMatching == kSchemaTitleMatching )
{
return iMetaData.get( "schema" ) == getSchemaTitle();
}
return false;
}
static bool matches( const AbcA::ObjectHeader &iHeader,
SchemaInterpMatching iMatching = kStrictMatching )
{
return matches( iHeader.getMetaData(), iMatching );
}
//-*************************************************************************
// CONSTRUCTION, DESTRUCTION, ASSIGNMENT
//-*************************************************************************
ISchemaObject() {}
ISchemaObject( const IObject & iParent,
const std::string &iName,
const Argument &iArg0 = Argument(),
const Argument &iArg1 = Argument() )
: IObject( iParent, iName, GetErrorHandlerPolicyFromArgs( iArg0, iArg1 ) )
{
Arguments args;
iArg0.setInto( args );
iArg1.setInto( args );
ALEMBIC_ABC_SAFE_CALL_BEGIN(
"ISchemaObject::ISchemaObject( IObject )" );
const AbcA::ObjectHeader &oheader = this->getHeader();
ABCA_ASSERT( matches( oheader, args.getSchemaInterpMatching() ),
"Incorrect match of schema: "
<< oheader.getMetaData().get( "schema" )
<< " to expected: "
<< getSchemaTitle() );
// Make the schema.
m_schema = SCHEMA( m_object->getProperties(),
SCHEMA::getDefaultSchemaName(),
this->getErrorHandlerPolicy(),
args.getSchemaInterpMatching() );
ALEMBIC_ABC_SAFE_CALL_END_RESET();
}
ISchemaObject( const IObject & iObject,
const Argument &iArg0 = Argument(),
const Argument &iArg1 = Argument() )
: IObject( iObject )
{
getErrorHandler().setPolicy(
GetErrorHandlerPolicy( iObject, iArg0, iArg1 ) );
ALEMBIC_ABC_SAFE_CALL_BEGIN(
"ISchemaObject::ISchemaObject( wrap )" );
const AbcA::ObjectHeader &oheader = this->getHeader();
ABCA_ASSERT( matches( oheader.getMetaData(),
GetSchemaInterpMatching( iArg0, iArg1 ) ),
"Incorrect match of schema: "
<< oheader.getMetaData().get( "schemaObjTitle" )
<< " to expected: "
<< getSchemaObjTitle() );
m_schema = SCHEMA( this->getProperties(),
SCHEMA::getDefaultSchemaName(),
this->getErrorHandlerPolicy(),
GetSchemaInterpMatching( iArg0, iArg1 ) );
ALEMBIC_ABC_SAFE_CALL_END_RESET();
}
// Deprecated in favor of the constructor above
ISchemaObject( const IObject & iObject,
WrapExistingFlag iFlag,
const Argument &iArg0 = Argument(),
const Argument &iArg1 = Argument() )
: IObject( iObject )
{
getErrorHandler().setPolicy(
GetErrorHandlerPolicy( iObject, iArg0, iArg1 ) );
ALEMBIC_ABC_SAFE_CALL_BEGIN(
"ISchemaObject::ISchemaObject( wrapflag )" );
const AbcA::ObjectHeader &oheader = this->getHeader();
ABCA_ASSERT( matches( oheader.getMetaData(),
GetSchemaInterpMatching( iArg0, iArg1 ) ),
"Incorrect match of schema: "
<< oheader.getMetaData().get( "schemaObjTitle" )
<< " to expected: "
<< getSchemaObjTitle() );
m_schema = SCHEMA( this->getProperties(),
SCHEMA::getDefaultSchemaName(),
this->getErrorHandlerPolicy(),
GetSchemaInterpMatching( iArg0, iArg1 ) );
ALEMBIC_ABC_SAFE_CALL_END_RESET();
}
//-*************************************************************************
// ABC BASE MECHANISMS
// These functions are used by Abc to deal with errors, rewrapping,
// and so on.
//-*************************************************************************
SCHEMA &getSchema() { return m_schema; }
const SCHEMA &getSchema() const { return m_schema; }
void reset() { m_schema.reset(); IObject::reset(); }
bool valid() const
{
return ( IObject::valid() && m_schema.valid() );
}
ALEMBIC_OVERRIDE_OPERATOR_BOOL( this_type::valid() );
protected:
SCHEMA m_schema;
};
//-*****************************************************************************
// TEMPLATE AND INLINE FUNCTIONS
//-*****************************************************************************
inline ErrorHandler::Policy GetErrorHandlerPolicy( const Argument &iArg0,
const Argument &iArg1 )
{
Arguments args;
iArg0.setInto( args );
iArg1.setInto( args );
return args.getErrorHandlerPolicy();
}
} // End namespace ALEMBIC_VERSION_NS
using namespace ALEMBIC_VERSION_NS;
} // End namespace Abc
} // End namespace Alembic
#endif
ABCA_ASSERT
#define ABCA_ASSERT(COND, TEXT)
Definition Foundation.h:99
Foundation.h
Argument.h
Base.h
ALEMBIC_ABC_SAFE_CALL_BEGIN
#define ALEMBIC_ABC_SAFE_CALL_BEGIN(CONTEXT)
Definition ErrorHandler.h:172
ALEMBIC_ABC_SAFE_CALL_END_RESET
#define ALEMBIC_ABC_SAFE_CALL_END_RESET()
Definition ErrorHandler.h:181
IObject.h
ISchema.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::Argument::setInto
void setInto(Arguments &iArgs) const
Definition Argument.h:149
Alembic::Abc::ALEMBIC_VERSION_NS::Arguments
Definition Argument.h:49
Alembic::Abc::ALEMBIC_VERSION_NS::Arguments::getSchemaInterpMatching
SchemaInterpMatching getSchemaInterpMatching() const
Definition Argument.h:95
Alembic::Abc::ALEMBIC_VERSION_NS::Arguments::getErrorHandlerPolicy
ErrorHandler::Policy getErrorHandlerPolicy() const
Definition Argument.h:83
Alembic::Abc::ALEMBIC_VERSION_NS::Base::getErrorHandler
ErrorHandler & getErrorHandler() const
Definition Base.h:76
Alembic::Abc::ALEMBIC_VERSION_NS::Base::getErrorHandlerPolicy
ErrorHandler::Policy getErrorHandlerPolicy() const
Definition Base.h:81
Alembic::Abc::ALEMBIC_VERSION_NS::ErrorHandler::setPolicy
void setPolicy(Policy iPolicy)
Definition ErrorHandler.h:84
Alembic::Abc::ALEMBIC_VERSION_NS::ErrorHandler::Policy
Policy
Definition ErrorHandler.h:52
Alembic::Abc::ALEMBIC_VERSION_NS::IObject::IObject
IObject()
Definition IObject.h:68
Alembic::Abc::ALEMBIC_VERSION_NS::IObject::getHeader
const AbcA::ObjectHeader & getHeader() const
Alembic::Abc::ALEMBIC_VERSION_NS::IObject::getProperties
ICompoundProperty getProperties() const
Alembic::Abc::ALEMBIC_VERSION_NS::IObject::m_object
AbcA::ObjectReaderPtr m_object
Definition IObject.h:269
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::valid
bool valid() const
Definition IObject.h:251
Alembic::Abc::ALEMBIC_VERSION_NS::ISchemaObject::this_type
ISchemaObject< SCHEMA > this_type
Definition ISchemaObject.h:62
Alembic::Abc::ALEMBIC_VERSION_NS::ISchemaObject::ISchemaObject
ISchemaObject(const IObject &iObject, const Argument &iArg0=Argument(), const Argument &iArg1=Argument())
Definition ISchemaObject.h:159
Alembic::Abc::ALEMBIC_VERSION_NS::ISchemaObject::ALEMBIC_OVERRIDE_OPERATOR_BOOL
ALEMBIC_OVERRIDE_OPERATOR_BOOL(this_type::valid())
Alembic::Abc::ALEMBIC_VERSION_NS::ISchemaObject::valid
bool valid() const
Definition ISchemaObject.h:234
Alembic::Abc::ALEMBIC_VERSION_NS::ISchemaObject::reset
void reset()
Definition ISchemaObject.h:230
Alembic::Abc::ALEMBIC_VERSION_NS::ISchemaObject::getSchemaObjTitle
static std::string getSchemaObjTitle()
Definition ISchemaObject.h:70
Alembic::Abc::ALEMBIC_VERSION_NS::ISchemaObject::getSchema
SCHEMA & getSchema()
Definition ISchemaObject.h:225
Alembic::Abc::ALEMBIC_VERSION_NS::ISchemaObject::getSchema
const SCHEMA & getSchema() const
Definition ISchemaObject.h:226
Alembic::Abc::ALEMBIC_VERSION_NS::ISchemaObject::ISchemaObject
ISchemaObject(const IObject &iParent, const std::string &iName, const Argument &iArg0=Argument(), const Argument &iArg1=Argument())
The primary constructor creates an ISchemaObject as a child of iParent.
Definition ISchemaObject.h:127
Alembic::Abc::ALEMBIC_VERSION_NS::ISchemaObject::matches
static bool matches(const AbcA::MetaData &iMetaData, SchemaInterpMatching iMatching=kStrictMatching)
Definition ISchemaObject.h:84
Alembic::Abc::ALEMBIC_VERSION_NS::ISchemaObject::schema_type
SCHEMA schema_type
Definition ISchemaObject.h:61
Alembic::Abc::ALEMBIC_VERSION_NS::ISchemaObject::ISchemaObject
ISchemaObject(const IObject &iObject, WrapExistingFlag iFlag, const Argument &iArg0=Argument(), const Argument &iArg1=Argument())
Definition ISchemaObject.h:188
Alembic::Abc::ALEMBIC_VERSION_NS::ISchemaObject::ISchemaObject
ISchemaObject()
Definition ISchemaObject.h:124
Alembic::Abc::ALEMBIC_VERSION_NS::ISchemaObject< ICollectionsSchema >::m_schema
ICollectionsSchema m_schema
Definition ISchemaObject.h:244
Alembic::Abc::ALEMBIC_VERSION_NS::ISchemaObject::getSchemaTitle
static const char * getSchemaTitle()
Definition ISchemaObject.h:76
Alembic::Abc::ALEMBIC_VERSION_NS::ISchemaObject::matches
static bool matches(const AbcA::ObjectHeader &iHeader, SchemaInterpMatching iMatching=kStrictMatching)
Definition ISchemaObject.h:111
Alembic::Abc::ALEMBIC_VERSION_NS
Definition ArchiveInfo.h:48
Alembic::Abc::ALEMBIC_VERSION_NS::GetErrorHandlerPolicyFromArgs
ErrorHandler::Policy GetErrorHandlerPolicyFromArgs(const Argument &iArg0, const Argument &iArg1=Argument(), const Argument &iArg2=Argument(), const Argument &iArg3=Argument())
Definition Argument.h:258
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::SchemaInterpMatching
SchemaInterpMatching
Definition Foundation.h:77
Alembic::Abc::ALEMBIC_VERSION_NS::kSchemaTitleMatching
@ kSchemaTitleMatching
Definition Foundation.h:80
Alembic::Abc::ALEMBIC_VERSION_NS::kNoMatching
@ kNoMatching
Definition Foundation.h:79
Alembic::Abc::ALEMBIC_VERSION_NS::kStrictMatching
@ kStrictMatching
Definition Foundation.h:78
Alembic::Abc::ALEMBIC_VERSION_NS::WrapExistingFlag
WrapExistingFlag
Definition Foundation.h:94
Alembic::Abc::ALEMBIC_VERSION_NS::GetSchemaInterpMatching
SchemaInterpMatching GetSchemaInterpMatching(const Argument &iArg0, const Argument &iArg1=Argument(), const Argument &iArg2=Argument(), const Argument &iArg3=Argument())
Definition Argument.h:318
Alembic::Abc
Definition ArchiveInfo.h:47
Alembic
Alembic namespace ...
Definition ArchiveInfo.h:46