HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
IScalarProperty.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_IScalarProperty_h_
37 #define _Alembic_Abc_IScalarProperty_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>
46 
47 namespace Alembic {
48 namespace Abc {
49 namespace ALEMBIC_VERSION_NS {
50 
51 //-*****************************************************************************
53  : public IBasePropertyT<AbcA::ScalarPropertyReaderPtr>
54 {
55 public:
56  //! By convention we always define this_type in Abc classes
57  //! Used by unspecified-bool-type conversion below
59 
60  //-*************************************************************************
61  // CONSTRUCTION, DESTRUCTION, ASSIGNMENT
62  //-*************************************************************************
63 
64  //! The default constructor creates an empty IScalarProperty function set.
65  //! ...
67 
68  //! This templated, explicit function creates a new scalar property reader.
69  //! The first argument is any Abc (or AbcCoreAbstract) object
70  //! which can intrusively be converted to a CompoundPropertyReaderPtr
71  //! to use as a parent, from which the error handler policy for
72  //! inheritance is also derived. The remaining optional arguments
73  //! can be used to override the ErrorHandlerPolicy, and that's it.
74  template <class OBJECT_PTR>
75  IScalarProperty( OBJECT_PTR iParentObject,
76  const std::string &iName,
77 
78  const Argument &iArg0 = Argument() );
79 
80  //! This attaches an IScalarProperty wrapper around an existing
81  //! ScalarPropertyReaderPtr, with an optional error handling policy.
83  //! The pointer
84  //! ...
86 
87  //! The flag indicating that wrapping is intended.
88  //! Even though it's nonambiguous here, we use it anyway
89  //! for readability
90  WrapExistingFlag iWrapFlag,
91 
92  //! Optional error handling policy
93  //! ...
94  const Argument &iArg0 = Argument() )
95  : IBasePropertyT<AbcA::ScalarPropertyReaderPtr>( iPtr, iWrapFlag,
96  GetErrorHandlerPolicy( iPtr, iArg0 ) )
97  {}
98 
99  //! Default copy constructor used
100  //! Default assignment operator used.
101 
102  //! Destructor
103  //! ...
104  ~IScalarProperty();
105 
106  //-*************************************************************************
107  // SCALAR PROPERTY READER FUNCTIONALITY
108  //-*************************************************************************
109 
110  //! Return the number of samples contained in the property.
111  //! This can be any number, including zero.
112  //! This returns the number of samples that were written, independently
113  //! of whether or not they were constant.
114  size_t getNumSamples() const;
115 
116  //! Ask if we're constant - no change in value amongst samples,
117  //! regardless of the time sampling.
118  bool isConstant() const;
119 
120  //! Time information.
121  //! This will be valid regardless of TimeSamplingType or number of samples.
122  AbcA::TimeSamplingPtr getTimeSampling() const;
123 
124  //! Get a sample into the address of a datum.
125  //! ...
126  void get( void *oSample,
127  const ISampleSelector &iSS = ISampleSelector() ) const;
128 
129  //! Return the parent compound property, handily wrapped in a
130  //! ICompoundProperty wrapper.
131  ICompoundProperty getParent() const;
132 
133 private:
134  void init( AbcA::CompoundPropertyReaderPtr iParentObject,
135  const std::string &iName,
136 
137  ErrorHandler::Policy iParentPolicy,
138 
139  const Argument &iArg0 );
140 };
141 
142 //-*****************************************************************************
143 // TEMPLATE AND INLINE FUNCTIONS
144 //-*****************************************************************************
145 
146 //-*****************************************************************************
147 template <class CPROP_PTR>
148 inline IScalarProperty::IScalarProperty( CPROP_PTR iParentProp,
149  const std::string &iName,
150  const Argument &iArg0 )
151 {
152  init( GetCompoundPropertyReaderPtr( iParentProp ), iName,
153  GetErrorHandlerPolicy( iParentProp ), iArg0 );
154 }
155 
156 } // End namespace ALEMBIC_VERSION_NS
157 
158 using namespace ALEMBIC_VERSION_NS;
159 
160 } // End namespace Abc
161 } // End namespace Alembic
162 
163 #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
IScalarProperty(AbcA::ScalarPropertyReaderPtr iPtr, WrapExistingFlag iWrapFlag, const Argument &iArg0=Argument())
Alembic::Util::shared_ptr< TimeSampling > TimeSamplingPtr
Definition: TimeSampling.h:137
Alembic::Util::shared_ptr< CompoundPropertyReader > CompoundPropertyReaderPtr
AbcA::CompoundPropertyReaderPtr GetCompoundPropertyReaderPtr(AbcA::CompoundPropertyReaderPtr iPtr)
Definition: Foundation.h:171
Alembic::Util::shared_ptr< ScalarPropertyReader > ScalarPropertyReaderPtr
#define ALEMBIC_EXPORT
Definition: Export.h:51
#define ALEMBIC_VERSION_NS
Definition: Foundation.h:104