12#include "RMF/config.h"
14#include <boost/cstdint.hpp>
17#if RMF_HAS_DEPRECATED_BACKENDS
34struct ValueTraitsBase {
36 typedef std::vector<T> Types;
37 typedef T ArgumentType;
39 static bool get_are_equal(T a, T b) {
return a == b; }
43struct ReferenceTraitsBase {
45 typedef std::vector<T> Types;
46 typedef const T& ArgumentType;
47 typedef const T& ReturnType;
51struct Traits<
Int> :
public ValueTraitsBase<Int> {
52 static bool get_is_null_value(
const Type& t) {
return t == get_null_value(); }
53 static ReturnType get_null_value() {
54 return std::numeric_limits<Type>::max();
56#if RMF_HAS_DEPRECATED_BACKENDS
57 typedef HDF5::IntTraits HDF5Traits;
58 typedef boost::int32_t AvroType;
60 static std::string get_tag() {
return "ki"; }
61 static std::string get_name() {
return "int"; }
65struct Traits<
Float> :
public ValueTraitsBase<Float> {
66 static bool get_is_null_value(
const Type& t) {
67 return t >= std::numeric_limits<Float>::max();
69 static ReturnType get_null_value() {
70 return std::numeric_limits<Type>::infinity();
72#if RMF_HAS_DEPRECATED_BACKENDS
73 typedef HDF5::FloatTraits HDF5Traits;
74 typedef double AvroType;
76 static bool get_are_equal(ArgumentType a, ArgumentType b) {
77 return std::abs(a - b) < .0000001 * std::abs(a + b) + .000000001;
79 static std::string get_tag() {
return "kf"; }
80 static std::string get_name() {
return "float"; }
85 static bool get_is_null_value(
const Type& t) {
return t.empty(); }
86 static ReturnType get_null_value() {
90#if RMF_HAS_DEPRECATED_BACKENDS
91 typedef HDF5::StringTraits HDF5Traits;
92 typedef Type AvroType;
94 static std::string get_tag() {
return "ks"; }
95 static std::string get_name() {
return "string"; }
99struct SequenceTraitsBase {
100 typedef std::vector<T> Type;
101 typedef std::vector<Type> Types;
102 typedef Type ReturnType;
103 typedef const Type& ArgumentType;
104 static bool get_is_null_value(
const Type& t) {
return t.empty(); }
105 static ReturnType get_null_value() {
109 static bool get_are_equal(ArgumentType a, ArgumentType b) {
110 if (a.size() != b.size())
return false;
111 for (
unsigned int i = 0; i < a.size(); ++i) {
112 if (!Traits<T>::get_are_equal(a[i], b[i]))
return false;
116 static std::string get_tag() {
return Traits<T>::get_tag() +
"s"; }
117 static std::string get_name() {
return Traits<T>::get_name() +
"s"; }
121struct Traits<
Ints> :
public SequenceTraitsBase<Int> {
122#if RMF_HAS_DEPRECATED_BACKENDS
123 typedef HDF5::IntsTraits HDF5Traits;
124 typedef std::vector<Traits<Int>::AvroType> AvroType;
129struct Traits<
Floats> :
public SequenceTraitsBase<Float> {
130#if RMF_HAS_DEPRECATED_BACKENDS
131 typedef HDF5::FloatsTraits HDF5Traits;
132 typedef std::vector<double> AvroType;
138#if RMF_HAS_DEPRECATED_BACKENDS
139 typedef HDF5::StringsTraits HDF5Traits;
140 typedef Type AvroType;
144template <
unsigned int D>
145class Traits<
Vector<D> > :
public ReferenceTraitsBase<Vector<D> > {
146 static std::string make_tag() {
147 std::ostringstream oss;
151 static std::string make_name() {
152 std::ostringstream oss;
153 oss <<
"vector" << D;
159 return t[0] > std::numeric_limits<double>::max();
163 D, std::numeric_limits<
typename Traits<Float>::Type>::infinity()));
167 for (
unsigned int i = 0; i < D; ++i) {
168 if (!Traits<Float>::get_are_equal(a[i], b[i]))
return false;
172 static std::string get_tag() {
173 static std::string tag = make_tag();
176 static std::string get_name() {
177 static std::string name = make_name();
182template <
unsigned int D>
183struct Traits<std::vector<Vector<D> > > :
public SequenceTraitsBase<
207typedef IntTraits IntTag;
208typedef FloatTraits FloatTag;
209typedef StringTraits StringTag;
210typedef Vector3Traits Vector3Tag;
211typedef Vector4Traits Vector4Tag;
212typedef IntsTraits IntsTag;
213typedef FloatsTraits FloatsTag;
214typedef StringsTraits StringsTag;
215typedef Vector3sTraits Vector3sTag;
216typedef Vector4sTraits Vector4sTag;
227struct Vector3sTag {};
228struct Vector4sTag {};
Handle read/write of Model data from/to files.
Represent a point in some dimension.
The namespace for all functionality in the library.
std::vector< String > Strings
std::vector< Float > Floats
Traits classes describing how RMF uses types for storing data.
Default implementation for types.h.
#define RMF_VECTOR
For classes that are templated on the dimension.