PLCnext API Documentation 25.0.2.69
StaticFunctor.hxx
1
2//
3// Copyright Phoenix Contact GmbH & Co. KG
4//
6#pragma once
7#include "Arp/Base/Core/Detail/DelegateFunctorBase.hxx"
8namespace Arp::Base::Core
9{
10
12
13template <typename T> class StaticFunctor;
14
16template<class R, class ...A>
17class StaticFunctor<R(A...)> : public DelegateFunctorBase<StaticFunctor<R(A...)>>
18{
19public: // usings
20 using FunctionPtr = R(*)(A...);
21
22public: // construction/destruction
23 StaticFunctor(R(*pFunction)(A...))
24 : pFunction(pFunction)
25 {
26 }
27
28public: // static operations
29 template<class ...Args>
30 static R Invoke(IDelegateFunctor* pFunctor, Args... args)
31 {
32 auto* pThis = dynamic_cast<StaticFunctor*>(pFunctor);
33 return std::invoke(pThis->pFunction, args...);
34 }
35
36protected: // overridden operations
37 bool EqualsTo(const StaticFunctor& other)override
38 {
39 return this->pFunction == other.pFunction;
40 }
41
42private: // fields
43 FunctionPtr pFunction;
44};
45
47
48} // end of namespace Arp::Base::Core