* A function available over the internal cluster API. * * @ingroup base */
| 20 | * @ingroup base |
| 21 | */ |
| 22 | class ApiFunction final : public Object |
| 23 | { |
| 24 | public: |
| 25 | DECLARE_PTR_TYPEDEFS(ApiFunction); |
| 26 | |
| 27 | typedef std::function<Value(const MessageOrigin::Ptr& origin, const Dictionary::Ptr&)> Callback; |
| 28 | |
| 29 | ApiFunction(const char* name, Callback function); |
| 30 | |
| 31 | const char* GetName() const noexcept |
| 32 | { |
| 33 | return m_Name; |
| 34 | } |
| 35 | |
| 36 | Value Invoke(const MessageOrigin::Ptr& origin, const Dictionary::Ptr& arguments); |
| 37 | |
| 38 | static ApiFunction::Ptr GetByName(const String& name); |
| 39 | static void Register(const String& name, const ApiFunction::Ptr& function); |
| 40 | |
| 41 | private: |
| 42 | const char* m_Name; |
| 43 | Callback m_Callback; |
| 44 | }; |
| 45 | |
| 46 | /** |
| 47 | * A registry for API functions. |
nothing calls this directly
no outgoing calls
no test coverage detected