DataType.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_DataType_h
#define Alembic_AbcCoreAbstract_DataType_h
#include <Alembic/AbcCoreAbstract/Foundation.h>
namespace Alembic {
namespace AbcCoreAbstract {
namespace ALEMBIC_VERSION_NS {
//-*****************************************************************************
class ALEMBIC_EXPORT DataType
: Alembic::Util::totally_ordered<DataType>
{
public:
DataType()
: m_pod( kUnknownPOD ), m_extent( 0 ) {}
explicit DataType( PlainOldDataType iPod, uint8_t iExtent = 1 )
: m_pod( iPod ), m_extent( iExtent ) {}
PlainOldDataType getPod() const { return m_pod; }
void setPod( PlainOldDataType iPod ) { m_pod = iPod; }
uint8_t getExtent() const { return m_extent; }
void setExtent( uint8_t iExtent ) { m_extent = iExtent; }
size_t getNumBytes() const
{
return PODNumBytes( m_pod ) * ( size_t )m_extent;
}
bool operator==( const DataType &b ) const
{
return ( ( m_pod == b.m_pod ) &&
( m_extent == b.m_extent ) );
}
//-*************************************************************************
bool operator<( const DataType &b ) const
{
if ( m_pod < b.m_pod ) { return true; }
else if ( m_pod > b.m_pod ) { return false; }
else { return ( m_extent < b.m_extent ); }
}
private:
PlainOldDataType m_pod;
uint8_t m_extent;
};
//-*****************************************************************************
inline std::ostream &operator<<( std::ostream &ostr, const DataType &a )
{
ostr << PODName( a.getPod() );
if ( a.getExtent() > 1 )
{
ostr << "[" << ( size_t )a.getExtent() << "]";
}
return ostr;
}
} // End namespace ALEMBIC_VERSION_NS
using namespace ALEMBIC_VERSION_NS;
} // End namespace AbcCoreAbstract
} // End namespace Alembic
#endif
Foundation.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::DataType::operator==
bool operator==(const DataType &b) const
Definition: DataType.h:103
Alembic::AbcCoreAbstract::ALEMBIC_VERSION_NS::DataType::operator<
bool operator<(const DataType &b) const
Definition: DataType.h:113
Alembic::AbcCoreAbstract::ALEMBIC_VERSION_NS::DataType::setPod
void setPod(PlainOldDataType iPod)
Definition: DataType.h:78
Alembic::AbcCoreAbstract::ALEMBIC_VERSION_NS::DataType::getExtent
uint8_t getExtent() const
Definition: DataType.h:82
Alembic::AbcCoreAbstract::ALEMBIC_VERSION_NS::DataType::getNumBytes
size_t getNumBytes() const
Definition: DataType.h:96
Alembic::AbcCoreAbstract::ALEMBIC_VERSION_NS::DataType::DataType
DataType(PlainOldDataType iPod, uint8_t iExtent=1)
Definition: DataType.h:66
Alembic::AbcCoreAbstract::ALEMBIC_VERSION_NS::DataType::getPod
PlainOldDataType getPod() const
Definition: DataType.h:74
Alembic::AbcCoreAbstract::ALEMBIC_VERSION_NS::DataType::setExtent
void setExtent(uint8_t iExtent)
Definition: DataType.h:86
Alembic::AbcCoreAbstract::ALEMBIC_VERSION_NS::DataType::DataType
DataType()
Definition: DataType.h:59
Alembic::Util::ALEMBIC_VERSION_NS::totally_ordered
Definition: Foundation.h:194
Alembic::AbcCoreAbstract::ALEMBIC_VERSION_NS::operator<<
std::ostream & operator<<(std::ostream &ostr, const DataType &a)
Definition: DataType.h:133
Alembic::Util::ALEMBIC_VERSION_NS::PlainOldDataType
PlainOldDataType
Definition: PlainOldDataType.h:184
Alembic::Util::ALEMBIC_VERSION_NS::kUnknownPOD
@ kUnknownPOD
Unknown.
Definition: PlainOldDataType.h:222
Alembic::Util::ALEMBIC_VERSION_NS::PODName
const char * PODName(PlainOldDataType pod)
Definition: PlainOldDataType.h:358
Alembic::Util::ALEMBIC_VERSION_NS::PODNumBytes
size_t PODNumBytes(PlainOldDataType pod)
Definition: PlainOldDataType.h:332
Alembic
Alembic namespace ...
Definition: ArchiveInfo.h:46