Loading...
Searching...
No Matches
OSchema.h
Go to the documentation of this file.
//-*****************************************************************************
//
// Copyright (c) 2009-2012,
// 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_OSchema_h
#define Alembic_Abc_OSchema_h
#include <Alembic/Abc/Foundation.h>
#include <Alembic/Abc/OCompoundProperty.h>
namespace Alembic {
namespace Abc {
namespace ALEMBIC_VERSION_NS {
//-*****************************************************************************
//-*****************************************************************************
//-*****************************************************************************
//-*****************************************************************************
#define ALEMBIC_ABC_DECLARE_SCHEMA_INFO( STITLE, SBTYP, SDFLT, SPREP, STDEF ) \
struct STDEF \
{ \
static const char * title() { return ( STITLE ) ; } \
static const char * defaultName() { return ( SDFLT ); } \
static const char * schemaBaseType() { return ( SBTYP ); } \
static bool replaceOnSparse() { return SPREP; } \
}
//-*****************************************************************************
template <class INFO>
class OSchema : public OCompoundProperty
{
public:
//-*************************************************************************
// TYPEDEFS AND IDENTIFIERS
//-*************************************************************************
typedef INFO info_type;
typedef OSchema<INFO> this_type;
static const char * getSchemaTitle()
{
return INFO::title();
}
static const char * getSchemaBaseType()
{
return INFO::schemaBaseType();
}
static const char * getDefaultSchemaName()
{
return INFO::defaultName();
}
static bool replaceOnSparse()
{
return INFO::replaceOnSparse();
}
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
//-*************************************************************************
OSchema() {}
OSchema( AbcA::CompoundPropertyWriterPtr iParent,
const std::string &iName,
const Argument &iArg0 = Argument(),
const Argument &iArg1 = Argument(),
const Argument &iArg2 = Argument(),
const Argument &iArg3 = Argument() )
{
this_type::init( iParent, iName, iArg0, iArg1, iArg2, iArg3 );
}
OSchema( OCompoundProperty iParent,
const std::string &iName,
const Argument &iArg0 = Argument(),
const Argument &iArg1 = Argument(),
const Argument &iArg2 = Argument() )
{
*this = OSchema( iParent.getPtr(), iName,
GetErrorHandlerPolicy( iParent ), iArg0, iArg1, iArg2);
}
virtual ~OSchema() {}
private:
void init( AbcA::CompoundPropertyWriterPtr iParent,
const std::string &iName,
const Argument &iArg0,
const Argument &iArg1,
const Argument &iArg2,
const Argument &iArg3 );
};
//-*****************************************************************************
// TEMPLATE AND INLINE FUNCTIONS
//-*****************************************************************************
template <class INFO>
void OSchema<INFO>::init( AbcA::CompoundPropertyWriterPtr iParent,
const std::string &iName,
const Argument &iArg0,
const Argument &iArg1,
const Argument &iArg2,
const Argument &iArg3 )
{
Arguments args;
iArg0.setInto( args );
iArg1.setInto( args );
iArg2.setInto( args );
iArg3.setInto( args );
getErrorHandler().setPolicy( args.getErrorHandlerPolicy() );
ALEMBIC_ABC_SAFE_CALL_BEGIN( "OSchema::OSchema::init()" );
// Get actual writer for parent.
ABCA_ASSERT( iParent,
"NULL parent passed into OSchema ctor" );
// Put schema title into metadata.
AbcA::MetaData mdata = args.getMetaData();
std::string emptyStr;
if ( emptyStr != getSchemaTitle() && !args.isSparse() )
{
mdata.set( "schema", getSchemaTitle() );
}
if ( emptyStr != getSchemaBaseType() && !args.isSparse() )
{
mdata.set( "schemaBaseType", getSchemaBaseType() );
}
// Create property.
m_property = iParent->createCompoundProperty( iName, mdata );
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
OCompoundProperty.h
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::getMetaData
const AbcA::MetaData & getMetaData() const
Definition Argument.h:86
Alembic::Abc::ALEMBIC_VERSION_NS::Arguments::isSparse
bool isSparse() const
Definition Argument.h:98
Alembic::Abc::ALEMBIC_VERSION_NS::Arguments::getErrorHandlerPolicy
ErrorHandler::Policy getErrorHandlerPolicy() const
Definition Argument.h:83
Alembic::Abc::ALEMBIC_VERSION_NS::OBasePropertyT::getPtr
PROP_PTR getPtr() const
Definition OBaseProperty.h:162
Alembic::Abc::ALEMBIC_VERSION_NS::OCompoundProperty::OCompoundProperty
OCompoundProperty()
Definition OCompoundProperty.h:65
Alembic::Abc::ALEMBIC_VERSION_NS::OSchema::OSchema
OSchema(AbcA::CompoundPropertyWriterPtr iParent, const std::string &iName, const Argument &iArg0=Argument(), const Argument &iArg1=Argument(), const Argument &iArg2=Argument(), const Argument &iArg3=Argument())
Definition OSchema.h:195
Alembic::Abc::ALEMBIC_VERSION_NS::OSchema::~OSchema
virtual ~OSchema()
Definition OSchema.h:219
Alembic::Abc::ALEMBIC_VERSION_NS::OSchema::getDefaultSchemaName
static const char * getDefaultSchemaName()
Definition OSchema.h:144
Alembic::Abc::ALEMBIC_VERSION_NS::OSchema::OSchema
OSchema(OCompoundProperty iParent, const std::string &iName, const Argument &iArg0=Argument(), const Argument &iArg1=Argument(), const Argument &iArg2=Argument())
Definition OSchema.h:208
Alembic::Abc::ALEMBIC_VERSION_NS::OSchema::matches
static bool matches(const AbcA::MetaData &iMetaData, SchemaInterpMatching iMatching=kStrictMatching)
Definition OSchema.h:162
Alembic::Abc::ALEMBIC_VERSION_NS::OSchema::info_type
INFO info_type
Definition OSchema.h:125
Alembic::Abc::ALEMBIC_VERSION_NS::OSchema::matches
static bool matches(const AbcA::PropertyHeader &iHeader, SchemaInterpMatching iMatching=kStrictMatching)
Definition OSchema.h:179
Alembic::Abc::ALEMBIC_VERSION_NS::OSchema::OSchema
OSchema()
Definition OSchema.h:191
Alembic::Abc::ALEMBIC_VERSION_NS::OSchema::this_type
OSchema< INFO > this_type
Definition OSchema.h:126
Alembic::Abc::ALEMBIC_VERSION_NS::OSchema::getSchemaTitle
static const char * getSchemaTitle()
Definition OSchema.h:130
Alembic::Abc::ALEMBIC_VERSION_NS::OSchema::getSchemaBaseType
static const char * getSchemaBaseType()
Definition OSchema.h:137
Alembic::Abc::ALEMBIC_VERSION_NS::OSchema::replaceOnSparse
static bool replaceOnSparse()
Definition OSchema.h:154
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
Definition ArchiveInfo.h:47
Alembic
Alembic namespace ...
Definition ArchiveInfo.h:46