00001
00002
00011 #ifndef ATHCONTAINERS_AUXDATATRAITS_H
00012 #define ATHCONTAINERS_AUXDATATRAITS_H
00013
00014
00015 #include <vector>
00016 #include <cstdlib>
00017
00018
00019 namespace SG {
00020
00021
00028 template <class T>
00029 class AuxDataTraits
00030 {
00031 public:
00033 typedef T element_type;
00034
00036 typedef T& reference_type;
00037 typedef const T& const_reference_type;
00038
00040 typedef std::vector<T> vector_type;
00041
00043 typedef typename vector_type::pointer container_pointer_type;
00044 typedef typename vector_type::const_pointer const_container_pointer_type;
00045
00048 static reference_type index (void* ptr, size_t ndx)
00049 {
00050 return reinterpret_cast<container_pointer_type>(ptr)[ndx];
00051 }
00052
00055 static const_reference_type index (const void* ptr, size_t ndx)
00056 {
00057 return reinterpret_cast<const_container_pointer_type>(ptr)[ndx];
00058 }
00059
00060 };
00061
00062
00071 template <>
00072 class AuxDataTraits<bool>
00073 {
00074 public:
00076 typedef bool element_type;
00077
00079 typedef bool& reference_type;
00080 typedef const bool& const_reference_type;
00081
00083 typedef std::vector<char> vector_type;
00084
00086 typedef vector_type::pointer container_pointer_type;
00087 typedef vector_type::const_pointer const_container_pointer_type;
00088
00091 static reference_type index (void* ptr, size_t ndx)
00092 {
00093 return reinterpret_cast<bool*>(ptr)[ndx];
00094 }
00095
00098 static const_reference_type index (const void* ptr, size_t ndx)
00099 {
00100 return reinterpret_cast<const bool*>(ptr)[ndx];
00101 }
00102 };
00103
00104
00105 }
00106
00107
00108 #endif // not ATHCONTAINERS_AUXDATATRAITS_H