8#ifndef ARP_USE_ARP_SYSTEM_CORE 
   19template <
typename T> 
class slim_delegate;
 
   27template<class R, class ...A>
 
   28class slim_delegate<R(A...)>
 
   31    using InvokerPtr = R(*)(
void*, A && ...);
 
   34    slim_delegate(
const slim_delegate&) = 
default;
 
   35    slim_delegate(slim_delegate&&)noexcept = default;
 
   36    slim_delegate& operator=(const slim_delegate&) = default;
 
   37    slim_delegate& operator=(slim_delegate&&)noexcept = default;
 
   42    template <R(*TFunction)(A...)>
 
   44    static slim_delegate create(
void) noexcept
 
   46        return{ functionInvoker<TFunction> };
 
   50    template <
class C, R(C::*TMethod)(A...)>
 
   52    static slim_delegate create(C* pObject) noexcept
 
   54        return{ pObject, methodInvoker<C, TMethod> };
 
   58    template <
class C, R(C::*TMethod)(A...)>
 
   60    static slim_delegate create(C& obj) noexcept
 
   62        return{ &obj, methodInvoker<C, TMethod> };
 
   66    template <
class C, R(C::*TMethod)(A...)
const>
 
   68    static slim_delegate create(const C* pObject) noexcept
 
   70        return{ 
const_cast<C*
>(pObject), constMethodInvoker<C, TMethod> };
 
   74    template <
class C, R(C::*TMethod)(A...)
const>
 
   76    static slim_delegate create(const C& obj) noexcept
 
   78        return{ 
const_cast<C*
>(&obj), constMethodInvoker<C, TMethod> };
 
   82    bool operator==(
const slim_delegate& rhs)
const noexcept 
   84        if (this->is_static())
 
   86            return this->pInvoker == rhs.pInvoker;
 
   89        return (this->pInstance == rhs.pInstance) && (this->pInvoker == rhs.pInvoker);
 
   92    bool operator!=(
const slim_delegate& rhs)
const noexcept 
   94        return !(operator==(rhs));
 
   98    slim_delegate(std::nullptr_t) noexcept : slim_delegate(
nullptr, 
nullptr) { }
 
  100    bool operator==(std::nullptr_t)
const noexcept 
  102        if (this->is_static())
 
  104            return this->pInvoker == 
nullptr;
 
  107        return this->pInstance == 
nullptr || this->pInvoker == 
nullptr;
 
  110    bool operator!=(std::nullptr_t)
const noexcept 
  112        return !(*
this == 
nullptr);
 
  115    explicit operator bool()const noexcept
 
  117        return *
this != 
nullptr;
 
  121    R operator()(A... args)
 const 
  123        return pInvoker(this->pInstance, std::forward<A>(args)...);
 
  127    slim_delegate(InvokerPtr invokerPtr) noexcept
 
  128        : pInstance(
this), pInvoker(invokerPtr) 
 
  132    slim_delegate(
void* pObject, InvokerPtr invokerPtr) noexcept
 
  133        : pInstance(pObject), pInvoker(invokerPtr)
 
  137    bool is_static(
void)
const 
  139        return this->pInstance == 
this;
 
  143    template <R(*TFunction)(A...)>
 
  144    static R functionInvoker(
void* 
const, A&& ... args)
 
  146        return TFunction(std::move(args)...);
 
  149    template <
class C, R(C::*TMethod)(A...)>
 
  150    static R methodInvoker(
void* pObject, A&& ... args)
 
  152        return (
static_cast<C*
>(pObject)->*TMethod)(std::move(args)...);
 
  155    template <
class C, R(C::*TMethod)(A...) 
const>
 
  156    static R constMethodInvoker(
void* pObject, A&& ... args)
 
  158        return (
static_cast<const C*
>(pObject)->*TMethod)(std::move(args)...);
 
Root namespace for the PLCnext API
 
class ARP_DEPRECATED("Use Arp::Enum<T> instead.") EnumStrings
Deprecated! The class implements an adapter for enums to define the string literals of the enum entri...
Definition: EnumStrings.hxx:38