Alembic: Abc/TypedPropertyTraits.h Source File

Alembic 1.8.11

Loading...
Searching...
No Matches
TypedPropertyTraits.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_Abc_TypedPropertyTraits_h
38#define Alembic_Abc_TypedPropertyTraits_h
39
40#include <Alembic/Abc/Foundation.h>
41
42//-*****************************************************************************
43// The property traits class maps ValueTypes with their protocol
44// strings.
45
46namespace Alembic {
47namespace Abc {
48namespace ALEMBIC_VERSION_NS {
49
50//-*****************************************************************************
51//-*****************************************************************************
52// This macro relies on there being a default constructor for the type
53// VAL
54#define ALEMBIC_ABC_DECLARE_TYPE_TRAITS( VAL, POD, EXTENT, INTERP, PTDEF ) \
55struct PTDEF \
56{ \
57 static const PlainOldDataType pod_enum = POD; \
58 static const int extent = EXTENT; \
59 typedef VAL value_type; \
60 static const char * interpretation() { return ( INTERP ) ; } \
61 static const char * name() { return #PTDEF; } \
62 static AbcA::DataType dataType() \
63 { return AbcA::DataType( POD, EXTENT ) ; } \
64 static value_type defaultValue() \
65 { value_type v; return v; } \
66}
67
68//-*****************************************************************************
69//-*****************************************************************************
70#define DECLARE_POD_TRAITS( POD_TYPE , PTDEF ) \
71struct PTDEF \
72{ \
73 static const PlainOldDataType pod_enum = \
74 PODTraitsFromType< POD_TYPE >::pod_enum; \
75 static const int extent = 1; \
76 typedef POD_TYPE value_type; \
77 static const char * interpretation() { return ""; } \
78 static const char * name() { return #PTDEF; } \
79 static AbcA::DataType dataType() \
80 { return AbcA::DataType( PODTraitsFromType< POD_TYPE >::pod_enum, 1 ); } \
81 static value_type defaultValue() \
82 { return PODTraitsFromType< POD_TYPE >::default_value(); } \
83}
84
85//-*****************************************************************************
86DECLARE_POD_TRAITS( bool_t, BooleanTPTraits );
87DECLARE_POD_TRAITS( uint8_t, Uint8TPTraits );
88DECLARE_POD_TRAITS( int8_t, Int8TPTraits );
89DECLARE_POD_TRAITS( uint16_t, Uint16TPTraits );
90DECLARE_POD_TRAITS( int16_t, Int16TPTraits );
91DECLARE_POD_TRAITS( uint32_t, Uint32TPTraits );
92DECLARE_POD_TRAITS( int32_t, Int32TPTraits );
93DECLARE_POD_TRAITS( uint64_t, Uint64TPTraits );
94DECLARE_POD_TRAITS( int64_t, Int64TPTraits );
95DECLARE_POD_TRAITS( float16_t, Float16TPTraits );
96DECLARE_POD_TRAITS( float32_t, Float32TPTraits );
97DECLARE_POD_TRAITS( float64_t, Float64TPTraits );
98DECLARE_POD_TRAITS( string, StringTPTraits );
99DECLARE_POD_TRAITS( wstring, WstringTPTraits );
100
101#undef DECLARE_POD_TRAITS
102
103//-*****************************************************************************
104ALEMBIC_ABC_DECLARE_TYPE_TRAITS( V2s, kInt16POD, 2, "vector", V2sTPTraits );
105ALEMBIC_ABC_DECLARE_TYPE_TRAITS( V2i, kInt32POD, 2, "vector", V2iTPTraits );
106ALEMBIC_ABC_DECLARE_TYPE_TRAITS( V2f, kFloat32POD, 2, "vector", V2fTPTraits );
107ALEMBIC_ABC_DECLARE_TYPE_TRAITS( V2d, kFloat64POD, 2, "vector", V2dTPTraits );
108
109ALEMBIC_ABC_DECLARE_TYPE_TRAITS( V3s, kInt16POD, 3, "vector", V3sTPTraits );
110ALEMBIC_ABC_DECLARE_TYPE_TRAITS( V3i, kInt32POD, 3, "vector", V3iTPTraits );
111ALEMBIC_ABC_DECLARE_TYPE_TRAITS( V3f, kFloat32POD, 3, "vector", V3fTPTraits );
112ALEMBIC_ABC_DECLARE_TYPE_TRAITS( V3d, kFloat64POD, 3, "vector", V3dTPTraits );
113
114ALEMBIC_ABC_DECLARE_TYPE_TRAITS( V2s, kInt16POD, 2, "point", P2sTPTraits );
115ALEMBIC_ABC_DECLARE_TYPE_TRAITS( V2i, kInt32POD, 2, "point", P2iTPTraits );
116ALEMBIC_ABC_DECLARE_TYPE_TRAITS( V2f, kFloat32POD, 2, "point", P2fTPTraits );
117ALEMBIC_ABC_DECLARE_TYPE_TRAITS( V2d, kFloat64POD, 2, "point", P2dTPTraits );
118
119ALEMBIC_ABC_DECLARE_TYPE_TRAITS( V3s, kInt16POD, 3, "point", P3sTPTraits );
120ALEMBIC_ABC_DECLARE_TYPE_TRAITS( V3i, kInt32POD, 3, "point", P3iTPTraits );
121ALEMBIC_ABC_DECLARE_TYPE_TRAITS( V3f, kFloat32POD, 3, "point", P3fTPTraits );
122ALEMBIC_ABC_DECLARE_TYPE_TRAITS( V3d, kFloat64POD, 3, "point", P3dTPTraits );
123
124ALEMBIC_ABC_DECLARE_TYPE_TRAITS( Box2s, kInt16POD, 4, "box", Box2sTPTraits );
125ALEMBIC_ABC_DECLARE_TYPE_TRAITS( Box2i, kInt32POD, 4, "box", Box2iTPTraits );
126ALEMBIC_ABC_DECLARE_TYPE_TRAITS( Box2f, kFloat32POD, 4, "box", Box2fTPTraits );
127ALEMBIC_ABC_DECLARE_TYPE_TRAITS( Box2d, kFloat64POD, 4, "box", Box2dTPTraits );
128
129ALEMBIC_ABC_DECLARE_TYPE_TRAITS( Box3s, kInt16POD, 6, "box", Box3sTPTraits );
130ALEMBIC_ABC_DECLARE_TYPE_TRAITS( Box3i, kInt32POD, 6, "box", Box3iTPTraits );
131ALEMBIC_ABC_DECLARE_TYPE_TRAITS( Box3f, kFloat32POD, 6, "box", Box3fTPTraits );
132ALEMBIC_ABC_DECLARE_TYPE_TRAITS( Box3d, kFloat64POD, 6, "box", Box3dTPTraits );
133
134ALEMBIC_ABC_DECLARE_TYPE_TRAITS( M33f, kFloat32POD, 9, "matrix", M33fTPTraits );
135ALEMBIC_ABC_DECLARE_TYPE_TRAITS( M33d, kFloat64POD, 9, "matrix", M33dTPTraits );
136ALEMBIC_ABC_DECLARE_TYPE_TRAITS( M44f, kFloat32POD, 16, "matrix", M44fTPTraits );
137ALEMBIC_ABC_DECLARE_TYPE_TRAITS( M44d, kFloat64POD, 16, "matrix", M44dTPTraits );
138
139ALEMBIC_ABC_DECLARE_TYPE_TRAITS( Quatf, kFloat32POD, 4, "quat", QuatfTPTraits );
140ALEMBIC_ABC_DECLARE_TYPE_TRAITS( Quatd, kFloat64POD, 4, "quat", QuatdTPTraits );
141
142//-*****************************************************************************
143// colors. For now, using "rgb"/"rgba" as the interpretation
144ALEMBIC_ABC_DECLARE_TYPE_TRAITS( C3h, kFloat16POD, 3, "rgb", C3hTPTraits );
145ALEMBIC_ABC_DECLARE_TYPE_TRAITS( C3f, kFloat32POD, 3, "rgb", C3fTPTraits );
146ALEMBIC_ABC_DECLARE_TYPE_TRAITS( C3c, kUint8POD, 3, "rgb", C3cTPTraits );
147
148ALEMBIC_ABC_DECLARE_TYPE_TRAITS( C4h, kFloat16POD, 4, "rgba", C4hTPTraits );
149ALEMBIC_ABC_DECLARE_TYPE_TRAITS( C4f, kFloat32POD, 4, "rgba", C4fTPTraits );
150ALEMBIC_ABC_DECLARE_TYPE_TRAITS( C4c, kUint8POD, 4, "rgba", C4cTPTraits );
151
152//-*****************************************************************************
153// Normals.
154ALEMBIC_ABC_DECLARE_TYPE_TRAITS( V2f, kFloat32POD, 2, "normal", N2fTPTraits );
155ALEMBIC_ABC_DECLARE_TYPE_TRAITS( V2d, kFloat64POD, 2, "normal", N2dTPTraits );
156
157// N3f and N3d is typedefed in Foundation from V3f and V3d
158ALEMBIC_ABC_DECLARE_TYPE_TRAITS( N3f, kFloat32POD, 3, "normal", N3fTPTraits );
159ALEMBIC_ABC_DECLARE_TYPE_TRAITS( N3d, kFloat64POD, 3, "normal", N3dTPTraits );
160
161} // End namespace ALEMBIC_VERSION_NS
162
163using namespace ALEMBIC_VERSION_NS;
164
165} // End namespace Abc
166} // End namespace Alembic
167
168#endif
Alembic
Alembic namespace ...
Definition ArchiveInfo.cpp:39