Changeset 121 for trunk/nv/types.hh
- Timestamp:
- 06/15/13 17:47:57 (12 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/nv/types.hh
r113 r121 6 6 #define NV_TYPES_HH 7 7 8 #include <glm/glm.hpp>9 8 #include <nv/common.hh> 9 #include <nv/math.hh> 10 10 #include <nv/object.hh> 11 11 #include <type_traits> … … 44 44 }; 45 45 46 template <typename T>47 struct datatype_traits48 {49 typedef T type;50 typedef T base_type;51 static const size_t size = 1;52 };53 54 template <typename T>55 struct datatype_traits< glm::detail::tvec2<T> >56 {57 typedef glm::detail::tvec2<T> type;58 typedef typename type::value_type base_type;59 static const size_t size = 2;60 };61 62 template <typename T>63 struct datatype_traits< glm::detail::tvec3<T> >64 {65 typedef glm::detail::tvec3<T> type;66 typedef typename type::value_type base_type;67 static const size_t size = 3;68 };69 70 template <typename T>71 struct datatype_traits< glm::detail::tvec4<T> >72 {73 typedef glm::detail::tvec4<T> type;74 typedef typename type::value_type base_type;75 static const size_t size = 4;76 };77 78 typedef glm::detail::tvec2<sint8> i8vec2;79 typedef glm::detail::tvec3<sint8> i8vec3;80 typedef glm::detail::tvec4<sint8> i8vec4;81 82 typedef glm::vec2 vec2;83 typedef glm::vec3 vec3;84 typedef glm::vec4 vec4;85 86 typedef glm::ivec2 ivec2;87 typedef glm::ivec3 ivec3;88 typedef glm::ivec4 ivec4;89 90 typedef glm::mat2 mat2;91 typedef glm::mat3 mat3;92 typedef glm::mat4 mat4;93 94 46 template < datatype EnumType > struct enum_to_type {}; 95 47 … … 177 129 enum type_flag 178 130 { 179 TF_POINTER = 0x01, // < field is a pointer180 TF_NOSERIALIZE = 0x02, // < ignore during serialization181 TF_INVISIBLE = 0x04, // < field invisible to API182 TF_READONLY = 0x08, // < read only field183 TF_SIMPLETYPE = 0x10, // < raw binary I/O possible131 TF_POINTER = 0x01, //!< field is a pointer 132 TF_NOSERIALIZE = 0x02, //!< ignore during serialization 133 TF_INVISIBLE = 0x04, //!< field invisible to API 134 TF_READONLY = 0x08, //!< read only field 135 TF_SIMPLETYPE = 0x10, //!< raw binary I/O possible 184 136 TF_OWNED = 0x20, 185 TF_CONTAINER = 0x40, // < is a container137 TF_CONTAINER = 0x40, //!< is a container 186 138 }; 187 139 188 140 struct type_field 189 141 { 190 std::string name; //< name of the field191 std::string type_name; //< name of the type of the field192 const std::type_info* type_inf; //< typeinfo for later retrieval of type193 type_entry* type; //< pointer to field type194 unsigned int flags; //< flags142 std::string name; //!< name of the field 143 std::string type_name; //!< name of the type of the field 144 const std::type_info* type_inf; //!< typeinfo for later retrieval of type 145 type_entry* type; //!< pointer to field type 146 unsigned int flags; //!< flags 195 147 size_t offset; 196 148 197 149 template< typename TOBJECT, typename TFIELD > 198 type_field( const char* name, TFIELD TOBJECT::*field, typename std::enable_if< is_container<TFIELD>::value, void* >::type = nullptr )199 : name( name)150 type_field( const char* aname, TFIELD TOBJECT::*field, typename std::enable_if< is_container<TFIELD>::value, void* >::type = nullptr ) 151 : name(aname) 200 152 , type_name() 201 153 , type_inf( &typeid( typename std::remove_pointer<typename TFIELD::value_type>::type ) ) … … 204 156 , offset( offset_of( field ) ) 205 157 { 206 NV_LOG( LOG_INFO, name << "-" << offset);158 NV_LOG( LOG_INFO, aname << "-" << offset); 207 159 flags = TF_CONTAINER | 208 160 ( std::is_pointer<typename TFIELD::value_type>::value ? TF_POINTER : 0 ) | … … 211 163 212 164 template< typename TOBJECT, typename TFIELD > 213 type_field( const char* name, TFIELD TOBJECT::*field, typename std::enable_if< !is_container<TFIELD>::value, void* >::type = nullptr )214 : name( name)165 type_field( const char* aname, TFIELD TOBJECT::*field, typename std::enable_if< !is_container<TFIELD>::value, void* >::type = nullptr ) 166 : name(aname) 215 167 , type_name() 216 168 , type_inf( &typeid( typename std::remove_pointer<TFIELD>::type ) ) … … 219 171 , offset( offset_of( field ) ) 220 172 { 221 NV_LOG( LOG_INFO, name << "-" << offset);173 NV_LOG( LOG_INFO, aname << "-" << offset); 222 174 flags = 223 175 ( std::is_pointer<TFIELD>::value ? TF_POINTER : 0 ) | … … 236 188 std::string name; 237 189 int value; 238 type_enum( const char* name, int value ) : name(name), value(value) {}190 type_enum( const char* aname, int avalue ) : name(aname), value(avalue) {} 239 191 }; 240 192 … … 345 297 { 346 298 base_type = type_db->get_type( typeid(TYPE) ); 299 return *this; 347 300 } 348 301
Note: See TracChangeset
for help on using the changeset viewer.