Plasma Engine  2.0
Loading...
Searching...
No Matches
ConsoleFunction.h
1#pragma once
2
3#include <Core/CoreDLL.h>
4#include <Foundation/Types/Delegate.h>
5#include <Foundation/Types/Variant.h>
6#include <Foundation/Utilities/EnumerableClass.h>
7
36class PL_CORE_DLL plConsoleFunctionBase : public plEnumerable<plConsoleFunctionBase>
37{
38 PL_DECLARE_ENUMERABLE_CLASS(plConsoleFunctionBase);
39
40public:
42 plConsoleFunctionBase(plStringView sFunctionName, plStringView sDescription)
43 : m_sFunctionName(sFunctionName)
44 , m_sDescription(sDescription)
45 {
46 }
47
49 plStringView GetName() const { return m_sFunctionName; }
50
52 plStringView GetDescription() const { return m_sDescription; }
53
55 virtual plUInt32 GetNumParameters() const = 0;
56
58 virtual plVariant::Type::Enum GetParameterType(plUInt32 uiParam) const = 0;
59
64 virtual plResult Call(plArrayPtr<plVariant> params) = 0;
65
66private:
67 plStringView m_sFunctionName;
68 plStringView m_sDescription;
69};
70
71
74template <typename R>
78
79
80#define ARG_COUNT 0
81#include <Core/Console/Implementation/ConsoleFunctionHelper_inl.h>
82#undef ARG_COUNT
83
84#define ARG_COUNT 1
85#include <Core/Console/Implementation/ConsoleFunctionHelper_inl.h>
86#undef ARG_COUNT
87
88#define ARG_COUNT 2
89#include <Core/Console/Implementation/ConsoleFunctionHelper_inl.h>
90#undef ARG_COUNT
91
92#define ARG_COUNT 3
93#include <Core/Console/Implementation/ConsoleFunctionHelper_inl.h>
94#undef ARG_COUNT
95
96#define ARG_COUNT 4
97#include <Core/Console/Implementation/ConsoleFunctionHelper_inl.h>
98#undef ARG_COUNT
99
100#define ARG_COUNT 5
101#include <Core/Console/Implementation/ConsoleFunctionHelper_inl.h>
102#undef ARG_COUNT
103
104#define ARG_COUNT 6
105#include <Core/Console/Implementation/ConsoleFunctionHelper_inl.h>
106#undef ARG_COUNT
This class encapsulates an array and it's size. It is recommended to use this class instead of plain ...
Definition ArrayPtr.h:37
Base class for all types of plConsoleFunction, represents functions to be exposed to plConsole.
Definition ConsoleFunction.h:37
virtual plVariant::Type::Enum GetParameterType(plUInt32 uiParam) const =0
Returns the type of the n-th parameter.
virtual plUInt32 GetNumParameters() const =0
Returns the number of parameters that this function takes.
plStringView GetDescription() const
Returns the description of the function as it should appear in the console.
Definition ConsoleFunction.h:52
plConsoleFunctionBase(plStringView sFunctionName, plStringView sDescription)
The constructor takes the function name and description as it should appear in the console.
Definition ConsoleFunction.h:42
plStringView GetName() const
Returns the name of the function as it should be exposed in the console.
Definition ConsoleFunction.h:49
virtual plResult Call(plArrayPtr< plVariant > params)=0
Calls the function. Each parameter must be put into an plVariant and all of them are passed along as ...
Implements the functionality of plConsoleFunctionBase for functions with different parameter types....
Definition ConsoleFunction.h:76
Base class to add the ability to another class to enumerate all active instance of it,...
Definition EnumerableClass.h:28
plStringView represent a read-only sub-string of a larger string, as it can store a dedicated string ...
Definition StringView.h:34
Default enum for returning failure or success, instead of using a bool.
Definition Types.h:54
Enum
This enum describes the type of data that is currently stored inside the variant. Note that changes t...
Definition VariantType.h:26