FAST.Framework  1.0.0
FSlot.h
1 /******************************************************************************
2 **
3 ** FAST.Framework
4 **
5 ** Created: 2023-10-11
6 ** Author: Boris Fast
7 ** Mail: support@fast-framework.com
8 **
9 ******************************************************************************/
10 
11 #ifndef FSLOT_H
12 #define FSLOT_H
13 
14 #include <functional>
15 
16 using namespace std;
17 
18 #include "FObject.h"
19 #include "FString.h"
20 
24 template <typename ...Args>
25 class FSlot : public FObject
26 {
27  public:
28  inline FSlot(std::function<void(Args...)> function) :
29  init(true), function(function) { };
30  inline FSlot() : init(false) { };
31  virtual ~FSlot() = default;
32 
33  inline void Call(Args... args) const
34  {
35  if (this->init) this->function(args...);
36  }
37 
38  inline void SetSlotFunction(std::function<void(Args...)> function)
39  {
40  this->init = true;
41  this->function = function;
42  }
43 
44  inline const type_info& GetType() override { return typeid(FSlot); }
45  inline FString GetName() const override
46  {
47  return typeid(FSlot).name();
48  }
49 
50  private:
51  Boolean init;
52  std::function<void(Args...)> function;
53 };
54 
55 #endif // FSLOT_H
Definition: FObject.h:50
Definition: FSlot.h:26
const type_info & GetType() override
Returns the type info over object.
Definition: FSlot.h:44
FString GetName() const override
< Returns the name of object
Definition: FSlot.h:45
virtual ~FSlot()=default
Constructor of slot object.
void Call(Args... args) const
< Execute call
Definition: FSlot.h:33
void SetSlotFunction(std::function< void(Args...)> function)
Definition: FSlot.h:38
Definition: FString.h:22