HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
OScalarProperty.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_OScalarProperty_h_
37 #define _Alembic_Abc_OScalarProperty_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::ScalarPropertyWriterPtr>
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 OScalarProperty 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  OScalarProperty( 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 OScalarProperty wrapper around an existing
84  //! ScalarPropertyWriterPtr, arguments are there to specify
85  //! ErrorHandling policy,
87 
88  //! The pointer
89  //! ...
91 
92  //! The flag indicating that wrapping is intended.
93  //! Even though it's nonambiguous here, we use it anyway
94  //! for readability
95  WrapExistingFlag iWrapFlag,
96 
97  //! Error Handling Policy
98  //! ..
101  iWrapFlag,
102  iPolicy ) {}
103 
104  //! Default copy constructor used
105  //! Default assignment operator used.
106 
107  //! Destructor
108  //! ...
109  ~OScalarProperty();
110 
111  //-*************************************************************************
112  // SCALAR PROPERTY WRITER FUNCTIONALITY
113  //-*************************************************************************
114 
115  //! Return the number of samples contained in the property.
116  //! This can be any number, including zero.
117  //! This returns the number of samples that were written, independently
118  //! of whether or not they were constant.
119  //! It make change over time as more samples are written.
120  size_t getNumSamples() const;
121 
122  //! Set a sample from the address of a datum.
123  //! ...
124  void set( const void *iSample );
125 
126  //! Set a sample from the previous sample.
127  //! ...
128  void setFromPrevious( );
129 
130  //! Changes the TimeSampling used by this property.
131  //! If the TimeSampling is changed to Acyclic and the number of samples
132  //! currently set is more than the number of times provided in the Acyclic
133  //! TimeSampling, an exception will be thrown.
134  void setTimeSampling( uint32_t iIndex );
135 
136  //! Changes the TimeSampling used by this property.
137  //! If the TimeSampling is changed to Acyclic and the number of samples
138  //! currently set is more than the number of times provided in the Acyclic
139  //! TimeSampling, an exception will be thrown.
140  void setTimeSampling( AbcA::TimeSamplingPtr iTime );
141 
142  //! Return the parent compound property, handily wrapped in a
143  //! OCompoundProperty wrapper.
144  OCompoundProperty getParent() const;
145 
146 private:
147  void init( AbcA::CompoundPropertyWriterPtr iParentObject,
148  const std::string &iName,
149  const AbcA::DataType &iDataType,
150 
151  ErrorHandler::Policy iParentPolicy,
152 
153  const Argument &iArg0,
154  const Argument &iArg1,
155  const Argument &iArg2 );
156 };
157 
158 //-*****************************************************************************
159 // TEMPLATE AND INLINE FUNCTIONS
160 //-*****************************************************************************
161 
162 //-*****************************************************************************
163 template <class CPROP_PTR>
164 inline OScalarProperty::OScalarProperty( CPROP_PTR iParentProp,
165  const std::string &iName,
166  const AbcA::DataType &iDataType,
167  const Argument &iArg0,
168  const Argument &iArg1,
169  const Argument &iArg2 )
170 {
171  init( GetCompoundPropertyWriterPtr( iParentProp ),
172  iName, iDataType,
173 
174  GetErrorHandlerPolicy( iParentProp ),
175  iArg0, iArg1, iArg2 );
176 }
177 
178 } // End namespace ALEMBIC_VERSION_NS
179 
180 using namespace ALEMBIC_VERSION_NS;
181 
182 } // End namespace Abc
183 } // End namespace Alembic
184 
185 #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< ScalarPropertyWriter > ScalarPropertyWriterPtr
OScalarProperty(AbcA::ScalarPropertyWriterPtr 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