Alembic: AbcCoreAbstract/DataType.h Source File

Alembic 1.8.11

Loading...
Searching...
No Matches
DataType.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_AbcCoreAbstract_DataType_h
38#define Alembic_AbcCoreAbstract_DataType_h
39
40#include <Alembic/AbcCoreAbstract/Foundation.h>
41
42namespace Alembic {
43namespace AbcCoreAbstract {
44namespace ALEMBIC_VERSION_NS {
45
46//-*****************************************************************************
50 class ALEMBIC_EXPORT DataType
51 : Alembic::Util::totally_ordered<DataType>
52{
53public:
59 DataType()
60 : m_pod( kUnknownPOD ), m_extent( 0 ) {}
61
66 explicit DataType( PlainOldDataType iPod, uint8_t iExtent = 1 )
67 : m_pod( iPod ), m_extent( iExtent ) {}
68
71
74 PlainOldDataType getPod() const { return m_pod; }
75
78 void setPod( PlainOldDataType iPod ) { m_pod = iPod; }
79
82 uint8_t getExtent() const { return m_extent; }
83
86 void setExtent( uint8_t iExtent ) { m_extent = iExtent; }
87
96 size_t getNumBytes() const
97 {
98 return PODNumBytes( m_pod ) * ( size_t )m_extent;
99 }
100
103 bool operator==( const DataType &b ) const
104 {
105 return ( ( m_pod == b.m_pod ) &&
106 ( m_extent == b.m_extent ) );
107 }
108
109 //-*************************************************************************
113 bool operator<( const DataType &b ) const
114 {
115 if ( m_pod < b.m_pod ) { return true; }
116 else if ( m_pod > b.m_pod ) { return false; }
117 else { return ( m_extent < b.m_extent ); }
118 }
119
120private:
123 PlainOldDataType m_pod;
124
127 uint8_t m_extent;
128};
129
130//-*****************************************************************************
133inline std::ostream &operator<<( std::ostream &ostr, const DataType &a )
134{
135 ostr << PODName( a.getPod() );
136 if ( a.getExtent() > 1 )
137 {
138 ostr << "[" << ( size_t )a.getExtent() << "]";
139 }
140 return ostr;
141}
142
143} // End namespace ALEMBIC_VERSION_NS
144
145using namespace ALEMBIC_VERSION_NS;
146
147} // End namespace AbcCoreAbstract
148} // End namespace Alembic
149
150#endif
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:120
Alembic
Alembic namespace ...
Definition ArchiveInfo.cpp:39