PLCnext API Documentation 25.0.2.69
MethodFunctor.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 MethodFunctor;
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 C, class R, class ...A>
21class MethodFunctor<R(C::*)(A...)> : public DelegateFunctorBase<MethodFunctor<R(C::*)(A...)>>
22{
23public: // typedefs/usings
24 using MethodPtr = R(C::*)(A...);
25
26public: // construction/destruction
27 MethodFunctor(C* pObjectArg, R(C::*pMethodArg)(A...)) : pObject(pObjectArg), pMethod(pMethodArg) {}
28 MethodFunctor(C& objectArg, R(C::*pMethodArg)(A...)) : pObject(&objectArg), pMethod(pMethodArg) {}
29 MethodFunctor(const MethodFunctor& arg) = default;
30 MethodFunctor& operator=(const MethodFunctor& arg) = default;
31 virtual ~MethodFunctor(void)noexcept = default;
32
33public: // static operations
34 template<class ...Args>
35 static R Invoke(void* pArg, Args&& ... args)
36 {
37 MethodFunctor* pThis = static_cast<MethodFunctor*>(pArg);
38 return ((pThis->pObject)->*(pThis->pMethod))(std::forward<Args>(args)...);
39 }
40
41protected: // overidden operations
42 bool Equals(const MethodFunctor& other)override
43 {
44 return this->pObject == other.pObject && this->pMethod == other.pMethod;
45 }
46
47private: // fields
48 C* pObject;
49 MethodPtr pMethod;
50};
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