1#ifndef NW_G3D_RES_RESCOMMON_H_
2#define NW_G3D_RES_RESCOMMON_H_
4#include <nw/g3d/g3d_config.h>
5#include <nw/g3d/ut/g3d_Inlines.h>
6#include <nw/g3d/res/g3d_ResDefs.h>
9namespace nw {
namespace g3d {
namespace res {
11#define NW_G3D_VALIDITY_ASSERT
12 NW_G3D_ASSERTMSG(this, "%s::%s: Object not valid.", GetClassName(), __FUNCTION__)
14#define NW_G3D_RES_COMMON_ALIGN(class_name, alignment) public
16 typedef class_name##Data DataType;
17 DataType* ptr() { return this; }
18 const DataType* ptr() const { return this; }
21 static class_name* ResCast(DataType* ptr)
23 static const class_name* ResCast(const DataType* ptr)
25 static const char* GetClassName() { return #class_name; } private
50 bool Equals(
const char* str, size_t len)
const
52 return (GetLength() == len) && (std::strcmp(GetName(), str) == 0);
97 const char*
to_ptr()
const {
return offset.to_ptr<
char>(); }
99 void set_ptr(
const char* ptr) { offset.set_ptr(ptr); }
103 return offset == 0 ? NULL : ResName::ResCast(
104 AddOffset<ResNameData>(
this,
static_cast<size_t>(offset) -
sizeof(ResName::LengthType)));
119 void*
to_ptr() {
return to_ptr<
void>(); }
121 const void*
to_ptr()
const {
return to_ptr<
void>(); }
123 template <
typename T>
127 return static_cast<T*>(ptr);
133 template <
typename T>
137 return static_cast<
const T*>(ptr);
148 NW_G3D_ASSERT(ptr == NULL);
200 void*
GetData() {
return ref().offset.to_ptr(); }
202 const void*
GetData()
const {
return ref().offset.to_ptr(); }
Definition g3d_ResCommon.h:109
const T * to_ptr() const
Definition g3d_ResCommon.h:134
BinPtr & set_ptr(void *ptr)
Definition g3d_ResCommon.h:143
u32 addr
Definition g3d_ResCommon.h:113
const void * to_ptr() const
Definition g3d_ResCommon.h:121
void * ptr
Definition g3d_ResCommon.h:115
T * to_ptr()
Definition g3d_ResCommon.h:124
void * to_ptr()
Definition g3d_ResCommon.h:119
Definition g3d_ResCommon.h:93
const char * to_ptr() const
Definition g3d_ResCommon.h:97
const ResName * GetResName() const
Definition g3d_ResCommon.h:101
void set_ptr(const char *ptr)
Definition g3d_ResCommon.h:99
Offset offset
Definition g3d_ResCommon.h:95
Definition g3d_ResCommon.h:62
s32 offset
Definition g3d_ResCommon.h:64
Definition g3d_ResCommon.h:194
const void * GetData() const
Definition g3d_ResCommon.h:202
size_t GetSize() const
Definition g3d_ResCommon.h:198
void * GetData()
Definition g3d_ResCommon.h:200
Definition g3d_ResCommon.h:40
bool Equals(const char *str, size_t len) const
Definition g3d_ResCommon.h:50
size_t GetLength() const
Definition g3d_ResCommon.h:46
bool Equals(const ResName *rhs) const
Definition g3d_ResCommon.h:55
const char * GetName() const
Definition g3d_ResCommon.h:48
#define NW_G3D_RES_COMMON_ALIGN(class_name, alignment)
Definition g3d_ResCommon.h:14
#define NW_G3D_VALIDITY_ASSERT
Definition g3d_ResCommon.h:11
#define NW_G3D_RES_COMMON(class_name)
Definition g3d_ResCommon.h:30
#define NW_G3D_ASSERTMSG(exp,...)
Definition g3d_assert.h:13
#define NW_G3D_ASSERT_ADDR_ALIGNMENT(addr, alignment)
Definition g3d_assert.h:36
#define NW_G3D_DISALLOW_COPY_AND_ASSIGN(TypeName)
Definition g3d_defs.h:81
#define NW_G3D_HOST_PTRSIZE
Definition g3d_defs.h:40
#define NW_G3D_TARGET_PTRSIZE
Definition g3d_defs.h:34
Definition g3d_defs.h:122
Definition g3d_GfxManage.cpp:10
Definition g3d_ResCommon.h:188
Offset offset
Definition g3d_ResCommon.h:189
u32 size
Definition g3d_ResCommon.h:190
Definition g3d_ResCommon.h:33
char str[sizeof(LengthType)]
Definition g3d_ResCommon.h:36
LengthType len
Definition g3d_ResCommon.h:35
u32 LengthType
Definition g3d_ResCommon.h:34