OROCHI
 
Loading...
Searching...
No Matches
GxRttiResource.h
Go to the documentation of this file.
1//===========================================================================
10//===========================================================================
11#pragma once
12
13//---------------------------------------------------------------------------
15//---------------------------------------------------------------------------
17
18#define _RESOURCE(__CLASS__, __VALUE__) _CUSTOM_PROPERTY_POINTER(__CLASS__, __VALUE__)
19#define _RESOURCE_ATTRIBUTE(__CLASS__, __VALUE__, __ATTRIBUTE__) _CUSTOM_PROPERTY_POINTER_ATTRIBUTE(__CLASS__, __VALUE__, __ATTRIBUTE__)
20#define _RESOURCE_NAME(__CLASS__, __VALUE__, __NAME__) _CUSTOM_PROPERTY_POINTER_NAME(__CLASS__, __VALUE__, __NAME__)
21#define _RESOURCE_NAME_ATTRIBUTE(__CLASS__, __VALUE__, __NAME__, __ATTRIBUTE__) _CUSTOM_PROPERTY_POINTER_NAME_ATTRIBUTE(__CLASS__, __VALUE__, __NAME__, __ATTRIBUTE__)
22#define _RESOURCE_ARRAY(__CLASS__, __VALUE__) _CUSTOM_PROPERTY_POINTER_ARRAY(__CLASS__, __VALUE__)
23#define _RESOURCE_ARRAY_COUNT(__CLASS__, __VALUE__, __COUNT__) _CUSTOM_PROPERTY_POINTER_ARRAY_COUNT(__CLASS__, __VALUE__, __COUNT__)
24#define _RESOURCE_CUSTOM(__CLASS__, __NAME__, __GET_VALUE_FUNC__, __SET_VALUE_FUNC__) _CUSTOM_PROPERTY_POINTER_CUSTOM(__CLASS__, __NAME__, __GET_VALUE_FUNC__, __SET_VALUE_FUNC__)
25#define _RESOURCE_CUSTOM_ATTRIBUTE(__CLASS__, __NAME__, __GET_VALUE_FUNC__, __SET_VALUE_FUNC__, __ATTRIBUTE__) _CUSTOM_PROPERTY_POINTER_CUSTOM_ATTRIBUTE(__CLASS__, __NAME__, __GET_VALUE_FUNC__, __SET_VALUE_FUNC__, __ATTRIBUTE__)
26#define _RESOURCE_DYNAMIC(__CLASS__, __NAME__, __GET_IVALUE_FUNC__, __SET_IVALUE_FUNC__, __GET_COUNT_FUNC__, __SET_COUNT_FUNC__) _CUSTOM_PROPERTY_POINTER_DYNAMIC(__CLASS__, __NAME__, __GET_IVALUE_FUNC__, __SET_IVALUE_FUNC__, __GET_COUNT_FUNC__, __SET_COUNT_FUNC__)
27#define _RESOURCE_DYNAMIC_ATTRIBUTE(__CLASS__, __NAME__, __GET_IVALUE_FUNC__, __SET_IVALUE_FUNC__, __GET_COUNT_FUNC__, __SET_COUNT_FUNC__, __ATTRIBUTE__) _CUSTOM_PROPERTY_POINTER_DYNAMIC_ATTRIBUTE(__CLASS__, __NAME__, __GET_IVALUE_FUNC__, __SET_IVALUE_FUNC__, __GET_COUNT_FUNC__, __SET_COUNT_FUNC__, __ATTRIBUTE__)
28
30//---------------------------------------------------------------------------
32//---------------------------------------------------------------------------
34
35#if defined(__clang__) // PS4, NX (see GxRtti.h)
36#define GX_RTTI_RESOURCE_CPP_PRAGMA_BEGIN() \
37 _Pragma("clang diagnostic push") \
38 _Pragma("clang diagnostic ignored \"-Winconsistent-missing-override\"")
39#define GX_RTTI_RESOURCE_CPP_PRAGMA_END() \
40 _Pragma("clang diagnostic pop")
41#else //__clang__
42#define GX_RTTI_RESOURCE_CPP_PRAGMA_BEGIN()
43#define GX_RTTI_RESOURCE_CPP_PRAGMA_END()
44#endif // !__clang__
45
47#if GX_DEVELOP
48#define GX_RTTI_RESOURCE_DEFINE(__THIS__, __BASE__, __NAME__, __ID__, __ICON_TYPE__, __ATTRIBUTE__, __CREATEINSTANCE__) \
49 GX_RTTI_RESOURCE_CPP_PRAGMA_BEGIN() \
50 using MyClass = __THIS__; \
51 using Super = __BASE__; \
52 static gx::core::GxRttiResource __rtti; \
53 static gx::core::GxProperty __properties[]; \
54 static constexpr u32 __defaultId = __ID__; \
55 static constexpr u32 __defaultAttribute = __ATTRIBUTE__; \
56 static void usage(void){ gx::core::GxRtti& rtti = __THIS__::__rtti; \
57 gx::core::GxRtti::forceUsage(rtti); \
58 volatile u32 mask = 0; \
59 GX_ALLOCA(sizeof(MyClass) * mask + 1); } \
60 gx::core::GxRttiResource& getRtti(void) const override{ return __THIS__::__rtti; } \
61 void* cast(const GxRtti& rtti){ if( getRtti().isDerived(rtti) ){ return this; } return nullptr; } \
62 const void* cast(const GxRtti& rtti) const { if( getRtti().isDerived(rtti) ){ return this; } return nullptr; } \
63 static gx::core::GxProperty* __getProperties(void){ return __properties; } \
64 static u32 __getPropertyCount(void); \
65 static GX_CSTR __getName(void){ return __NAME__; } \
66 static gx::core::GxRttiResource& __getStaticRtti(void){ return __rtti; } \
67 static __THIS__* __createInstance(void){ return __CREATEINSTANCE__; } \
68 static GxGuiBase* __createGui(GxProperty& property, GxTypedObject* pOwner, const GxRtti& rtti, u32 index = 0){ return MyClass::createGui(property, pOwner, rtti, index); } \
69 static constexpr GxRtti::ICON_TYPE __iconType = __ICON_TYPE__; \
70 GX_RTTI_RESOURCE_CPP_PRAGMA_END()
71#else //GX_DEVELOP
72#define GX_RTTI_RESOURCE_DEFINE(__THIS__, __BASE__, __NAME__, __ID__, __ICON_TYPE__, __ATTRIBUTE__, __CREATEINSTANCE__) \
73 GX_RTTI_RESOURCE_CPP_PRAGMA_BEGIN() \
74 using MyClass = __THIS__; \
75 using Super = __BASE__; \
76 static gx::core::GxRttiResource __rtti; \
77 static gx::core::GxProperty __properties[]; \
78 static constexpr u32 __defaultId = __ID__; \
79 static constexpr u32 __defaultAttribute = __ATTRIBUTE__; \
80 static void usage(void){ gx::core::GxRtti& rtti = __THIS__::__rtti; \
81 gx::core::GxRtti::forceUsage(rtti); \
82 volatile u32 mask = 0; \
83 GX_ALLOCA(sizeof(MyClass) * mask + 1); } \
84 gx::core::GxRttiResource& getRtti(void) const override { return __THIS__::__rtti; } \
85 void* cast(const GxRtti& rtti){ if( getRtti().isDerived(rtti) ){ return this; } return nullptr; } \
86 const void* cast(const GxRtti& rtti) const { if( getRtti().isDerived(rtti) ){ return this; } return nullptr; } \
87 static gx::core::GxProperty* __getProperties(void){ return __properties; } \
88 static u32 __getPropertyCount(void); \
89 static GX_CSTR __getName(void){ return __NAME__; } \
90 static gx::core::GxRttiResource& __getStaticRtti(void){ return __rtti; } \
91 static __THIS__* __createInstance(void){ return __CREATEINSTANCE__; } \
92 GX_RTTI_RESOURCE_CPP_PRAGMA_END()
93#endif // !GX_DEVELOP
94
96#if GX_DEVELOP
97#define GX_RTTI_RESOURCE(__THIS__, __BASE__) GX_RTTI_RESOURCE_DEFINE(__THIS__, __BASE__, #__THIS__, gx::core::GxRtti::DEFAULT_ID, GxRtti::ICON_TYPE::INVALID, gx::core::GxRtti::ATTRIBUTE_CREATABLE, GX_NEW __THIS__)
98#define GX_RTTI_RESOURCE_ICON(__THIS__, __BASE__, __ICON_TYPE__) GX_RTTI_RESOURCE_DEFINE(__THIS__, __BASE__, #__THIS__, gx::core::GxRtti::DEFAULT_ID, __ICON_TYPE__, gx::core::GxRtti::ATTRIBUTE_CREATABLE, GX_NEW __THIS__)
99#define GX_RTTI_RESOURCE_NAME(__THIS__, __BASE__, __NAME__) GX_RTTI_RESOURCE_DEFINE(__THIS__, __BASE__, __NAME__, gx::core::GxRtti::DEFAULT_ID, GxRtti::ICON_TYPE::INVALID, gx::core::GxRtti::ATTRIBUTE_CREATABLE, GX_NEW __THIS__)
100#define GX_RTTI_RESOURCE_NAME_ICON(__THIS__, __BASE__, __NAME__, __ICON_TYPE__) GX_RTTI_RESOURCE_DEFINE(__THIS__, __BASE__, __NAME__, gx::core::GxRtti::DEFAULT_ID, __ICON_TYPE__, gx::core::GxRtti::ATTRIBUTE_CREATABLE, GX_NEW __THIS__)
101#else //GX_DEVELOP
102#define GX_RTTI_RESOURCE(__THIS__, __BASE__) GX_RTTI_RESOURCE_DEFINE(__THIS__, __BASE__, nullptr, gx::core::GxRtti::DEFAULT_ID, GxRtti::ICON_TYPE::INVALID, gx::core::GxRtti::ATTRIBUTE_CREATABLE, GX_NEW __THIS__)
103#define GX_RTTI_RESOURCE_ICON(__THIS__, __BASE__, __ICON_TYPE__) GX_RTTI_RESOURCE_DEFINE(__THIS__, __BASE__, nullptr, gx::core::GxRtti::DEFAULT_ID, __ICON_TYPE__, gx::core::GxRtti::ATTRIBUTE_CREATABLE, GX_NEW __THIS__)
104#define GX_RTTI_RESOURCE_NAME(__THIS__, __BASE__, __NAME__) GX_RTTI_RESOURCE_DEFINE(__THIS__, __BASE__, nullptr, gx::core::GxRtti::DEFAULT_ID, GxRtti::ICON_TYPE::INVALID, gx::core::GxRtti::ATTRIBUTE_CREATABLE, GX_NEW __THIS__)
105#define GX_RTTI_RESOURCE_NAME_ICON(__THIS__, __BASE__, __NAME__, __ICON_TYPE__) GX_RTTI_RESOURCE_DEFINE(__THIS__, __BASE__, nullptr, gx::core::GxRtti::DEFAULT_ID, __ICON_TYPE__, gx::core::GxRtti::ATTRIBUTE_CREATABLE, GX_NEW __THIS__)
106#endif // !GX_DEVELOP
107
109#if GX_DEVELOP
110#define GX_RTTI_ABSTRACT_RESOURCE(__THIS__, __BASE__) GX_RTTI_RESOURCE_DEFINE(__THIS__, __BASE__, #__THIS__, gx::core::GxRtti::DEFAULT_ID, GxRtti::ICON_TYPE::INVALID, 0, nullptr)
111#define GX_RTTI_ABSTRACT_RESOURCE_ICON(__THIS__, __BASE__, __ICON_TYPE__) GX_RTTI_RESOURCE_DEFINE(__THIS__, __BASE__, #__THIS__, gx::core::GxRtti::DEFAULT_ID, __ICON_TYPE__, 0, nullptr)
112#define GX_RTTI_ABSTRACT_RESOURCE_NAME(__THIS__, __BASE__, __NAME__) GX_RTTI_RESOURCE_DEFINE(__THIS__, __BASE__, __NAME__, gx::core::GxRtti::DEFAULT_ID, GxRtti::ICON_TYPE::INVALID, 0, nullptr)
113#define GX_RTTI_ABSTRACT_RESOURCE_NAME_ICON(__THIS__, __BASE__, __NAME__, __ICON_TYPE__) GX_RTTI_RESOURCE_DEFINE(__THIS__, __BASE__, __NAME__, gx::core::GxRtti::DEFAULT_ID, __ICON_TYPE__, 0, nullptr)
114#else //GX_DEVELOP
115#define GX_RTTI_ABSTRACT_RESOURCE(__THIS__, __BASE__) GX_RTTI_RESOURCE_DEFINE(__THIS__, __BASE__, nullptr, gx::core::GxRtti::DEFAULT_ID, GxRtti::ICON_TYPE::INVALID, 0, nullptr)
116#define GX_RTTI_ABSTRACT_RESOURCE_ICON(__THIS__, __BASE__, __ICON_TYPE__) GX_RTTI_RESOURCE_DEFINE(__THIS__, __BASE__, nullptr, gx::core::GxRtti::DEFAULT_ID, __ICON_TYPE__, 0, nullptr)
117#define GX_RTTI_ABSTRACT_RESOURCE_NAME(__THIS__, __BASE__, __NAME__) GX_RTTI_RESOURCE_DEFINE(__THIS__, __BASE__, nullptr, gx::core::GxRtti::DEFAULT_ID, GxRtti::ICON_TYPE::INVALID, 0, nullptr)
118#define GX_RTTI_ABSTRACT_RESOURCE_NAME_ICON(__THIS__, __BASE__, __NAME__, __ICON_TYPE__) GX_RTTI_RESOURCE_DEFINE(__THIS__, __BASE__, nullptr, gx::core::GxRtti::DEFAULT_ID, __ICON_TYPE__, 0, nullptr)
119#endif // !GX_DEVELOP
120
122//---------------------------------------------------------------------------
124//---------------------------------------------------------------------------
126
132#define GX_RESOURCE_MAGIC_NUMBER(__ext1__, __ext2__, __ext3__, __ext4__) GX_FOURCC(__ext1__, __ext2__, __ext3__, __ext4__)
133
135#if GX_DEVELOP
136#define GX_RTTI_RESOURCE_DETAIL(__THIS__, __ATTRIBUTE__, __RES_VERSION__, __MAGIC_NUMBER__, __EXTENSION__, __RES_ATTRIBUTE__, __CONFIG__) \
137 gx::core::GxRttiResource __THIS__::__rtti( #__THIS__, __THIS__::__getName(), __THIS__::__iconType, gx::core::GxRtti::TYPE::RESOURCE, sizeof(__THIS__), \
138 (__defaultId == gx::core::GxRtti::DEFAULT_ID)? GxMath::getHash32(#__THIS__) : __defaultId, __THIS__::__defaultAttribute | __ATTRIBUTE__, \
139 &Super::__getStaticRtti(), (gx::core::GxRttiResource::CREATE_INSTANCE_FUNCTION)&__THIS__::__createInstance, (GxRtti::CREATE_GUI_FUNCTION)&__THIS__::__createGui, \
140 (gx::core::GxRttiResource::GET_PROPERTIES_FUNCTION)&__THIS__::__getProperties, (gx::core::GxRttiResource::GET_PROPERTY_NUM_FUNCTION)&__THIS__::__getPropertyCount, \
141 __RES_VERSION__, __MAGIC_NUMBER__, __EXTENSION__, __RES_ATTRIBUTE__, \
142 (gx::core::GxRttiResource::RESOURCE_CREATE_FUNCTION)&__THIS__::createCallback, (gx::core::GxRttiResource::RESOURCE_LOAD_FUNCTION)&__THIS__::load, \
143 static_cast<gx::core::GxRttiResource::RESOURCE_SAVE_FUNCTION>(&__THIS__::save), \
144 static_cast<gx::core::GxRttiResource::RESOURCE_FINALIZE_FUNCTION>(&__THIS__::finalize), \
145 static_cast<gx::core::GxRttiResource::RESOURCE_MODIFIED_CHECK_FUNCTION>(&__THIS__::isModified), \
146 __CONFIG__); \
147 u32 __THIS__::__getPropertyCount(void){ u32 i; for(i = 0;__properties[i].getType() != gx::core::GxProperty::TYPE::COUNT_MAX; ++i){} return i; } \
148 gx::core::GxProperty __THIS__::__properties[] = {
149#else //GX_DEVELOP
150#define GX_RTTI_RESOURCE_DETAIL(__THIS__, __ATTRIBUTE__, __RES_VERSION__, __MAGIC_NUMBER__, __EXTENSION__, __RES_ATTRIBUTE__, __CONFIG__) \
151 gx::core::GxRttiResource __THIS__::__rtti( gx::core::GxRtti::TYPE::RESOURCE, sizeof(__THIS__), \
152 (__defaultId == gx::core::GxRtti::DEFAULT_ID)? GxMath::getHash32(#__THIS__) : __defaultId, __THIS__::__defaultAttribute | __ATTRIBUTE__, \
153 &Super::__getStaticRtti(), (gx::core::GxRttiResource::CREATE_INSTANCE_FUNCTION)&__THIS__::__createInstance, \
154 (gx::core::GxRttiResource::GET_PROPERTIES_FUNCTION)&__THIS__::__getProperties, (gx::core::GxRttiResource::GET_PROPERTY_NUM_FUNCTION)&__THIS__::__getPropertyCount, \
155 __RES_VERSION__, __MAGIC_NUMBER__, __EXTENSION__, __RES_ATTRIBUTE__, \
156 (gx::core::GxRttiResource::RESOURCE_CREATE_FUNCTION)&__THIS__::createCallback, (gx::core::GxRttiResource::RESOURCE_LOAD_FUNCTION)&__THIS__::load ); \
157 u32 __THIS__::__getPropertyCount(void){ u32 i; for(i = 0;__properties[i].getType() != gx::core::GxProperty::TYPE::COUNT_MAX; ++i){} return i; } \
158 gx::core::GxProperty __THIS__::__properties[] = {
159#endif // !GX_DEVELOP
160
162#define GX_RESOURCE_PROPERTY_BEGIN(__THIS__, __RES_VERSION__, __MAGIC_NUMBER__, __EXTENSION__, __RES_ATTRIBUTE__) GX_RTTI_RESOURCE_DETAIL(__THIS__, 0, __RES_VERSION__, __MAGIC_NUMBER__, __EXTENSION__, __RES_ATTRIBUTE__, nullptr)
163#define GX_RESOURCE_PROPERTY_BEGIN_ABSTRACT(__THIS__, __RES_ATTRIBUTE__) GX_RTTI_RESOURCE_DETAIL(__THIS__, 0, gx::core::GxRttiResource::VERSION_NOTHING, gx::core::GxRttiResource::MAGIC_NUMBER_NOTHING, gx::core::GxRttiResource::EXTENSION_NOTHING, __RES_ATTRIBUTE__, nullptr)
164
166#define GX_RESOURCE_PROPERTY_END GX_PROPERTY_END
167
168#if GX_DEVELOP
170#define GX_RESOURCE_CONFIG_PROPERTY_BEGIN(__THIS__, __BASE__, __RES_VERSION__, __MAGIC_NUMBER__, __EXTENSION__, __RES_ATTRIBUTE__) GX_RTTI_RESOURCE_DETAIL(__THIS__, 0, __RES_VERSION__, __MAGIC_NUMBER__, __EXTENSION__, __RES_ATTRIBUTE__ | gx::core::GxRttiResource::RESOURCE_ATTRIBUTE_CONFIG, &__BASE__::__rtti)
171
173#define GX_RESOURCE_CONFIG_PROPERTY_END GX_PROPERTY_END
174#endif // GX_DEVELOP
175
177
178GX_CORE_NAMESPACE_BEGIN()
179
180// クラス宣言
181class GxResBase;
182class GxStream;
183
184//===========================================================================
186//===========================================================================
187class GxRttiResource : public GxRtti
188{
189 //-----------------------------------------------------------
191 //-----------------------------------------------------------
193public:
194 // バージョン定義
195 static constexpr u32 VERSION_NOTHING = 0;
196
197 // 識別子定義
198 static constexpr u32 MAGIC_NUMBER_NOTHING = 0;
199
200 // 拡張子定義
201 static GX_CSTR EXTENSION_NOTHING;
202
204 enum class COMPRESS_TYPE
205 {
206 NONE = 0,
207 ZLIB,
208 };
209
212 {
213 RESOURCE_ATTRIBUTE_NOTHING = 0,
214 RESOURCE_ATTRIBUTE_ORIGINAL = (1 << 0),
215 RESOURCE_ATTRIBUTE_FINALIZED = (1 << 1),
216 RESOURCE_ATTRIBUTE_CONFIG = (1 << 2),
217 RESOURCE_ATTRIBUTE_RAW = (1 << 3),
218 RESOURCE_ATTRIBUTE_HAVE_CONFIG = (1 << 4),
219 RESOURCE_ATTRIBUTE_SAVABLE = (1 << 5),
220 RESOURCE_ATTRIBUTE_HAVE_HEADER = (1 << 6),
221 RESOURCE_ATTRIBUTE_COMPRESS_ZLIB = (1 << 7),
222 RESOURCE_ATTRIBUTE_HARDWARE_COMMON = (1 << 8),
223 RESOURCE_ATTRIBUTE_DYNAMIC_REFERENCE = (1 << 9),
224
225 RESOURCE_ATTRIBUTE_PACK_ORIGINAL_DEFAULT = (RESOURCE_ATTRIBUTE_ORIGINAL | RESOURCE_ATTRIBUTE_SAVABLE),
226 RESOURCE_ATTRIBUTE_PACK_ORIGINAL_IMPORT = (RESOURCE_ATTRIBUTE_ORIGINAL),
227 RESOURCE_ATTRIBUTE_PACK_FINALIZED_DEFAULT = (RESOURCE_ATTRIBUTE_FINALIZED | RESOURCE_ATTRIBUTE_SAVABLE | RESOURCE_ATTRIBUTE_HAVE_HEADER | RESOURCE_ATTRIBUTE_COMPRESS_ZLIB),
228 RESOURCE_ATTRIBUTE_PACK_FINALIZED_NO_COMPRESS = (RESOURCE_ATTRIBUTE_FINALIZED | RESOURCE_ATTRIBUTE_SAVABLE | RESOURCE_ATTRIBUTE_HAVE_HEADER),
229 RESOURCE_ATTRIBUTE_PACK_FINALIZED_RAW = (RESOURCE_ATTRIBUTE_FINALIZED | RESOURCE_ATTRIBUTE_SAVABLE | RESOURCE_ATTRIBUTE_RAW),
230 RESOURCE_ATTRIBUTE_PACK_FINALIZED_COMMON = (RESOURCE_ATTRIBUTE_PACK_FINALIZED_DEFAULT | RESOURCE_ATTRIBUTE_HARDWARE_COMMON),
231 RESOURCE_ATTRIBUTE_PACK_FINALIZED_COMMON_NO_COMPRESS = (RESOURCE_ATTRIBUTE_PACK_FINALIZED_NO_COMPRESS | RESOURCE_ATTRIBUTE_HARDWARE_COMMON),
232 RESOURCE_ATTRIBUTE_PACK_CONFIG_DEFAULT = (RESOURCE_ATTRIBUTE_CONFIG)
233 };
234
235 // リソース生成時コールバック関数定義
236 typedef void (GxResBase::* RESOURCE_CREATE_FUNCTION)(void* pUser);
237 // リソースロード関数定義
238 typedef b32 (GxResBase::* RESOURCE_LOAD_FUNCTION)(GxStream& stream, u32 dataSize);
239#if GX_DEVELOP
240 // リソースセーブ関数定義 (開発用)
241 typedef b32 (GxResBase::* RESOURCE_SAVE_FUNCTION)(GxStream& stream);
242 // リソースファイナライズ関数定義 (開発用)
243 typedef b32 (GxResBase::* RESOURCE_FINALIZE_FUNCTION)(void);
244 // リソース変更チェック関数定義 (開発用)
245 typedef b32 (*RESOURCE_MODIFIED_CHECK_FUNCTION)(GxStream& stream, u64 lastWriteTime, GX_CSTR resourcePath);
246
247 static const u32 REFERENCE_RTTI_MAX = 8;
248#endif // GX_DEVELOP
249
251 //-----------------------------------------------------------
253 //-----------------------------------------------------------
255public:
258#if GX_DEVELOP
259 GX_CSTR className,
260 GX_CSTR resourceName,
261 GxRtti::ICON_TYPE iconType,
262#endif // GX_DEVELOP
263 GxRtti::TYPE type,
264 u32 size,
265 u32 id,
266 u32 attribute,
267 GxRtti* pBaseRtti,
268 GxRtti::CREATE_INSTANCE_FUNCTION pCreateInstanceFunction,
269#if GX_DEVELOP
270 GxRtti::CREATE_GUI_FUNCTION pCreateGuiFunction,
271#endif //GX_DEVELOP
272 GxRtti::GET_PROPERTIES_FUNCTION pGetPropertiesFunction,
273 GxRtti::GET_PROPERTY_NUM_FUNCTION pGetPropertyNumFunction,
274 u32 version,
275 u32 magicNumber,
276 GX_CSTR extension,
277 u32 resourceAttribute,
278 RESOURCE_CREATE_FUNCTION pResourceCreateFunction,
279 RESOURCE_LOAD_FUNCTION pResourceLoadFunction
280#if GX_DEVELOP
281 ,
282 RESOURCE_SAVE_FUNCTION pResourceSaveFunction,
283 RESOURCE_FINALIZE_FUNCTION pResourceFinalizeFunction,
284 RESOURCE_MODIFIED_CHECK_FUNCTION pResourceModifiedCheckFunction,
285 GxRttiResource* pConfigRtti
286#endif // GX_DEVELOP
287 );
288
289#if GX_DEVELOP
291 static void initializeReferenceRTTIAll(void);
292#endif //GX_DEVELOP
293private:
294#if GX_DEVELOP
296 void initializeReferenceRTTI(void);
297#endif //GX_DEVELOP
299 GxRttiResource(const GxRttiResource&);
301 GX_FORCE_INLINE const GxRttiResource& operator = (const GxRttiResource&);
302
304 //-------------------------------
306 //-------------------------------
308public:
310 GX_FORCE_INLINE static const GxRttiResource* castRtti(const GxRtti* pRtti);
311#if GX_DEVELOP
313 GX_FORCE_INLINE static GxRttiResource* castRtti(GxRtti* pRtti);
314#endif // GX_DEVELOP
315
317 static const GxRttiResource* getRtti(u32 id);
319 static const GxRttiResource* getRttiFromExtension(GX_CSTR extension);
321 static const GxRttiResource* getRttiFromPath(GX_CSTR path);
322#if GX_DEVELOP
324 static const GxRttiResource* getRttiFromName(GX_CSTR name);
325#endif // GX_DEVELOP
326
327#if GX_DEVELOP
329 const GxRttiResource* getRttiDirectionChild(u32 attribute, b32 isSkipSelf = false) const;
331 const GxRttiResource* getRttiDirectionChild(u32 attribute, GX_CSTR resourcePath, b32 isSkipSelf = false) const;
333 const GxRttiResource* getRttiDirectionParent(u32 attribute, b32 isSkipSelf = false) const;
335 const GxRttiResource* getRttiDirectionParent(u32 attribute, GX_CSTR resourcePath, b32 isSkipSelf = false) const;
337 const GxRttiResource* getRttiOriginal(b32 isSkipSelf = false) const;
339 const GxRttiResource* getRttiOriginal(GX_CSTR resourcePath, b32 isSkipSelf = false) const;
341 const GxRttiResource* getRttiFinalized(b32 isSkipSelf = false) const;
343 const GxRttiResource* getRttiFinalized(GX_CSTR resourcePath, b32 isSkipSelf = false) const;
344#endif // GX_DEVELOP
346 const GxRttiResource* findNodeFromExtension(GX_CSTR extension) const;
348 const GxRttiResource* enumerate(const GxRttiResource* pRootRtti) const;
349
351 void createCallback(GxResBase* pResource, void* pUser) const;
353 b32 load(GxResBase* pResource, GxStream& stream, u32 size) const;
354#if GX_DEVELOP
356 b32 save(GxResBase* pResource, GxStream& stream) const;
358 b32 finalize(GxResBase* pResource) const;
360 b32 isModified(GxStream& stream, u64 lastWriteTime, GX_CSTR resourcePath) const;
362 void setConfigRtti(GxRttiResource* pConfigRtti);
363#endif // GX_DEVELOP
364
366 //-------------------------------
368 //-------------------------------
370public:
372 b32 isRootRtti(void) const { return (_resourceAttribute == RESOURCE_ATTRIBUTE_NOTHING); }
374 GX_FORCE_INLINE b32 isResourceAttribute(RESOURCE_ATTRIBUTE attribute) const { return (_resourceAttribute & attribute) != 0; }
375
377 const GxRttiResource* getParent(void) const { return castRtti(GxRtti::getParent()); }
379 const GxRttiResource* getChild(void) const { return castRtti(GxRtti::getChild()); }
381 const GxRttiResource* getNext(void) const { return castRtti(GxRtti::getNext()); }
382#if GX_DEVELOP
384 GxRttiResource* getParent(void) { return castRtti(GxRtti::getParent()); }
386 GxRttiResource* getChild(void) { return castRtti(GxRtti::getChild()); }
388 GxRttiResource* getNext(void) { return castRtti(GxRtti::getNext()); }
389#endif // GX_DEVELOP
390
392 constexpr u32 getVersion(void) const { return _version; }
394 constexpr u32 getMagicNumber(void) const { return _magicNumber; }
396 COMPRESS_TYPE getCompressType(void) const { return (isResourceAttribute(RESOURCE_ATTRIBUTE_COMPRESS_ZLIB))? COMPRESS_TYPE::ZLIB : COMPRESS_TYPE::NONE; }
398 constexpr GX_CSTR getExtension(void) const { return _extension; }
400 constexpr u32 getResourceAttribute(void) const { return _resourceAttribute; }
401#if GX_DEVELOP
403 constexpr GxRttiResource* getConfigRtti(void) const { return _pConfigRtti; }
405 b32 isReferenceRtti(GxRttiResource* pRttiResource) const;
406#endif // GX_DEVELOP
407
408 // バージョン設定
409 constexpr void setVersion(u32 version) { _version = version; }
410
412 static void forceFinalizedDefault(const GxRtti& rtti);
413
415 //-------------------------------
417 //-------------------------------
419protected:
423 RESOURCE_CREATE_FUNCTION _pResourceCreateFunction;
424 RESOURCE_LOAD_FUNCTION _pResourceLoadFunction;
425#if GX_DEVELOP
426 RESOURCE_SAVE_FUNCTION _pResourceSaveFunction;
427 RESOURCE_FINALIZE_FUNCTION _pResourceFinalizeFunction;
428 RESOURCE_MODIFIED_CHECK_FUNCTION _pResourceModifiedCheckFunction;
429 GxRttiResource* _pConfigRtti;
430 GxRttiResource* _pReferenceRtti[REFERENCE_RTTI_MAX];
431 u32 _referenceRttiCount;
432#endif // GX_DEVELOP
433 GX_CSTR _extension;
434
436};
437
438//---------------------------------------------------------------------------
439// Rtti* → GxRttiResource* 動的キャスト
442//---------------------------------------------------------------------------
443GX_FORCE_INLINE const GxRttiResource* GxRttiResource::castRtti(const GxRtti* pRtti)
444{
445 if( pRtti )
446 {
447 if( pRtti->getType() == GxRtti::TYPE::RESOURCE )
448 {
449 return static_cast<const GxRttiResource*>(pRtti);
450 }
451 }
452 return nullptr;
453}
454
455#if GX_DEVELOP
456//---------------------------------------------------------------------------
457// Rtti* → GxRttiResource* 動的キャスト
461//---------------------------------------------------------------------------
462GX_FORCE_INLINE GxRttiResource* GxRttiResource::castRtti(GxRtti* pRtti)
463{
464 if( pRtti )
465 {
466 if( pRtti->getType() == GxRtti::TYPE::RESOURCE )
467 {
468 return static_cast<GxRttiResource*>(pRtti);
469 }
470 }
471 return nullptr;
472}
473#endif // GX_DEVELOP
474
475GX_CORE_NAMESPACE_END()
@ NONE
何もしない
リソース基底クラス
Definition GxResBase.h:23
実行時型情報クラス
Definition GxRtti.h:154
ICON_TYPE
アイコンタイプ定義
Definition GxRtti.h:202
constexpr GxRtti::TYPE getType(void) const
種類を取得
Definition GxRtti.h:384
TYPE
種類
Definition GxRtti.h:195
@ RESOURCE
リソース用
constexpr GxRtti * getChild(void) const
子を取得
Definition GxRtti.h:388
constexpr GxRtti * getParent(void) const
親を取得
Definition GxRtti.h:386
constexpr GxRtti * getNext(void) const
次の兄弟を取得
Definition GxRtti.h:390
リソース実行時型情報クラス
Definition GxRttiResource.h:188
RESOURCE_ATTRIBUTE
属性定義
Definition GxRttiResource.h:212
const GxRttiResource * getChild(void) const
子のRTTIを取得
Definition GxRttiResource.h:379
const GxRttiResource * getParent(void) const
親のRTTIを取得
Definition GxRttiResource.h:377
static GX_FORCE_INLINE const GxRttiResource * castRtti(const GxRtti *pRtti)
Rtti* → GxRttiResource* 動的キャスト
Definition GxRttiResource.h:443
constexpr GX_CSTR getExtension(void) const
拡張子取得
Definition GxRttiResource.h:398
u32 _version
バージョン
Definition GxRttiResource.h:420
constexpr u32 getResourceAttribute(void) const
リソースの属性取得
Definition GxRttiResource.h:400
RESOURCE_LOAD_FUNCTION _pResourceLoadFunction
リソースロード関数ポインタ
Definition GxRttiResource.h:424
RESOURCE_CREATE_FUNCTION _pResourceCreateFunction
リソース生成時コールバック関数ポインタ
Definition GxRttiResource.h:423
constexpr u32 getMagicNumber(void) const
マジックナンバー取得
Definition GxRttiResource.h:394
u32 _resourceAttribute
リソース属性
Definition GxRttiResource.h:422
b32 isRootRtti(void) const
ルートリソースRTTI判定
Definition GxRttiResource.h:372
constexpr u32 getVersion(void) const
バージョン取得
Definition GxRttiResource.h:392
GX_FORCE_INLINE b32 isResourceAttribute(RESOURCE_ATTRIBUTE attribute) const
リソース属性判定
Definition GxRttiResource.h:374
COMPRESS_TYPE getCompressType(void) const
圧縮タイプ取得
Definition GxRttiResource.h:396
GX_CSTR _extension
拡張子
Definition GxRttiResource.h:433
GxRttiResource(GxRtti::TYPE type, u32 size, u32 id, u32 attribute, GxRtti *pBaseRtti, GxRtti::CREATE_INSTANCE_FUNCTION pCreateInstanceFunction, GxRtti::GET_PROPERTIES_FUNCTION pGetPropertiesFunction, GxRtti::GET_PROPERTY_NUM_FUNCTION pGetPropertyNumFunction, u32 version, u32 magicNumber, GX_CSTR extension, u32 resourceAttribute, RESOURCE_CREATE_FUNCTION pResourceCreateFunction, RESOURCE_LOAD_FUNCTION pResourceLoadFunction)
コンストラクタ
const GxRttiResource * getNext(void) const
次のRTTIを取得
Definition GxRttiResource.h:381
COMPRESS_TYPE
圧縮タイプ定義
Definition GxRttiResource.h:205
u32 _magicNumber
識別用番号
Definition GxRttiResource.h:421
static GX_CSTR EXTENSION_NOTHING
拡張子:なし
Definition GxRttiResource.h:201
ストリーム基礎クラス
Definition GxStream.h:20
32bitブーリアン
Definition GxDefine.h:173