Alembic Version 1.1
Loading...
Searching...
No Matches
IObject.h
Go to the documentation of this file.
1//-*****************************************************************************
2//
3// Copyright (c) 2009-2013,
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_IObject_h
38#define Alembic_Abc_IObject_h
39
40#include <Alembic/Util/Export.h>
42#include <Alembic/Abc/Base.h>
45
46namespace Alembic {
47namespace Abc {
48namespace ALEMBIC_VERSION_NS {
49
50class ICompoundProperty;
51
52//-*****************************************************************************
54{
55public:
61
62 //-*************************************************************************
63 // CONSTRUCTION, DESTRUCTION, ASSIGNMENT
64 //-*************************************************************************
65
69
74 IObject( const IObject & iParent,
75 const std::string &iName,
76 const Argument &iArg0 = Argument() )
77 {
78 init( iParent.getPtr(),
79 iName,
80 GetErrorHandlerPolicy( iParent, iArg0 ) );
81
82 initInstance();
83 }
84
88 const Argument &iArg0 = Argument() )
89 : m_object( GetObjectReaderPtr( iPtr ) )
90 {
91 // Set the error handling policy
92 getErrorHandler().setPolicy(
93 GetErrorHandlerPolicy( iPtr, iArg0 ) );
94
95 initInstance();
96 }
97
98 // Deprecated in favor of the constructor above
100 WrapExistingFlag /* iFlag */,
101 const Argument &iArg0 = Argument() )
102 : m_object( GetObjectReaderPtr( iPtr ) )
103 {
104 // Set the error handling policy
105 getErrorHandler().setPolicy(
106 GetErrorHandlerPolicy( iPtr, iArg0 ) );
107
108 initInstance();
109 }
110
113 IObject( IArchive & iArchive,
114 const Argument &iArg0 = Argument() )
115 {
116 init( iArchive, iArg0 );
117 }
118
119 // Deprecated in favor of the constructor above
120 IObject( IArchive & iArchive,
121 TopFlag iFlag,
122 const Argument &iArg0 = Argument() )
123 {
124 init( iArchive, iArg0 );
125 }
126
129
132 virtual ~IObject();
133
134 //-*************************************************************************
135 // OBJECT READER FUNCTIONALITY
136 //-*************************************************************************
137
142
147 const std::string &getName() const;
148
153 const std::string &getFullName() const;
154
162 { return getHeader().getMetaData(); }
163
167
172
175 size_t getNumChildren() const;
176
179 const AbcA::ObjectHeader & getChildHeader( size_t i ) const;
180
183 const AbcA::ObjectHeader *
184 getChildHeader( const std::string &iName ) const;
185
189
190 //-*************************************************************************
191 // ADVANCED TOOLS
192 // Unless you really know why you need to be using these next few
193 // functions, they're probably best left alone. The right way to create
194 // an IObject is to actually call its constructor.
195 //-*************************************************************************
196
199 IObject getChild( size_t iChildIndex ) const;
200
205 IObject getChild( const std::string &iChildName ) const;
206
208 // INSTANCE METHODS
209 // An IObject can refer to another IObject in the same cache and stand in
210 // as an instance for that target hierarchy. On disk only the instance
211 // object is required. When read in however, a normal hierarchy is
212 // returned. Optionally, client code could use the isInstanceRoot() and
213 // instanceSourcePath() methods to discover that the hierarchies are
214 // duplicate and instance them appropriately in memory.
216
218 bool isInstanceRoot() const;
219
223
226 std::string instanceSourcePath() const;
227
228 bool isChildInstance(size_t iChildIndex) const;
229 bool isChildInstance(const std::string &iChildName) const;
230
232 AbcA::ObjectReaderPtr getInstancePtr() const { return m_instanceObject; }
233
234 //-*************************************************************************
235 // ABC BASE MECHANISMS
236 // These functions are used by Abc to deal with errors, rewrapping,
237 // and so on.
238 //-*************************************************************************
239
244 AbcA::ObjectReaderPtr getPtr() const { return m_object; }
245
247 void reset();
248
251 bool valid() const
252 {
253 return ( Base::valid() && m_object );
254 }
255
259
262 bool getChildrenHash( Util::Digest & oDigest );
263
267
268public:
270
271private:
272
273 void init( IArchive & iArchive, const Argument &iArg0 );
274
275 void init( AbcA::ObjectReaderPtr iParentObject,
276 const std::string &iName,
277 ErrorHandler::Policy iPolicy );
278
279 void initInstance();
280
281 void setInstancedFullName(const std::string& parentPath) const;
282
283 // This is the "original" object when it is an instance (not the source)
284 AbcA::ObjectReaderPtr m_instanceObject;
285
286 // All IObject ancestors of an instance object have these set.
287 mutable std::string m_instancedFullName;
288};
289
290typedef Alembic::Util::shared_ptr< IObject > IObjectPtr;
291
292//-*****************************************************************************
294GetObjectReaderPtr( IObject& iPrp ) { return iPrp.getPtr(); }
295
296//-*****************************************************************************
297// TEMPLATE AND INLINE FUNCTIONS
298//-*****************************************************************************
299
300template <class OBJ>
303{
304 Argument arg( iPcy );
305 return GetErrorHandlerPolicy( iObj, arg );
306}
307
308} // End namespace ALEMBIC_VERSION_NS
309
310using namespace ALEMBIC_VERSION_NS;
311
312} // End namespace Abc
313} // End namespace Alembic
314
315#endif
#define ALEMBIC_EXPORT
Definition Export.h:51
#define ALEMBIC_VERSION_NS
Definition Foundation.h:105
const AbcA::ObjectHeader & getChildHeader(size_t i) const
const std::string & getName() const
const AbcA::ObjectHeader * getChildHeader(const std::string &iName) const
IObject getChild(const std::string &iChildName) const
bool isChildInstance(const std::string &iChildName) const
const AbcA::ObjectHeader & getHeader() const
bool getPropertiesHash(Util::Digest &oDigest)
AbcA::ObjectReaderPtr getPtr() const
Definition IObject.h:244
IObject(AbcA::ObjectReaderPtr iPtr, const Argument &iArg0=Argument())
Definition IObject.h:87
IObject(IArchive &iArchive, TopFlag iFlag, const Argument &iArg0=Argument())
Definition IObject.h:120
ICompoundProperty getProperties() const
bool getChildrenHash(Util::Digest &oDigest)
IObject(const IObject &iParent, const std::string &iName, const Argument &iArg0=Argument())
Definition IObject.h:74
const std::string & getFullName() const
IObject(AbcA::ObjectReaderPtr iPtr, WrapExistingFlag, const Argument &iArg0=Argument())
Definition IObject.h:99
bool isChildInstance(size_t iChildIndex) const
AbcA::ObjectReaderPtr getInstancePtr() const
Returns the original ObjectReaderPtr, if this object is an instance.
Definition IObject.h:232
const AbcA::MetaData & getMetaData() const
Definition IObject.h:161
void reset()
Reset returns this function set to an empty, default state.
IObject(IArchive &iArchive, const Argument &iArg0=Argument())
Definition IObject.h:113
bool isInstanceRoot() const
-************************************************************************
IObject getChild(size_t iChildIndex) const
Alembic::Util::shared_ptr< ObjectReader > ObjectReaderPtr
Alembic::Util::shared_ptr< IObject > IObjectPtr
Definition IObject.h:290
ErrorHandler::Policy GetErrorHandlerPolicy(SOMETHING iSomething, const Argument &iArg0, const Argument &iArg1=Argument(), const Argument &iArg2=Argument(), const Argument &iArg3=Argument())
Definition Argument.h:242
AbcA::ObjectReaderPtr GetObjectReaderPtr(AbcA::ObjectReaderPtr iPtr)
Definition Foundation.h:200
Alembic namespace ...
Definition ArchiveInfo.h:46