Loading...
Searching...
No Matches
TimeSamplingType.h
Go to the documentation of this file.
//-*****************************************************************************
//
// Copyright (c) 2009-2013,
// Sony Pictures Imageworks, Inc. and
// Industrial Light & Magic, a division of Lucasfilm Entertainment Company Ltd.
//
// All rights reserved.
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are
// met:
// * Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
// * Redistributions in binary form must reproduce the above
// copyright notice, this list of conditions and the following disclaimer
// in the documentation and/or other materials provided with the
// distribution.
// * Neither the name of Sony Pictures Imageworks, nor
// Industrial Light & Magic nor the names of their contributors may be used
// to endorse or promote products derived from this software without specific
// prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
//
//-*****************************************************************************
#ifndef Alembic_AbcCoreAbstract_TimeSamplingType_h
#define Alembic_AbcCoreAbstract_TimeSamplingType_h
#include <Alembic/Util/Export.h>
#include <Alembic/AbcCoreAbstract/Foundation.h>
namespace Alembic {
namespace AbcCoreAbstract {
namespace ALEMBIC_VERSION_NS {
//-*****************************************************************************
class ALEMBIC_EXPORT TimeSamplingType
{
public:
static uint32_t AcyclicNumSamples();
static chrono_t AcyclicTimePerCycle();
public:
TimeSamplingType()
: m_numSamplesPerCycle( 1 ),
m_timePerCycle( 1.0 ) {}
explicit TimeSamplingType( chrono_t iTimePerCycle )
: m_numSamplesPerCycle( 1 )
, m_timePerCycle( iTimePerCycle )
{
ABCA_ASSERT( m_timePerCycle > 0.0 &&
m_timePerCycle < AcyclicTimePerCycle(),
"Time per cycle must be greater than 0 " <<
"and can not be ACYCLIC_TIME_PER_CYCLE." );
}
TimeSamplingType( uint32_t iNumSamplesPerCycle,
chrono_t iTimePerCycle )
: m_numSamplesPerCycle( iNumSamplesPerCycle )
, m_timePerCycle( iTimePerCycle )
{
ABCA_ASSERT(
// Acyclic
( m_timePerCycle == AcyclicTimePerCycle() &&
m_numSamplesPerCycle == AcyclicNumSamples() ) ||
// valid time per cycle
( m_timePerCycle > 0.0 &&
m_timePerCycle < AcyclicTimePerCycle() &&
// and valid samples per cycle
m_numSamplesPerCycle > 0 &&
m_numSamplesPerCycle < AcyclicNumSamples() ),
"Invalid Time Sampling Type, time per cycle: "
<< m_timePerCycle << " samples per cycle: "
<< m_numSamplesPerCycle );
}
enum AcyclicFlag { kAcyclic };
explicit TimeSamplingType( AcyclicFlag /*iAF*/ )
{
m_numSamplesPerCycle = AcyclicNumSamples();
m_timePerCycle = AcyclicTimePerCycle();
}
bool operator==( const TimeSamplingType & iRhs ) const;
bool isUniform() const { return m_numSamplesPerCycle == 1; }
bool isCyclic() const
{
return ( ( m_numSamplesPerCycle > 1 ) &&
( m_numSamplesPerCycle < AcyclicNumSamples() ) );
}
bool isAcyclic() const
{ return m_numSamplesPerCycle == AcyclicNumSamples(); }
uint32_t getNumSamplesPerCycle() const { return m_numSamplesPerCycle; }
chrono_t getTimePerCycle() const { return m_timePerCycle; }
private:
uint32_t m_numSamplesPerCycle;
chrono_t m_timePerCycle;
public:
ALEMBIC_EXPORT friend std::ostream
&operator<<( std::ostream &ostr, const TimeSamplingType &tst );
};
} // End namespace ALEMBIC_VERSION_NS
using namespace ALEMBIC_VERSION_NS;
} // End namespace AbcCoreAbstract
} // End namespace Alembic
#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::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::operator<<
ALEMBIC_EXPORT friend std::ostream & operator<<(std::ostream &ostr, const TimeSamplingType &tst)
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::kAcyclic
@ kAcyclic
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
Definition ArchiveReader.h:47
Alembic::AbcCoreAbstract::ALEMBIC_VERSION_NS::chrono_t
float64_t chrono_t
Definition Foundation.h:71
Alembic::AbcCoreAbstract
Definition ArchiveReader.h:46
Alembic
Alembic namespace ...
Definition ArchiveInfo.h:46