PLCnext API Documentation 25.0.2.69
ConstMethodFunctor.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
14template <typename T> class ConstMethodFunctor;
15
17// class MethodFunctor is implemented completely implicite inline to avoid
18// code bloat in commonly used Core classe and therefore reduce compile time
19template<class C, class R, class ...A>
20class ConstMethodFunctor<R(C::*)(A...)const> : public DelegateFunctorBase<ConstMethodFunctor<R(C::*)(A...)const>>
21{
22public: // typedefs/usings
23 using MethodPtr = R(C::*)(A...)const;
24
25public: // construction/destruction
26 ConstMethodFunctor(const C* pObjectArg, R(C::*pMethodArg)(A...)const) : pObject(pObjectArg), pMethod(pMethodArg) {}
27 ConstMethodFunctor(const C& objectArg, R(C::*pMethodArg)(A...)const) : pObject(&objectArg), pMethod(pMethodArg) {}
28 ConstMethodFunctor(const ConstMethodFunctor& arg) = default;
29 ConstMethodFunctor& operator=(const ConstMethodFunctor& arg) = default;
30 ~ConstMethodFunctor(void)noexcept override = default;
31
32public: // static operations
33 template<class ...Args>
34 static R Invoke(void* pArg, Args&& ...args)
35 {
36 ConstMethodFunctor* pThis = static_cast<ConstMethodFunctor*>(pArg);
37 return ((pThis->pObject)->*(pThis->pMethod))(std::forward<Args>(args)...);
38 }
39
40protected: // overidden operations
41 bool Equals(const ConstMethodFunctor& other)override
42 {
43 return this->pObject == other.pObject && this->pMethod == other.pMethod;
44 }
45
46private: // fields
47 const C* pObject;
48 MethodPtr pMethod;
49};
50
52// inline methods of class MethodDelegateFunctor
53
55
56}}}} // end of namespace Arp::System::Core::Impl
@ Equals
Start recording if TriggerVariable1 is equal to TriggerVariable2.
Root namespace for the PLCnext API