1//************************************ bs::framework - Copyright 2018 Marko Pintera **************************************//
2//*********** Licensed under the MIT license. See LICENSE.md for full terms. This notice is not to be removed. ***********//
3#pragma once
4
5#include "BsCorePrerequisites.h"
6#include "Reflection/BsRTTIType.h"
7#include "Importer/BsShaderImportOptions.h"
8
9namespace bs
10{
11 /** @cond RTTI */
12 /** @addtogroup RTTI-Impl-Core
13 * @{
14 */
15
16 class BS_CORE_EXPORT ShaderImportOptionsRTTI : public RTTIType<ShaderImportOptions, ImportOptions, ShaderImportOptionsRTTI>
17 {
18 private:
19 BS_BEGIN_RTTI_MEMBERS
20 BS_RTTI_MEMBER_PLAIN(languages, 1)
21 BS_END_RTTI_MEMBERS
22
23 std::pair<String, String>& getDefinePair(ShaderImportOptions* obj, UINT32 idx)
24 {
25 return mDefinePairs[idx];
26 }
27
28 void setDefinePair(ShaderImportOptions* obj, UINT32 idx, std::pair<String, String>& val)
29 {
30 obj->mDefines[val.first] = val.second;
31 }
32
33 UINT32 getNumDefines(ShaderImportOptions* obj) { return (UINT32)obj->mDefines.size(); }
34 void setNumDefines(ShaderImportOptions* obj, UINT32 val) { /* Do nothing */ }
35
36 public:
37 ShaderImportOptionsRTTI()
38 {
39 addPlainArrayField("mDefines", 0, &ShaderImportOptionsRTTI::getDefinePair,
40 &ShaderImportOptionsRTTI::getNumDefines, &ShaderImportOptionsRTTI::setDefinePair,
41 &ShaderImportOptionsRTTI::setNumDefines);
42 }
43
44 /** @copydoc ShaderImportOptionsRTTI::onSerializationStarted */
45 void onSerializationStarted(IReflectable* obj, SerializationContext* context) override
46 {
47 ShaderImportOptions* importOptions = static_cast<ShaderImportOptions*>(obj);
48
49 UnorderedMap<String, String>& defines = importOptions->mDefines;
50 for (auto& entry : defines)
51 mDefinePairs.push_back(entry);
52 }
53
54 /** @copydoc RTTIType::getRTTIName */
55 const String& getRTTIName() override
56 {
57 static String name = "ShaderImportOptions";
58 return name;
59 }
60
61 /** @copydoc RTTIType::getRTTIId */
62 UINT32 getRTTIId() override
63 {
64 return TID_ShaderImportOptions;
65 }
66
67 /** @copydoc RTTIType::newRTTIObject */
68 SPtr<IReflectable> newRTTIObject() override
69 {
70 return bs_shared_ptr_new<ShaderImportOptions>();
71 }
72
73 private:
74 Vector<std::pair<String, String>> mDefinePairs;
75 };
76
77 /** @} */
78 /** @endcond */
79}