Plasma Engine  2.0
Loading...
Searching...
No Matches
ScriptRTTI.h
1#pragma once
2
3#include <Core/CoreDLL.h>
4#include <Foundation/Containers/ArrayMap.h>
5#include <Foundation/Reflection/Reflection.h>
6#include <Foundation/Strings/HashedString.h>
7#include <Foundation/Types/SharedPtr.h>
8
9class plWorld;
10
11class PL_CORE_DLL plScriptRTTI : public plRTTI, public plRefCountingImpl
12{
13 PL_DISALLOW_COPY_AND_ASSIGN(plScriptRTTI);
14
15public:
16 enum
17 {
18 NumInplaceFunctions = 7
19 };
20
23
24 plScriptRTTI(plStringView sName, const plRTTI* pParentType, FunctionList&& functions, MessageHandlerList&& messageHandlers);
26
27 const plAbstractFunctionProperty* GetFunctionByIndex(plUInt32 uiIndex) const;
28
29private:
30 plString m_sTypeNameStorage;
31 FunctionList m_FunctionStorage;
32 MessageHandlerList m_MessageHandlerStorage;
35};
36
38{
39public:
42
43private:
44 plHashedString m_sPropertyNameStorage;
45};
46
48{
49 const plRTTI* m_pType = nullptr;
51};
52
54{
55public:
58
59 void FillMessagePropertyValues(const plMessage& msg, plDynamicArray<plVariant>& out_propertyValues);
60
61private:
63};
64
65class PL_CORE_DLL plScriptInstance
66{
67public:
68 plScriptInstance(plReflectedClass& inout_owner, plWorld* pWorld);
69 virtual ~plScriptInstance() = default;
70
71 plReflectedClass& GetOwner() { return m_Owner; }
72 plWorld* GetWorld() { return m_pWorld; }
73
74 virtual void SetInstanceVariables(const plArrayMap<plHashedString, plVariant>& parameters);
75 virtual void SetInstanceVariable(const plHashedString& sName, const plVariant& value) = 0;
76 virtual plVariant GetInstanceVariable(const plHashedString& sName) = 0;
77
78private:
79 plReflectedClass& m_Owner;
80 plWorld* m_pWorld = nullptr;
81};
82
83struct PL_CORE_DLL plScriptAllocator
84{
85 static plAllocator* GetAllocator();
86};
87
89#define PL_SCRIPT_NEW(type, ...) PL_NEW(plScriptAllocator::GetAllocator(), type, __VA_ARGS__)
The base class for a property that represents a function.
Definition AbstractProperty.h:535
The base class for all message handlers that a type provides.
Definition MessageHandler.h:12
Base class for all memory allocators.
Definition Allocator.h:23
See plArrayMapBase for details.
Definition ArrayMap.h:149
This class encapsulates an array and it's size. It is recommended to use this class instead of plain ...
Definition ArrayPtr.h:37
Definition DynamicArray.h:81
This class is optimized to take nearly no memory (sizeof(void*)) and to allow very fast checks whethe...
Definition HashedString.h:25
Base class for all message types. Each message type has it's own id which is used to dispatch message...
Definition Message.h:22
This class holds information about reflected types. Each instance represents one type that is known t...
Definition RTTI.h:30
PL_ALWAYS_INLINE plRTTIAllocator * GetAllocator() const
Returns the object through which instances of this type can be allocated.
Definition RTTI.h:76
Definition RefCounted.h:7
All classes that should be dynamically reflectable, need to be derived from this base class.
Definition DynamicRTTI.h:86
Definition ScriptRTTI.h:38
Definition ScriptRTTI.h:66
Definition ScriptRTTI.h:54
Definition ScriptRTTI.h:12
plStringView represent a read-only sub-string of a larger string, as it can store a dedicated string ...
Definition StringView.h:34
plVariant is a class that can store different types of variables, which is useful in situations where...
Definition Variant.h:44
A world encapsulates a scene graph of game objects and various component managers and their component...
Definition World.h:22
Definition ScriptRTTI.h:84
Definition ScriptRTTI.h:48