Alembic Version 1.1
Loading...
Searching...
No Matches
OSchema.h
Go to the documentation of this file.
1//-*****************************************************************************
2//
3// Copyright (c) 2009-2012,
4// Sony Pictures Imageworks, Inc. and
5// Industrial Light & Magic, a division of Lucasfilm Entertainment Company Ltd.
6//
7// All rights reserved.
8//
9// Redistribution and use in source and binary forms, with or without
10// modification, are permitted provided that the following conditions are
11// met:
12// * Redistributions of source code must retain the above copyright
13// notice, this list of conditions and the following disclaimer.
14// * Redistributions in binary form must reproduce the above
15// copyright notice, this list of conditions and the following disclaimer
16// in the documentation and/or other materials provided with the
17// distribution.
18// * Neither the name of Sony Pictures Imageworks, nor
19// Industrial Light & Magic nor the names of their contributors may be used
20// to endorse or promote products derived from this software without specific
21// prior written permission.
22//
23// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
24// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
25// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
26// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
27// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
28// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
29// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
30// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
31// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
32// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
33// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34//
35//-*****************************************************************************
36
37#ifndef Alembic_Abc_OSchema_h
38#define Alembic_Abc_OSchema_h
39
42
43namespace Alembic {
44namespace Abc {
45namespace ALEMBIC_VERSION_NS {
46
47//-*****************************************************************************
72//-*****************************************************************************
73
74
75//-*****************************************************************************
89
90
91//-*****************************************************************************
105#define ALEMBIC_ABC_DECLARE_SCHEMA_INFO( STITLE, SBTYP, SDFLT, SPREP, STDEF ) \
106struct STDEF \
107{ \
108 static const char * title() { return ( STITLE ) ; } \
109 static const char * defaultName() { return ( SDFLT ); } \
110 static const char * schemaBaseType() { return ( SBTYP ); } \
111 static bool replaceOnSparse() { return SPREP; } \
112}
113
114//-*****************************************************************************
117template <class INFO>
119{
120public:
121 //-*************************************************************************
122 // TYPEDEFS AND IDENTIFIERS
123 //-*************************************************************************
124
125 typedef INFO info_type;
127
130 static const char * getSchemaTitle()
131 {
132 return INFO::title();
133 }
134
137 static const char * getSchemaBaseType()
138 {
139 return INFO::schemaBaseType();
140 }
141
144 static const char * getDefaultSchemaName()
145 {
146 return INFO::defaultName();
147 }
148
154 static bool replaceOnSparse()
155 {
156 return INFO::replaceOnSparse();
157 }
158
162 static bool matches( const AbcA::MetaData &iMetaData,
164 {
165 if ( std::string() == getSchemaTitle() || iMatching == kNoMatching )
166 { return true; }
167
168 if ( iMatching == kStrictMatching || iMatching == kSchemaTitleMatching )
169 {
170 return iMetaData.get( "schema" ) == getSchemaTitle();
171 }
172
173 return false;
174 }
175
179 static bool matches( const AbcA::PropertyHeader &iHeader,
181 {
182 return matches( iHeader.getMetaData(), iMatching );
183 }
184
185 //-*************************************************************************
186 // CONSTRUCTION, DESTRUCTION, ASSIGNMENT
187 //-*************************************************************************
188
192
196 const std::string &iName,
197
198 const Argument &iArg0 = Argument(),
199 const Argument &iArg1 = Argument(),
200 const Argument &iArg2 = Argument(),
201 const Argument &iArg3 = Argument() )
202 {
203 this_type::init( iParent, iName, iArg0, iArg1, iArg2, iArg3 );
204 }
205
209 const std::string &iName,
210
211 const Argument &iArg0 = Argument(),
212 const Argument &iArg1 = Argument(),
213 const Argument &iArg2 = Argument() )
214 {
215 *this = OSchema( iParent.getPtr(), iName,
216 GetErrorHandlerPolicy( iParent ), iArg0, iArg1, iArg2);
217 }
218
219 virtual ~OSchema() {}
220
223
224private:
225 void init( AbcA::CompoundPropertyWriterPtr iParent,
226 const std::string &iName,
227 const Argument &iArg0,
228 const Argument &iArg1,
229 const Argument &iArg2,
230 const Argument &iArg3 );
231};
232
233//-*****************************************************************************
234// TEMPLATE AND INLINE FUNCTIONS
235//-*****************************************************************************
236template <class INFO>
238 const std::string &iName,
239 const Argument &iArg0,
240 const Argument &iArg1,
241 const Argument &iArg2,
242 const Argument &iArg3 )
243{
244 Arguments args;
245 iArg0.setInto( args );
246 iArg1.setInto( args );
247 iArg2.setInto( args );
248 iArg3.setInto( args );
249
250 getErrorHandler().setPolicy( args.getErrorHandlerPolicy() );
251
252 ALEMBIC_ABC_SAFE_CALL_BEGIN( "OSchema::OSchema::init()" );
253
254
255 // Get actual writer for parent.
256 ABCA_ASSERT( iParent,
257 "NULL parent passed into OSchema ctor" );
258
259 // Put schema title into metadata.
260 AbcA::MetaData mdata = args.getMetaData();
261 std::string emptyStr;
262 if ( emptyStr != getSchemaTitle() && !args.isSparse() )
263 {
264 mdata.set( "schema", getSchemaTitle() );
265 }
266 if ( emptyStr != getSchemaBaseType() && !args.isSparse() )
267 {
268 mdata.set( "schemaBaseType", getSchemaBaseType() );
269 }
270
271 // Create property.
272 m_property = iParent->createCompoundProperty( iName, mdata );
273
275}
276
277} // End namespace ALEMBIC_VERSION_NS
278
279using namespace ALEMBIC_VERSION_NS;
280
281} // End namespace Abc
282} // End namespace Alembic
283
284#endif
#define ABCA_ASSERT(COND, TEXT)
Definition Foundation.h:99
#define ALEMBIC_ABC_SAFE_CALL_BEGIN(CONTEXT)
#define ALEMBIC_ABC_SAFE_CALL_END_RESET()
#define ALEMBIC_VERSION_NS
Definition Foundation.h:105
std::string get(const std::string &iKey) const
Definition MetaData.h:192
void set(const std::string &iKey, const std::string &iData)
Definition MetaData.h:168
void setInto(Arguments &iArgs) const
Definition Argument.h:149
const AbcA::MetaData & getMetaData() const
Definition Argument.h:86
ErrorHandler::Policy getErrorHandlerPolicy() const
Definition Argument.h:83
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
static const char * getDefaultSchemaName()
Definition OSchema.h:144
OSchema(OCompoundProperty iParent, const std::string &iName, const Argument &iArg0=Argument(), const Argument &iArg1=Argument(), const Argument &iArg2=Argument())
Definition OSchema.h:208
static bool matches(const AbcA::MetaData &iMetaData, SchemaInterpMatching iMatching=kStrictMatching)
Definition OSchema.h:162
static bool matches(const AbcA::PropertyHeader &iHeader, SchemaInterpMatching iMatching=kStrictMatching)
Definition OSchema.h:179
static const char * getSchemaTitle()
Definition OSchema.h:130
static const char * getSchemaBaseType()
Definition OSchema.h:137
Alembic::Util::shared_ptr< CompoundPropertyWriter > CompoundPropertyWriterPtr
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 namespace ...
Definition ArchiveInfo.h:46