Alembic Version 1.1

TimeSamplingType.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_AbcCoreAbstract_TimeSamplingType_h
38#define Alembic_AbcCoreAbstract_TimeSamplingType_h
39
40#include <Alembic/Util/Export.h>
41#include <Alembic/AbcCoreAbstract/Foundation.h>
42
43 namespace Alembic {
44 namespace AbcCoreAbstract {
45 namespace ALEMBIC_VERSION_NS {
46
47//-*****************************************************************************
67
68 class ALEMBIC_EXPORT TimeSamplingType
69{
70 public:
71 static uint32_t AcyclicNumSamples();
72 static chrono_t AcyclicTimePerCycle();
73
74 public:
75
77 TimeSamplingType()
78 : m_numSamplesPerCycle( 1 ),
79 m_timePerCycle( 1.0 ) {}
80
83 explicit TimeSamplingType( chrono_t iTimePerCycle )
84 : m_numSamplesPerCycle( 1 )
85 , m_timePerCycle( iTimePerCycle )
86 {
87 ABCA_ASSERT( m_timePerCycle > 0.0 &&
88 m_timePerCycle < AcyclicTimePerCycle(),
89 "Time per cycle must be greater than 0 " <<
90 "and can not be ACYCLIC_TIME_PER_CYCLE." );
91 }
92
95 TimeSamplingType( uint32_t iNumSamplesPerCycle,
96 chrono_t iTimePerCycle )
97 : m_numSamplesPerCycle( iNumSamplesPerCycle )
98 , m_timePerCycle( iTimePerCycle )
99 {
100 ABCA_ASSERT(
101
102 // Acyclic
103 ( m_timePerCycle == AcyclicTimePerCycle() &&
104 m_numSamplesPerCycle == AcyclicNumSamples() ) ||
105
106 // valid time per cycle
107 ( m_timePerCycle > 0.0 &&
108 m_timePerCycle < AcyclicTimePerCycle() &&
109
110 // and valid samples per cycle
111 m_numSamplesPerCycle > 0 &&
112 m_numSamplesPerCycle < AcyclicNumSamples() ),
113 "Invalid Time Sampling Type, time per cycle: "
114 << m_timePerCycle << " samples per cycle: "
115 << m_numSamplesPerCycle );
116
117 }
118
123 enum AcyclicFlag { kAcyclic };
124 explicit TimeSamplingType( AcyclicFlag /*iAF*/ )
125 {
126 m_numSamplesPerCycle = AcyclicNumSamples();
127 m_timePerCycle = AcyclicTimePerCycle();
128 }
129
132
133 bool operator==( const TimeSamplingType & iRhs ) const;
134
139 bool isUniform() const { return m_numSamplesPerCycle == 1; }
140 bool isCyclic() const
141 {
142 return ( ( m_numSamplesPerCycle > 1 ) &&
143 ( m_numSamplesPerCycle < AcyclicNumSamples() ) );
144 }
145 bool isAcyclic() const
146 { return m_numSamplesPerCycle == AcyclicNumSamples(); }
147
148 uint32_t getNumSamplesPerCycle() const { return m_numSamplesPerCycle; }
149
150 chrono_t getTimePerCycle() const { return m_timePerCycle; }
151
152 private:
153 uint32_t m_numSamplesPerCycle;
154 chrono_t m_timePerCycle;
155
156 public:
157 ALEMBIC_EXPORT friend std::ostream
158 &operator<<( std::ostream &ostr, const TimeSamplingType &tst );
159};
160
161} // End namespace ALEMBIC_VERSION_NS
162
163 using namespace ALEMBIC_VERSION_NS;
164
165} // End namespace AbcCoreAbstract
166} // End namespace Alembic
167
168#endif
Foundation.h
ABCA_ASSERT
#define ABCA_ASSERT(COND, TEXT)
Definition: Foundation.h:99
Export.h
ALEMBIC_EXPORT
#define ALEMBIC_EXPORT
Definition: Export.h:51
ALEMBIC_VERSION_NS
#define ALEMBIC_VERSION_NS
Definition: Foundation.h:105
Alembic::AbcCoreAbstract::ALEMBIC_VERSION_NS::TimeSamplingType
Definition: TimeSamplingType.h:69
Alembic::AbcCoreAbstract::ALEMBIC_VERSION_NS::TimeSamplingType::isCyclic
bool isCyclic() const
Definition: TimeSamplingType.h:140
Alembic::AbcCoreAbstract::ALEMBIC_VERSION_NS::TimeSamplingType::getNumSamplesPerCycle
uint32_t getNumSamplesPerCycle() const
Definition: TimeSamplingType.h:148
Alembic::AbcCoreAbstract::ALEMBIC_VERSION_NS::TimeSamplingType::AcyclicTimePerCycle
static chrono_t AcyclicTimePerCycle()
Alembic::AbcCoreAbstract::ALEMBIC_VERSION_NS::TimeSamplingType::operator==
bool operator==(const TimeSamplingType &iRhs) const
Alembic::AbcCoreAbstract::ALEMBIC_VERSION_NS::TimeSamplingType::getTimePerCycle
chrono_t getTimePerCycle() const
Definition: TimeSamplingType.h:150
Alembic::AbcCoreAbstract::ALEMBIC_VERSION_NS::TimeSamplingType::TimeSamplingType
TimeSamplingType(AcyclicFlag)
Definition: TimeSamplingType.h:124
Alembic::AbcCoreAbstract::ALEMBIC_VERSION_NS::TimeSamplingType::TimeSamplingType
TimeSamplingType(chrono_t iTimePerCycle)
Definition: TimeSamplingType.h:83
Alembic::AbcCoreAbstract::ALEMBIC_VERSION_NS::TimeSamplingType::AcyclicFlag
AcyclicFlag
Definition: TimeSamplingType.h:123
Alembic::AbcCoreAbstract::ALEMBIC_VERSION_NS::TimeSamplingType::AcyclicNumSamples
static uint32_t AcyclicNumSamples()
Alembic::AbcCoreAbstract::ALEMBIC_VERSION_NS::TimeSamplingType::TimeSamplingType
TimeSamplingType()
Uniform default.
Definition: TimeSamplingType.h:77
Alembic::AbcCoreAbstract::ALEMBIC_VERSION_NS::TimeSamplingType::isUniform
bool isUniform() const
Definition: TimeSamplingType.h:139
Alembic::AbcCoreAbstract::ALEMBIC_VERSION_NS::TimeSamplingType::TimeSamplingType
TimeSamplingType(uint32_t iNumSamplesPerCycle, chrono_t iTimePerCycle)
Definition: TimeSamplingType.h:95
Alembic::AbcCoreAbstract::ALEMBIC_VERSION_NS::TimeSamplingType::isAcyclic
bool isAcyclic() const
Definition: TimeSamplingType.h:145
Alembic::AbcCoreAbstract::ALEMBIC_VERSION_NS::chrono_t
float64_t chrono_t
Definition: Foundation.h:71
Alembic::AbcCoreAbstract::ALEMBIC_VERSION_NS::operator<<
std::ostream & operator<<(std::ostream &ostr, const DataType &a)
Definition: DataType.h:133
Alembic
Alembic namespace ...
Definition: ArchiveInfo.h:46