Loading...
Searching...
No Matches
ScalarSample.h
Go to the documentation of this file.
//-*****************************************************************************
//
// Copyright (c) 2009-2012,
// 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_ScalarSample_h
#define Alembic_AbcCoreAbstract_ScalarSample_h
#include <Alembic/Util/Export.h>
#include <Alembic/AbcCoreAbstract/Foundation.h>
#include <Alembic/AbcCoreAbstract/DataType.h>
namespace Alembic {
namespace AbcCoreAbstract {
namespace ALEMBIC_VERSION_NS {
//-*****************************************************************************
class ALEMBIC_EXPORT ScalarSample
: public Alembic::Util::totally_ordered<ScalarSample>
{
public:
//-*************************************************************************
// Data
//-*************************************************************************
class Data
{
public:
virtual ~Data() {}
virtual void setToDefault() = 0;
virtual void copyFrom( const void *iData ) = 0;
virtual bool equalTo( const void *iData ) const = 0;
virtual bool equalEpsilon( const void *iData,
double iEpsilon ) const = 0;
virtual bool lessThan( const void *iData ) const = 0;
virtual const void *getData() const = 0;
};
explicit ScalarSample( const DataType &iDataType );
void copyFrom( const void *iData )
{
m_data->copyFrom( iData );
}
//-*************************************************************************
// Data Access
//-*************************************************************************
const DataType &getDataType() const { return m_dataType; }
const void *getData() const { return m_data->getData(); }
//-*************************************************************************
// Comparison and Equality
//-*************************************************************************
bool operator==( const void *iRhs ) const
{
return m_data->equalTo( iRhs );
}
bool operator==( const ScalarSample &iRhs ) const
{
return ( iRhs.getDataType() == m_dataType ) &&
m_data->equalTo( iRhs.getData() );
}
bool equalWithRelAbsError( const void *iRhs,
double iRelAbsError ) const
{
return m_data->equalEpsilon( iRhs, iRelAbsError );
}
bool equalWithRelAbsError( const ScalarSample &iRhs,
double iRelAbsError ) const
{
return ( iRhs.getDataType() == m_dataType ) &&
m_data->equalEpsilon( iRhs.getData(), iRelAbsError );
}
bool operator<( const void *iRhs ) const
{
return m_data->lessThan( iRhs );
}
bool operator<( const ScalarSample &iRhs ) const
{
if ( m_dataType < iRhs.getDataType() )
{
return true;
}
else if ( m_dataType > iRhs.getDataType() )
{
return false;
}
else
{
return m_data->lessThan( iRhs.getData() );
}
}
//-*************************************************************************
// Useful functions
//-*************************************************************************
void setToDefault()
{
m_data->setToDefault();
}
private:
DataType m_dataType;
Alembic::Util::unique_ptr<Data> m_data;
};
} // End namespace ALEMBIC_VERSION_NS
using namespace ALEMBIC_VERSION_NS;
} // End namespace AbcCoreAbstract
} // End namespace Alembic
#endif
Foundation.h
DataType.h
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::DataType
Definition DataType.h:52
Alembic::AbcCoreAbstract::ALEMBIC_VERSION_NS::ScalarSample::Data
Definition ScalarSample.h:70
Alembic::AbcCoreAbstract::ALEMBIC_VERSION_NS::ScalarSample::Data::equalTo
virtual bool equalTo(const void *iData) const =0
Alembic::AbcCoreAbstract::ALEMBIC_VERSION_NS::ScalarSample::Data::lessThan
virtual bool lessThan(const void *iData) const =0
Alembic::AbcCoreAbstract::ALEMBIC_VERSION_NS::ScalarSample::Data::setToDefault
virtual void setToDefault()=0
Alembic::AbcCoreAbstract::ALEMBIC_VERSION_NS::ScalarSample::Data::equalEpsilon
virtual bool equalEpsilon(const void *iData, double iEpsilon) const =0
Alembic::AbcCoreAbstract::ALEMBIC_VERSION_NS::ScalarSample::Data::~Data
virtual ~Data()
Definition ScalarSample.h:72
Alembic::AbcCoreAbstract::ALEMBIC_VERSION_NS::ScalarSample::Data::getData
virtual const void * getData() const =0
Alembic::AbcCoreAbstract::ALEMBIC_VERSION_NS::ScalarSample::Data::copyFrom
virtual void copyFrom(const void *iData)=0
Alembic::AbcCoreAbstract::ALEMBIC_VERSION_NS::ScalarSample::operator==
bool operator==(const ScalarSample &iRhs) const
Definition ScalarSample.h:123
Alembic::AbcCoreAbstract::ALEMBIC_VERSION_NS::ScalarSample::copyFrom
void copyFrom(const void *iData)
Definition ScalarSample.h:92
Alembic::AbcCoreAbstract::ALEMBIC_VERSION_NS::ScalarSample::equalWithRelAbsError
bool equalWithRelAbsError(const void *iRhs, double iRelAbsError) const
Definition ScalarSample.h:132
Alembic::AbcCoreAbstract::ALEMBIC_VERSION_NS::ScalarSample::getData
const void * getData() const
Definition ScalarSample.h:107
Alembic::AbcCoreAbstract::ALEMBIC_VERSION_NS::ScalarSample::operator==
bool operator==(const void *iRhs) const
Definition ScalarSample.h:116
Alembic::AbcCoreAbstract::ALEMBIC_VERSION_NS::ScalarSample::equalWithRelAbsError
bool equalWithRelAbsError(const ScalarSample &iRhs, double iRelAbsError) const
Definition ScalarSample.h:140
Alembic::AbcCoreAbstract::ALEMBIC_VERSION_NS::ScalarSample::operator<
bool operator<(const void *iRhs) const
Definition ScalarSample.h:149
Alembic::AbcCoreAbstract::ALEMBIC_VERSION_NS::ScalarSample::ScalarSample
ScalarSample(const DataType &iDataType)
Alembic::AbcCoreAbstract::ALEMBIC_VERSION_NS::ScalarSample::setToDefault
void setToDefault()
Definition ScalarSample.h:178
Alembic::AbcCoreAbstract::ALEMBIC_VERSION_NS::ScalarSample::operator<
bool operator<(const ScalarSample &iRhs) const
Definition ScalarSample.h:156
Alembic::AbcCoreAbstract::ALEMBIC_VERSION_NS::ScalarSample::getDataType
const DataType & getDataType() const
Definition ScalarSample.h:103
Alembic::Util::ALEMBIC_VERSION_NS::totally_ordered
Definition Foundation.h:194
Alembic::AbcCoreAbstract::ALEMBIC_VERSION_NS
Definition ArchiveReader.h:47
Alembic::AbcCoreAbstract
Definition ArchiveReader.h:46
Alembic
Alembic namespace ...
Definition ArchiveInfo.h:46