HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
OArrayProperty.h
Go to the documentation of this file.
1 //-*****************************************************************************
2 //
3 // Copyright (c) 2009-2011,
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 #ifndef _Alembic_Abc_OArrayProperty_h_
37 #define _Alembic_Abc_OArrayProperty_h_
38 
39 #include <Alembic/Util/Export.h>
40 #include <Alembic/Abc/Foundation.h>
41 #include <Alembic/Abc/Base.h>
42 #include <Alembic/Abc/Argument.h>
45 
46 namespace Alembic {
47 namespace Abc {
48 namespace ALEMBIC_VERSION_NS {
49 
50 //-*****************************************************************************
52  : public OBasePropertyT<AbcA::ArrayPropertyWriterPtr>
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 OArrayProperty 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, and to specify time sampling or time sampling index.
74  template <class OBJECT_PTR>
75  OArrayProperty( OBJECT_PTR iParentObject,
76  const std::string &iName,
77  const AbcA::DataType &iDataType,
78 
79  const Argument &iArg0 = Argument(),
80  const Argument &iArg1 = Argument(),
81  const Argument &iArg2 = Argument() );
82 
83  //! This attaches an OArrayProperty wrapper around an existing
84  //! ArrayPropertyWriterPtr, with an optional error handling policy.
86  //! The pointer
87  //! ...
89 
90  //! The flag indicating that wrapping is intended.
91  //! Even though it's nonambiguous here, we use it anyway
92  //! for readability
93  WrapExistingFlag iWrapFlag,
94 
95  //! Optional error handling policy
96  //! ...
99  iWrapFlag,
100  iPolicy ) {}
101 
102  //! Default copy constructor used
103  //! Default assignment operator used.
104 
105  //! Destructor
106  //! ...
107  ~OArrayProperty();
108 
109  //-*************************************************************************
110  // ARRAY PROPERTY WRITER FUNCTIONALITY
111  //-*************************************************************************
112 
113  //! Get the number of samples written so far.
114  //! May change over time as more samples are written.
115  size_t getNumSamples() const;
116 
117  //! Set a sample from the address of a datum.
118  //! ...
119  void set( const AbcA::ArraySample &iSample );
120 
121  //! Set a sample from the previous sample.
122  //! ...
123  void setFromPrevious( );
124 
125  //! Changes the TimeSampling used by this property.
126  //! If the TimeSampling is changed to Acyclic and the number of samples
127  //! currently set is more than the number of times provided in the Acyclic
128  //! TimeSampling, an exception will be thrown.
129  void setTimeSampling( uint32_t iIndex );
130 
131  //! Changes the TimeSampling used by this property.
132  //! If the TimeSampling is changed to Acyclic and the number of samples
133  //! currently set is more than the number of times provided in the Acyclic
134  //! TimeSampling, an exception will be thrown.
135  void setTimeSampling( AbcA::TimeSamplingPtr iTime );
136 
137  //! Return the parent compound property, handily wrapped in a
138  //! OCompoundProperty wrapper.
139  OCompoundProperty getParent() const;
140 
141 private:
142  void init( AbcA::CompoundPropertyWriterPtr iParentObject,
143  const std::string &iName,
144  const AbcA::DataType &iDataType,
145 
146  ErrorHandler::Policy iParentPolicy,
147 
148  const Argument &iArg0,
149  const Argument &iArg1,
150  const Argument &iArg2 );
151 };
152 
153 //-*****************************************************************************
154 // TEMPLATE AND INLINE FUNCTIONS
155 //-*****************************************************************************
156 
157 //-*****************************************************************************
158 template <class CPROP_PTR>
159 inline OArrayProperty::OArrayProperty( CPROP_PTR iParentProp,
160  const std::string &iName,
161  const AbcA::DataType &iDataType,
162  const Argument &iArg0,
163  const Argument &iArg1,
164  const Argument &iArg2 )
165 {
166  init( GetCompoundPropertyWriterPtr( iParentProp ),
167  iName, iDataType,
168 
169  GetErrorHandlerPolicy( iParentProp ),
170  iArg0, iArg1, iArg2 );
171 }
172 
173 } // End namespace ALEMBIC_VERSION_NS
174 
175 using namespace ALEMBIC_VERSION_NS;
176 
177 } // End namespace Abc
178 } // End namespace Alembic
179 
180 #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
Alembic::Util::shared_ptr< TimeSampling > TimeSamplingPtr
Definition: TimeSampling.h:137
Alembic::Util::shared_ptr< ArrayPropertyWriter > ArrayPropertyWriterPtr
OArrayProperty(AbcA::ArrayPropertyWriterPtr iPtr, WrapExistingFlag iWrapFlag, ErrorHandler::Policy iPolicy=ErrorHandler::kThrowPolicy)
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