| 1 | #pragma once |
| 2 | |
| 3 | namespace al { |
| 4 | class FunctorBase { |
| 5 | public: |
| 6 | inline FunctorBase() = default; |
| 7 | inline FunctorBase(const FunctorBase& copy) = default; |
| 8 | virtual void operator()() const = 0; |
| 9 | virtual FunctorBase* clone() const = 0; |
| 10 | |
| 11 | virtual ~FunctorBase() {} |
| 12 | }; |
| 13 | |
| 14 | template <class T, class F> |
| 15 | class FunctorV0M : public FunctorBase { |
| 16 | public: |
| 17 | inline FunctorV0M() = default; |
| 18 | |
| 19 | inline FunctorV0M(T objPointer, F functPointer) |
| 20 | : mObjPointer(objPointer), mFunctPointer(functPointer) {} |
| 21 | |
| 22 | inline FunctorV0M(const FunctorV0M<T, F>& copy) = default; |
| 23 | |
| 24 | void operator()() const override { (mObjPointer->*mFunctPointer)(); } |
| 25 | |
| 26 | FunctorV0M<T, F>* clone() const override { return new FunctorV0M<T, F>(*this); } |
| 27 | |
| 28 | private: |
| 29 | T mObjPointer = nullptr; |
| 30 | F mFunctPointer = nullptr; |
| 31 | }; |
| 32 | } // namespace al |
| 33 | |