PLCnext API Documentation 25.0.2.69
StaticFunctor.hxx
1
2//
3// Copyright Phoenix Contact GmbH & Co. KG
4//
6#pragma once
8#include "Arp/System/Core/Impl/DelegateFunctorBase.hxx"
9
10namespace Arp { namespace System { namespace Core { namespace Impl
11{
12
14
15template <typename T> class StaticFunctor;
16
18// class MethodFunctor is implemented completely implicite inline to avoid
19// code bloat in commonly used Core classe and therefore reduce compile time
20template<class R, class ...A>
21class StaticFunctor<R(A...)> : public DelegateFunctorBase<StaticFunctor<R(A...)>>
22{
23public: // typedefs/usings
24 using FunctionPtr = R(*)(A...);
25
26public: // construction/destruction
27 StaticFunctor(R(*pFunctionArg)(A...)) : pFunction(pFunctionArg) {}
28 StaticFunctor(const StaticFunctor& arg) = default;
29 StaticFunctor& operator=(const StaticFunctor& arg) = default;
30 virtual ~StaticFunctor(void)noexcept = default;
31
32public: // static operations
33 template<class ...Args>
34 static R Invoke(void* pThis, Args&& ... args)
35 {
36 return static_cast<StaticFunctor*>(pThis)->pFunction(std::forward<Args>(args)...);
37 }
38
39protected: // overidden operations
40 bool Equals(const StaticFunctor& other)override
41 {
42 return this->pFunction == other.pFunction;
43 }
44
45private: // fields
46 FunctionPtr pFunction;
47};
48
50// inline methods of class StaticFunctor
51
53
54}}}} // end of namespace Arp::System::Core::Impl
@ Equals
Start recording if TriggerVariable1 is equal to TriggerVariable2.
Root namespace for the PLCnext API