Alembic 1.8.11
Loading...
Searching...
No Matches
SpwImpl.h
1//-*****************************************************************************
2//
3// Copyright (c) 2009-2012,
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_AbcCoreHDF5_SpwImpl_h
38#define Alembic_AbcCoreHDF5_SpwImpl_h
39
40#include <Alembic/AbcCoreHDF5/Foundation.h>
41#include <Alembic/AbcCoreHDF5/SimplePwImpl.h>
42
43namespace Alembic {
44namespace AbcCoreHDF5 {
45namespace ALEMBIC_VERSION_NS {
46
47//-*****************************************************************************
48// This type is a no-op.
49// It is here to support the template interface which, in order to generalize
50// across arrays & scalars, needs a "key" type to compare array samples with.
51class ScalarSampleKey
52{
53public:
54 ScalarSampleKey(){}
55};
56
57//-*****************************************************************************
58// Scalar Property Writer.
59class SpwImpl
60 : public SimplePwImpl<AbcA::ScalarPropertyWriter,
61 SpwImpl,
62 const void *,
63 ScalarSampleKey>
64 , public Alembic::Util::enable_shared_from_this<SpwImpl>
65{
66protected:
67 friend class CpwData;
68
69 //-*************************************************************************
70 SpwImpl( AbcA::CompoundPropertyWriterPtr iParent,
71 hid_t iParentGroup,
72 const std::string & iName,
73 const AbcA::MetaData & iMetaData,
74 const AbcA::DataType & iDataType,
75 uint32_t iTimeSamplingIndex );
76
77 AbcA::ScalarPropertyWriterPtr asScalarPtr();
78
79public:
80 virtual ~SpwImpl();
81
82 //-*************************************************************************
83 // No-op return of no-op class.
84 static ScalarSampleKey computeSampleKey( const void *iSamp )
85 {
86 return ScalarSampleKey();
87 }
88
89 //-*************************************************************************
90 bool sameAsPreviousSample( const void *iSamp,
91 const ScalarSampleKey &iKey ) const
92 {
93 // CJH: Could include tolerances here.
94 return m_previousSample.equalWithRelAbsError( iSamp,
95 1.0e-9 );
96 }
97
98 //-*************************************************************************
99 void copyPreviousSample( hid_t iGroup,
100 const std::string &iSampleName,
101 index_t iSampleIndex );
102
103 //-*************************************************************************
104 void writeSample( hid_t iGroup,
105 const std::string &iSampleName,
106 index_t iSampleIndex,
107 const void *iSamp,
108 const ScalarSampleKey &iKey );
109
110protected:
111 // Use the AbcCoreAbstract's magnificent "ScalarSample"
112 // helper class to keep track of our storage.
113 AbcA::ScalarSample m_previousSample;
114};
115
116} // End namespace ALEMBIC_VERSION_NS
117
118using namespace ALEMBIC_VERSION_NS;
119
120} // End namespace AbcCoreHDF5
121} // End namespace Alembic
122
123#endif
AbcA::ScalarPropertyWriterPtr asScalarPtr()
Definition SpwImpl.cpp:82
Alembic namespace ...
Definition ArchiveInfo.cpp:39