Loading...
Searching...
No Matches
ISchema.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_ISchema_h
#define Alembic_Abc_ISchema_h
#include <Alembic/Abc/Foundation.h>
#include <Alembic/Abc/OSchema.h>
#include <Alembic/Abc/ICompoundProperty.h>
namespace Alembic {
namespace Abc {
namespace ALEMBIC_VERSION_NS {
//-*****************************************************************************
//-*****************************************************************************
//-*****************************************************************************
template <class INFO>
class ISchema : public ICompoundProperty
{
public:
//-*************************************************************************
// TYPEDEFS AND IDENTIFIERS
//-*************************************************************************
typedef INFO info_type;
typedef ISchema<INFO> this_type;
static const char * getSchemaTitle()
{
return INFO::title();
}
static const char * getDefaultSchemaName()
{
return INFO::defaultName();
}
static bool matches( const AbcA::MetaData &iMetaData,
SchemaInterpMatching iMatching = kStrictMatching )
{
if ( std::string() == getSchemaTitle() || iMatching == kNoMatching )
{ return true; }
if ( iMatching == kStrictMatching || iMatching == kSchemaTitleMatching )
{
return iMetaData.get( "schema" ) == getSchemaTitle();
}
return false;
}
static bool matches( const AbcA::PropertyHeader &iHeader,
SchemaInterpMatching iMatching = kStrictMatching )
{
return matches( iHeader.getMetaData(), iMatching );
}
//-*************************************************************************
// CONSTRUCTION, DESTRUCTION, ASSIGNMENT
//-*************************************************************************
ISchema() {}
ISchema( const ICompoundProperty &iParent,
const std::string &iName,
const Argument &iArg0 = Argument(),
const Argument &iArg1 = Argument() )
{
init( iParent, iName, iArg0, iArg1 );
}
ISchema( const ICompoundProperty &iProperty,
const Argument &iArg0 = Argument(),
const Argument &iArg1 = Argument() )
: ICompoundProperty( iProperty.getPtr(),
GetErrorHandlerPolicy( iProperty, iArg0, iArg1 ) )
{
ALEMBIC_ABC_SAFE_CALL_BEGIN( "ISchema::ISchema( wrap )" );
const AbcA::PropertyHeader &pheader = this->getHeader();
ABCA_ASSERT( matches( pheader,
GetSchemaInterpMatching( iArg0, iArg1 ) ),
"Incorrect match of schema: "
<< pheader.getMetaData().get( "schema" )
<< " to expected: "
<< INFO::title() );
// not wrapped, we want to use the default name
if ( !iProperty.getParent().valid() )
{
init( iProperty, getDefaultSchemaName(),
iArg0, iArg1 );
}
ALEMBIC_ABC_SAFE_CALL_END_RESET();
}
// Deprecated in favor of the constructor above
ISchema( const ICompoundProperty &iProperty,
WrapExistingFlag iFlag,
const Argument &iArg0 = Argument(),
const Argument &iArg1 = Argument() )
{
*this = ISchema( iProperty, iArg0, iArg1 );
}
//
virtual ~ISchema() {}
private:
void init( const ICompoundProperty & iParentObject,
const std::string &iName,
const Argument &iArg0,
const Argument &iArg1 );
};
//-*****************************************************************************
// TEMPLATE AND INLINE FUNCTIONS
//-*****************************************************************************
template <class INFO>
void ISchema<INFO>::init( const ICompoundProperty & iParent,
const std::string &iName,
const Argument &iArg0,
const Argument &iArg1 )
{
Arguments args;
iArg0.setInto( args );
iArg1.setInto( args );
getErrorHandler().setPolicy( args.getErrorHandlerPolicy() );
ALEMBIC_ABC_SAFE_CALL_BEGIN( "ISchema::ISchema::init()" );
// Get actual reader for parent.
ABCA_ASSERT( iParent,
"NULL parent passed into ISchema ctor" );
AbcA::CompoundPropertyReaderPtr parent = iParent.getPtr();
ABCA_ASSERT( parent, "NULL CompoundPropertyReaderPtr" );
const AbcA::PropertyHeader *pheader = parent->getPropertyHeader( iName );
ABCA_ASSERT( pheader != NULL,
"Nonexistent compound property: " << iName );
// Check metadata for schema.
ABCA_ASSERT( matches( *pheader, args.getSchemaInterpMatching() ),
"Incorrect match of schema: "
<< pheader->getMetaData().get( "schema" )
<< " to expected: "
<< INFO::title() );
// Get property.
m_property = parent->getCompoundProperty( iName );
ALEMBIC_ABC_SAFE_CALL_END_RESET();
}
} // 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
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
ICompoundProperty.h
OSchema.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::IBasePropertyT< AbcA::CompoundPropertyReaderPtr >::getHeader
const AbcA::PropertyHeader & getHeader() const
Definition IBaseProperty.h:192
Alembic::Abc::ALEMBIC_VERSION_NS::IBasePropertyT::valid
bool valid() const
Definition IBaseProperty.h:164
Alembic::Abc::ALEMBIC_VERSION_NS::IBasePropertyT< AbcA::CompoundPropertyReaderPtr >::getPtr
AbcA::CompoundPropertyReaderPtr getPtr() const
Definition IBaseProperty.h:156
Alembic::Abc::ALEMBIC_VERSION_NS::ICompoundProperty
Definition ICompoundProperty.h:53
Alembic::Abc::ALEMBIC_VERSION_NS::ICompoundProperty::ICompoundProperty
ICompoundProperty()
Definition ICompoundProperty.h:65
Alembic::Abc::ALEMBIC_VERSION_NS::ICompoundProperty::getParent
ICompoundProperty getParent() const
Alembic::Abc::ALEMBIC_VERSION_NS::ISchema::matches
static bool matches(const AbcA::PropertyHeader &iHeader, SchemaInterpMatching iMatching=kStrictMatching)
Definition ISchema.h:100
Alembic::Abc::ALEMBIC_VERSION_NS::ISchema::~ISchema
virtual ~ISchema()
Definition ISchema.h:167
Alembic::Abc::ALEMBIC_VERSION_NS::ISchema::getDefaultSchemaName
static const char * getDefaultSchemaName()
Definition ISchema.h:75
Alembic::Abc::ALEMBIC_VERSION_NS::ISchema::matches
static bool matches(const AbcA::MetaData &iMetaData, SchemaInterpMatching iMatching=kStrictMatching)
Definition ISchema.h:83
Alembic::Abc::ALEMBIC_VERSION_NS::ISchema::ISchema
ISchema(const ICompoundProperty &iProperty, const Argument &iArg0=Argument(), const Argument &iArg1=Argument())
Definition ISchema.h:128
Alembic::Abc::ALEMBIC_VERSION_NS::ISchema::this_type
ISchema< INFO > this_type
Definition ISchema.h:64
Alembic::Abc::ALEMBIC_VERSION_NS::ISchema::getSchemaTitle
static const char * getSchemaTitle()
Definition ISchema.h:68
Alembic::Abc::ALEMBIC_VERSION_NS::ISchema::info_type
INFO info_type
Definition ISchema.h:63
Alembic::Abc::ALEMBIC_VERSION_NS::ISchema::ISchema
ISchema(const ICompoundProperty &iParent, const std::string &iName, const Argument &iArg0=Argument(), const Argument &iArg1=Argument())
Definition ISchema.h:117
Alembic::Abc::ALEMBIC_VERSION_NS::ISchema::ISchema
ISchema()
Definition ISchema.h:112
Alembic::Abc::ALEMBIC_VERSION_NS::ISchema::ISchema
ISchema(const ICompoundProperty &iProperty, WrapExistingFlag iFlag, const Argument &iArg0=Argument(), const Argument &iArg1=Argument())
Definition ISchema.h:156
Alembic::Abc::ALEMBIC_VERSION_NS
Definition ArchiveInfo.h:48
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