Alembic
1.8.11
Toggle main menu visibility
Loading...
Searching...
No Matches
IObject.h
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>
41
#include <Alembic/Abc/Foundation.h>
42
#include <Alembic/Abc/Base.h>
43
#include <Alembic/Abc/Argument.h>
44
#include <Alembic/Abc/IArchive.h>
45
46
namespace
Alembic
{
47
namespace
Abc {
48
namespace
ALEMBIC_VERSION_NS {
49
50
class
ICompoundProperty
;
51
52
//-*****************************************************************************
53
class
ALEMBIC_EXPORT
IObject
:
public
Base
54
{
55
public
:
59
typedef
IObject
this_type
;
60
typedef
IObject
operator_bool_base_type;
61
62
//-*************************************************************************
63
// CONSTRUCTION, DESTRUCTION, ASSIGNMENT
64
//-*************************************************************************
65
68
IObject
() {}
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
87
IObject
( AbcA::ObjectReaderPtr iPtr,
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
99
IObject
( AbcA::ObjectReaderPtr iPtr,
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
141
const
AbcA::ObjectHeader &getHeader()
const
;
142
147
const
std::string &getName()
const
;
148
153
const
std::string &getFullName()
const
;
154
161
const
AbcA::MetaData &
getMetaData
()
const
162
{
return
getHeader
().getMetaData(); }
163
166
IArchive
getArchive()
const
;
167
171
IObject
getParent()
const
;
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
188
ICompoundProperty
getProperties()
const
;
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
222
bool
isInstanceDescendant()
const
;
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
258
bool
getPropertiesHash(
Util::Digest
& oDigest );
259
262
bool
getChildrenHash(
Util::Digest
& oDigest );
263
266
ALEMBIC_OPERATOR_BOOL
(
valid
() );
267
268
public
:
269
AbcA::ObjectReaderPtr m_object;
270
271
private
:
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
290
typedef
Alembic::Util::shared_ptr< IObject > IObjectPtr;
291
292
//-*****************************************************************************
293
inline
AbcA::ObjectReaderPtr
294
GetObjectReaderPtr(
IObject
& iPrp ) {
return
iPrp.
getPtr
(); }
295
296
//-*****************************************************************************
297
// TEMPLATE AND INLINE FUNCTIONS
298
//-*****************************************************************************
299
300
template
<
class
OBJ>
301
inline
ErrorHandler::Policy GetErrorHandlerPolicy( OBJ iObj,
302
ErrorHandler::Policy iPcy )
303
{
304
Argument
arg( iPcy );
305
return
GetErrorHandlerPolicy( iObj, arg );
306
}
307
308
}
// End namespace ALEMBIC_VERSION_NS
309
310
using namespace
ALEMBIC_VERSION_NS;
311
312
}
// End namespace Abc
313
}
// End namespace Alembic
314
315
#endif
Alembic::Abc::ALEMBIC_VERSION_NS::Argument
Definition
Argument.h:120
Alembic::Abc::ALEMBIC_VERSION_NS::IArchive
Definition
IArchive.h:53
Alembic::Abc::ALEMBIC_VERSION_NS::ICompoundProperty
Definition
ICompoundProperty.h:53
Alembic::Abc::ALEMBIC_VERSION_NS::IObject
Definition
IObject.h:54
Alembic::Abc::ALEMBIC_VERSION_NS::IObject::IObject
IObject()
Definition
IObject.h:68
Alembic::Abc::ALEMBIC_VERSION_NS::IObject::ALEMBIC_OPERATOR_BOOL
ALEMBIC_OPERATOR_BOOL(valid())
Alembic::Abc::ALEMBIC_VERSION_NS::IObject::getHeader
const AbcA::ObjectHeader & getHeader() const
Definition
IObject.cpp:67
Alembic::Abc::ALEMBIC_VERSION_NS::IObject::getPtr
AbcA::ObjectReaderPtr getPtr() const
Definition
IObject.h:244
Alembic::Abc::ALEMBIC_VERSION_NS::IObject::IObject
IObject(AbcA::ObjectReaderPtr iPtr, const Argument &iArg0=Argument())
Definition
IObject.h:87
Alembic::Abc::ALEMBIC_VERSION_NS::IObject::IObject
IObject(const IObject &iParent, const std::string &iName, const Argument &iArg0=Argument())
Definition
IObject.h:74
Alembic::Abc::ALEMBIC_VERSION_NS::IObject::getInstancePtr
AbcA::ObjectReaderPtr getInstancePtr() const
Returns the original ObjectReaderPtr, if this object is an instance.
Definition
IObject.h:232
Alembic::Abc::ALEMBIC_VERSION_NS::IObject::getMetaData
const AbcA::MetaData & getMetaData() const
Definition
IObject.h:161
Alembic::Abc::ALEMBIC_VERSION_NS::IObject::IObject
IObject(IArchive &iArchive, const Argument &iArg0=Argument())
Definition
IObject.h:113
Alembic::Abc::ALEMBIC_VERSION_NS::IObject::this_type
IObject this_type
Definition
IObject.h:59
Alembic::Abc::ALEMBIC_VERSION_NS::IObject::valid
bool valid() const
Definition
IObject.h:251
Alembic
Alembic namespace ...
Definition
ArchiveInfo.cpp:39
Alembic::Util::ALEMBIC_VERSION_NS::Digest
Definition
Digest.h:51
Abc
IObject.h
Generated by
1.18.0