HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
ICompoundProperty.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_ICompoundProperty_h_
38 #define _Alembic_Abc_ICompoundProperty_h_
39 
40 #include <Alembic/Util/Export.h>
41 #include <Alembic/Abc/Foundation.h>
42 #include <Alembic/Abc/Argument.h>
43 #include <Alembic/Abc/Base.h>
45 
46 namespace Alembic {
47 namespace Abc {
48 namespace ALEMBIC_VERSION_NS {
49 
50 //-*****************************************************************************
52  : public IBasePropertyT<AbcA::CompoundPropertyReaderPtr>
53 {
54 public:
55  //! By convention we always define this_type in Abc classes
56  //! Used by unspecified-bool-type conversion below
58 
59  //-*************************************************************************
60  // CONSTRUCTION, DESTRUCTION, ASSIGNMENT
61  //-*************************************************************************
62 
63  //! The default constructor creates an empty ICompoundProperty function set.
64  //! ...
66 
67  //! This templated, explicit function creates a new compound property
68  //! reader. The first argument is any Abc (or AbcCoreAbstract) object
69  //! which can intrusively be converted to an CompoundPropertyReaderPtr
70  //! to use as a parent, from which the error handler policy for
71  //! inheritance is also derived. The remaining optional arguments
72  //! can be used to override the ErrorHandlerPolicy
73  template <class CPROP_PTR>
74  ICompoundProperty( CPROP_PTR iParentProp,
75  const std::string &iName,
76  const Argument &iArg0 = Argument() );
77 
78  //! This attaches an ICompoundProperty wrapper around an existing
79  //! CompoundPropertyReaderPtr, with an optional error handling policy.
80  //!
81  //! The extra argument is to support ISchema, which is publicly derived
82  //! from ICompoundProperty (see ISchema.h).
83  template <class CPROP_PTR>
85  CPROP_PTR iThisObject,
86  WrapExistingFlag /* iWrapFlag */,
87  const Argument &iArg0 = Argument(),
88  const Argument &iArg1 = Argument() );
89 
90  //! This attaches an ICompoundProperty wrapper around the top
91  //! properties of any object, with an optional error handling policy.
92  //!
93  //! The extra argument is to support ISchema, which is publicly derived
94  //! from ICompoundProperty (see ISchema.h).
95  template <class OBJECT_PTR>
97  OBJECT_PTR iThisObject,
98  TopFlag /* iTopFlag */,
99  const Argument &iArg0 = Argument(),
100  const Argument &iArg1 = Argument() );
101 
102  //! Default copy constructor used
103  //! Default assignment operator used.
104 
105  //! Destructor
106  //! ...
108 
109  //-*************************************************************************
110  // COMPOUND PROPERTY READER FUNCTIONALITY
111  //-*************************************************************************
112 
113  //! Returns the number of properties contained in this ICompoundProperty
114  size_t getNumProperties() const;
115 
116  //! Return the header of a child property.
117  //! Property is selected by index.
118  //! This will throw an exception on out-of-range access.
119  const AbcA::PropertyHeader & getPropertyHeader( size_t i ) const;
120 
121  //! Return the header of a property name.
122  //! This will return a NULL pointer if no header by that name is found.
123  const AbcA::PropertyHeader *
124  getPropertyHeader( const std::string &iName ) const;
125 
126  //! There is no distinction between already added properties
127  //! and created properties with an AbcA::CompoundPropertyReader, therefore
128  //! we have no need to expose "getProperty". Simply use the appropriate
129  //! IScalarProperty, ICompoundProperty, or IArrayProperty
130  //! wrappers.
131 
132  //! Return the parent compound property, handily wrapped in a
133  //! ICompoundProperty wrapper.
134  ICompoundProperty getParent() const;
135 
136 private:
137  void init( AbcA::CompoundPropertyReaderPtr iParentObject,
138  const std::string &iName,
139 
140  ErrorHandler::Policy iParentPolicy,
141 
142  const Argument &iArg0 );
143 };
144 
145 //-*****************************************************************************
148 ( ICompoundProperty &iPrp ) { return iPrp.getPtr(); }
149 
150 //-*****************************************************************************
151 // TEMPLATE AND INLINE FUNCTIONS
152 //-*****************************************************************************
153 
154 //-*****************************************************************************
155 template <class CPROP_PTR>
156 inline ICompoundProperty::ICompoundProperty( CPROP_PTR iParentProp,
157  const std::string &iName,
158  const Argument &iArg0 )
159 {
160  init( GetCompoundPropertyReaderPtr( iParentProp ),
161  iName,
162 
163  GetErrorHandlerPolicy( iParentProp ),
164  iArg0 );
165 }
166 
167 //-*****************************************************************************
168 template <class CPROP_PTR>
169 inline ICompoundProperty::ICompoundProperty( CPROP_PTR iThisObject,
170  WrapExistingFlag iWrap,
171  const Argument &iArg0,
172  const Argument &iArg1 )
174  GetCompoundPropertyReaderPtr( iThisObject ),
175  iWrap,
176  GetErrorHandlerPolicy( iThisObject, iArg0, iArg1 ) )
177 {
178  // Nothing!
179 }
180 
181 //-*****************************************************************************
182 template <class OBJECT_PTR>
183 inline ICompoundProperty::ICompoundProperty( OBJECT_PTR iThisObject,
184  TopFlag /* iTop */,
185  const Argument &iArg0,
186  const Argument &iArg1 )
187 {
189  GetErrorHandlerPolicy( iThisObject, iArg0, iArg1 ) );
190 
192  "ICompoundProperty::ICompoundProperty( top )" );
193 
194  m_property = GetObjectReaderPtr( iThisObject )->getProperties();
195 
197 }
198 
199 
200 } // End namespace ALEMBIC_VERSION_NS
201 
202 using namespace ALEMBIC_VERSION_NS;
203 
204 } // End namespace Abc
205 } // End namespace Alembic
206 
207 #endif
ErrorHandler::Policy GetErrorHandlerPolicy(SOMETHING iSomething, const Argument &iArg0, const Argument &iArg1=Argument(), const Argument &iArg2=Argument())
Definition: Argument.h:219
GLsizei const GLchar *const * string
Definition: glcorearb.h:813
png_uint_32 i
Definition: png.h:2877
Alembic::Util::shared_ptr< CompoundPropertyReader > CompoundPropertyReaderPtr
#define ALEMBIC_ABC_SAFE_CALL_END_RESET()
Definition: ErrorHandler.h:181
AbcA::ObjectReaderPtr GetObjectReaderPtr(AbcA::ObjectReaderPtr iPtr)
Definition: Foundation.h:190
#define ALEMBIC_ABC_SAFE_CALL_BEGIN(CONTEXT)
Definition: ErrorHandler.h:172
ErrorHandler & getErrorHandler() const
Definition: Base.h:76
AbcA::CompoundPropertyReaderPtr GetCompoundPropertyReaderPtr(AbcA::CompoundPropertyReaderPtr iPtr)
Definition: Foundation.h:171
#define ALEMBIC_EXPORT
Definition: Export.h:51
#define ALEMBIC_VERSION_NS
Definition: Foundation.h:104