Alembic: Abc/OObject.h Source File

Alembic 1.8.11

Loading...
Searching...
No Matches
OObject.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_OObject_h
38#define Alembic_Abc_OObject_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/OArchive.h>
45
46namespace Alembic {
47namespace Abc {
48namespace ALEMBIC_VERSION_NS {
49
50class OCompoundProperty;
51
52//-*****************************************************************************
53 class ALEMBIC_EXPORT OObject : public Base
54{
55public:
59 typedef OObject this_type;
60 typedef OObject operator_bool_base_type;
61
62 //-*************************************************************************
63 // CONSTRUCTION, DESTRUCTION, ASSIGNMENT
64 //-*************************************************************************
65
68 OObject() {}
69
74 OObject( OObject iParentObject,
75 const std::string &iName,
76
77 const Argument &iArg0 = Argument(),
78 const Argument &iArg1 = Argument(),
79 const Argument &iArg2 = Argument() );
80
84 OObject( AbcA::ObjectWriterPtr iPtr,
85 const Argument &iArg0 = Argument(),
86 const Argument &iArg1 = Argument(),
87 const Argument &iArg2 = Argument() )
88 : m_object( iPtr )
89 {
90 // Set the error handling policy
91 getErrorHandler().setPolicy(
92 GetErrorHandlerPolicy( iPtr, iArg0, iArg1, iArg2 ) );
93 }
94
95 // Deprecated in favor of the constructor above
96 OObject( AbcA::ObjectWriterPtr iPtr,
97 WrapExistingFlag /* iFlag */,
98 const Argument &iArg0 = Argument(),
99 const Argument &iArg1 = Argument(),
100 const Argument &iArg2 = Argument() )
101 : m_object( iPtr )
102 {
103 // Set the error handling policy
104 getErrorHandler().setPolicy(
105 GetErrorHandlerPolicy( iPtr, iArg0, iArg1, iArg2 ) );
106 }
107
111 OObject( OArchive & iArchive,
112 const Argument &iArg0 = Argument(),
113 const Argument &iArg1 = Argument(),
114 const Argument &iArg2 = Argument() )
115 {
116 init( iArchive, iArg0, iArg1, iArg2 );
117 }
118
119 // deprecated in favor of the constructor above
120 OObject( OArchive & iArchive,
121 TopFlag /* iTop */,
122 const Argument &iArg0 = Argument(),
123 const Argument &iArg1 = Argument(),
124 const Argument &iArg2 = Argument() )
125 {
126 init( iArchive, iArg0, iArg1, iArg2 );
127 }
128
131
134 virtual ~OObject();
135
136 //-*************************************************************************
137 // OBJECT WRITER FUNCTIONALITY
138 //-*************************************************************************
139
142 const AbcA::ObjectHeader & getHeader() const;
143
146 const std::string &getName() const
147 { return getHeader().getName(); }
148
151 const std::string &getFullName() const
152 { return getHeader().getFullName(); }
153
156 const AbcA::MetaData &getMetaData() const
157 { return getHeader().getMetaData(); }
158
161 OArchive getArchive();
162
166 OObject getParent();
167
171 size_t getNumChildren();
172
175 const AbcA::ObjectHeader & getChildHeader( size_t i );
176
179 const AbcA::ObjectHeader * getChildHeader( const std::string &iName );
180
183 OCompoundProperty getProperties();
184
185 //-*************************************************************************
186 // ADVANCED TOOLS
187 // Unless you really know why you need to be using these next few
188 // functions, they're probably best left alone. These functions attempt
189 // to find a pointer to an existing writer, instead of creating a new one.
190 //-*************************************************************************
191
196 OObject getChild( size_t iChildIndex );
197
202 OObject getChild( const std::string &iChildName );
203
205 // PROXY METHODS
206 // An OObject can refer to another OObject. When read in, this instance
207 // will be represented by the target source hierarchy and its children.
209 bool addChildInstance( OObject iTarget, const std::string& iName );
210
211 //-*************************************************************************
212 // ABC BASE MECHANISMS
213 // These functions are used by Abc to deal with errors, rewrapping,
214 // and so on.
215 //-*************************************************************************
216
220 AbcA::ObjectWriterPtr getPtr() { return m_object; }
221 const AbcA::ObjectWriterPtr getPtr() const { return m_object; }
222
225 void reset() { m_object.reset(); Base::reset(); }
226
229 bool valid() const
230 {
231 return ( Base::valid() && m_object );
232 }
233
236 ALEMBIC_OPERATOR_BOOL( valid() );
237
238private:
239
240 void init( OArchive & iArchive,
241 const Argument &iArg0,
242 const Argument &iArg1,
243 const Argument &iArg2 );
244
245 void init( AbcA::ObjectWriterPtr iParentObject,
246 const std::string &iName,
247 ErrorHandler::Policy iParentPolicy,
248
249 const Argument &iArg0,
250 const Argument &iArg1,
251 const Argument &iARg2 );
252
253protected:
254 AbcA::ObjectWriterPtr m_object;
255};
256
257} // End namespace ALEMBIC_VERSION_NS
258
259using namespace ALEMBIC_VERSION_NS;
260
261} // End namespace Abc
262} // End namespace Alembic
263
264#endif
Alembic::Abc::ALEMBIC_VERSION_NS::Argument
Definition Argument.h:120
Alembic::Abc::ALEMBIC_VERSION_NS::OArchive
Definition OArchive.h:53
Alembic::Abc::ALEMBIC_VERSION_NS::OCompoundProperty
Definition OCompoundProperty.h:53
Alembic::Abc::ALEMBIC_VERSION_NS::OObject
Definition OObject.h:54
Alembic::Abc::ALEMBIC_VERSION_NS::OObject::OObject
OObject()
Definition OObject.h:68
Alembic::Abc::ALEMBIC_VERSION_NS::OObject::OObject
OObject(OArchive &iArchive, const Argument &iArg0=Argument(), const Argument &iArg1=Argument(), const Argument &iArg2=Argument())
Definition OObject.h:111
Alembic::Abc::ALEMBIC_VERSION_NS::OObject::ALEMBIC_OPERATOR_BOOL
ALEMBIC_OPERATOR_BOOL(valid())
Alembic::Abc::ALEMBIC_VERSION_NS::OObject::getName
const std::string & getName() const
Definition OObject.h:146
Alembic::Abc::ALEMBIC_VERSION_NS::OObject::getPtr
AbcA::ObjectWriterPtr getPtr()
Definition OObject.h:220
Alembic::Abc::ALEMBIC_VERSION_NS::OObject::getHeader
const AbcA::ObjectHeader & getHeader() const
Definition OObject.cpp:78
Alembic::Abc::ALEMBIC_VERSION_NS::OObject::getMetaData
const AbcA::MetaData & getMetaData() const
Definition OObject.h:156
Alembic::Abc::ALEMBIC_VERSION_NS::OObject::reset
void reset()
Definition OObject.h:225
Alembic::Abc::ALEMBIC_VERSION_NS::OObject::this_type
OObject this_type
Definition OObject.h:59
Alembic::Abc::ALEMBIC_VERSION_NS::OObject::valid
bool valid() const
Definition OObject.h:229
Alembic::Abc::ALEMBIC_VERSION_NS::OObject::OObject
OObject(AbcA::ObjectWriterPtr iPtr, const Argument &iArg0=Argument(), const Argument &iArg1=Argument(), const Argument &iArg2=Argument())
Definition OObject.h:84
Alembic::Abc::ALEMBIC_VERSION_NS::OObject::getFullName
const std::string & getFullName() const
Definition OObject.h:151
Alembic
Alembic namespace ...
Definition ArchiveInfo.cpp:39