HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
OCompoundProperty.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_OCompoundProperty_h_
38 #define _Alembic_Abc_OCompoundProperty_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 OBasePropertyT<AbcA::CompoundPropertyWriterPtr>
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 OCompoundProperty function set.
64  //! ...
66 
67  //! This templated, explicit function creates a new scalar property writer.
68  //! The first argument is any Abc (or AbcCoreAbstract) object
69  //! which can intrusively be converted to a CompoundPropertyWriterPtr
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, to specify
73  //! MetaData.
74  template <class CPROP_PTR>
75  OCompoundProperty( CPROP_PTR iParentObject,
76  const std::string &iName,
77 
78  const Argument &iArg0 = Argument(),
79  const Argument &iArg1 = Argument() );
80 
81  //! This attaches an OCompoundProperty wrapper around an existing
82  //! CompoundPropertyWriterPtr, with an optional error handling policy.
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 OCompoundProperty wrapper around the top
91  //! properties of an OObject.
92  template <class OBJECT_PTR>
94  OBJECT_PTR iObject,
95  TopFlag /* iTopFlag */,
96  const Argument &iArg0 = Argument(),
97  const Argument &iArg1 = Argument() );
98 
99  //! Default copy constructor used
100  //! Default assignment operator used.
101 
102  //! Destructor
103  //! ...
105 
106  //-*************************************************************************
107  // COMPOUND PROPERTY WRITER FUNCTIONALITY
108  //-*************************************************************************
109 
110  //! Returns the number of properties that have been created thus far.
111  //! May change as more are created.
112  size_t getNumProperties() const;
113 
114  //! Return the header of a property that has already been added.
115  //! Property is selected by index.
116  //! This will throw an exception on out-of-range access.
117  const AbcA::PropertyHeader & getPropertyHeader( size_t i ) const;
118 
119  //! Return the header of a property that has already been added.
120  //! Property is selected by name.
121  //! This will return NULL if no property with the given name is found.
122  const AbcA::PropertyHeader * getPropertyHeader( const std::string &iName ) const;
123 
124  //! Return a wrapped base property version of an ALREADY ADDED property.
125  //! Will return an empty pointer if the writer for this property
126  //! no longer exists or was never added.
127  //! This would primarily be used for introspection.
128  OBaseProperty getProperty( size_t i ) const;
129 
130  //! Return a wrapped base property version of an ALREADY ADDED property.
131  //! Will return an empty pointer if the writer for this property
132  //! no longer exists or was never added.
133  //! This would primarily be used for introspection.
134  OBaseProperty getProperty( const std::string &iName ) const;
135 
136  //! Return the parent compound property, handily wrapped in a
137  //! OCompoundProperty wrapper.
138  OCompoundProperty getParent() const;
139 
140 private:
141  void init( AbcA::CompoundPropertyWriterPtr iParentObject,
142  const std::string &iName,
143 
144  ErrorHandler::Policy iParentPolicy,
145 
146  const Argument &iArg0,
147  const Argument &iArg1 );
148 };
149 
150 //-*****************************************************************************
153 ( OCompoundProperty iPrp ) { return iPrp.getPtr(); }
154 
155 //-*****************************************************************************
156 // TEMPLATE AND INLINE FUNCTIONS
157 //-*****************************************************************************
158 
159 //-*****************************************************************************
160 template <class CPROP_PTR>
161 inline OCompoundProperty::OCompoundProperty( CPROP_PTR iParentProp,
162  const std::string &iName,
163  const Argument &iArg0,
164  const Argument &iArg1 )
165 {
166  init( GetCompoundPropertyWriterPtr( iParentProp ),
167  iName,
168 
169  GetErrorHandlerPolicy( iParentProp ),
170  iArg0, iArg1 );
171 }
172 
173 //-*****************************************************************************
174 template <class CPROP_PTR>
175 inline OCompoundProperty::OCompoundProperty( CPROP_PTR iThisObject,
176  WrapExistingFlag iWrap,
177  const Argument &iArg0,
178  const Argument &iArg1 )
180  GetCompoundPropertyWriterPtr( iThisObject ),
181  iWrap,
182  GetErrorHandlerPolicy( iThisObject, iArg0, iArg1 ) )
183 {
184  // Nothing!
185 }
186 
187 //-*****************************************************************************
188 template <class OBJECT_PTR>
189 inline OCompoundProperty::OCompoundProperty( OBJECT_PTR iThisObject,
190  TopFlag iTop,
191  const Argument &iArg0,
192  const Argument &iArg1 )
193 {
195  GetErrorHandlerPolicy( iThisObject, iArg0, iArg1 ) );
196 
198  "OCompoundProperty::OCompoundProperty( top )" );
199 
200  m_property = GetObjectWriterPtr( iThisObject )->getProperties();
201 
203 }
204 
205 } // End namespace ALEMBIC_VERSION_NS
206 
207 using namespace ALEMBIC_VERSION_NS;
208 
209 } // End namespace Abc
210 } // End namespace Alembic
211 
212 #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
#define ALEMBIC_ABC_SAFE_CALL_END_RESET()
Definition: ErrorHandler.h:181
AbcA::ObjectWriterPtr GetObjectWriterPtr(AbcA::ObjectWriterPtr iPtr)
Definition: Foundation.h:184
#define ALEMBIC_ABC_SAFE_CALL_BEGIN(CONTEXT)
Definition: ErrorHandler.h:172
ErrorHandler & getErrorHandler() const
Definition: Base.h:76
AbcA::CompoundPropertyWriterPtr GetCompoundPropertyWriterPtr(AbcA::CompoundPropertyWriterPtr iPtr)
Definition: Foundation.h:164
#define ALEMBIC_EXPORT
Definition: Export.h:51
#define ALEMBIC_VERSION_NS
Definition: Foundation.h:104
Alembic::Util::shared_ptr< CompoundPropertyWriter > CompoundPropertyWriterPtr