Files
qt6-migration-pipeline/external/tmsif/include/tmsif/api/BuiltInTest.hpp
T
2026-10-23 16:13:31 +00:00

1230 lines
60 KiB
C++

///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//
// GENERATED CODE - do not edit (Generated by ddkit/genModelApi)
//
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// BuiltInTest.hpp (rmodel-api)
#ifndef BuiltInTest_API
#define BuiltInTest_API
#include <ddkit/actors/CallbackInfo.hpp>
#include <ddkit/actors/ActorInfo.hpp>
#include <ddkit/actors/Session.hpp>
#include <ddkit/actors/MonitorSession.hpp>
#include <ddkit/actors/BackwardManager.hpp>
#include <ddkit/actors/SessionImpl.hpp>
#include <ddkit/utils/CallbackWrapper.hpp>
#include <ddkit/actors/SessionFactory.hpp>
#include <tmsif/msg/BuiltInTest.hpp>
#include <tmsif/tmsif_export.hpp>
#include <string>
#include <vector>
#include <type_traits>
namespace ddkit {
namespace actors {
class IActor;
typedef std::shared_ptr<IActor> ActorPtr;
typedef std::weak_ptr<IActor> ActorWeakPtr;
} // namespace actors
} // namespace ddkit
namespace M_BuiltInTest {
class TMSIF_EXPORT IServiceFactory {
public:
typedef M_BuiltInTest::IService InterfaceType;
/// @brief Creates a sender for writing to an IService
TMSIF_DEPRECATED
static IService* create(std::string const& serviceName, int domain);
/// @brief Deletes the sender received from create()
/// - the sender must not be used any more afterwards (undefined behaviour)
TMSIF_DEPRECATED
static void remove(M_BuiltInTest::IService* sender);
/// @brief deletes all senders received from create()
/// - if create() was called only once, this is equivalent to remove()
TMSIF_DEPRECATED
static void shutdown();
TMSIF_DEPRECATED
static IService* create(std::string const& serviceName);
/// @brief calling create with clientName [IServiceFactory only]
/// - clientName is the former clientId, which had problems:
/// - Ids of user-space are conceptually mixed with internal ids to distinguish actors.
/// - you may use this signature and give clientName.
/// - it will not be used internally for "ID"entifiying your client, hence the name 'clientName'
/// - you will get the clientName instead of its actorId, when calling getSource() during callbacks on service.
/// - if used here (IServiceFactory::create) and in IClientObsFactory::add, you must give the same clientName!
/// - it is theoretically possible, that the service will read "unknown" instead of your clientName on samples
/// sent very early after creation of actor.
TMSIF_DEPRECATED
static IService* create(std::string const& serviceName, int domain, std::string const& clientName);
};
class TMSIF_EXPORT IServiceObsFactory {
public:
typedef std::vector<std::string> StringSet;
typedef M_BuiltInTest::IService InterfaceType;
/// @brief Register an observer for getting IService-callbacks on it
template<class IServiceDerived>
TMSIF_DEPRECATED
static void add(std::string const& serviceName, IServiceDerived* obs, int domain);
TMSIF_DEPRECATED
static void addFiltered(std::string const& serviceName, M_BuiltInTest::IService* obs, std::string const& ignoredOps);
/// @brief Register manually an observer for getting IService-callbacks on it
/// - semicolon-separated std::string-list of not-to-override-methods
/// - unclear logic about derived ifaces, error-prone-syntax, better do not use
/// - logically deprecated, better use add() or new oo-API instead
TMSIF_DEPRECATED
static void addFiltered(std::string const& serviceName, M_BuiltInTest::IService* obs, std::string const& ignoredOps, int domain);
/// @brief Unregister observer previously registered with add...()
TMSIF_DEPRECATED
static void removeObs(M_BuiltInTest::IService* observer);
/// @brief - deprecated: on call a warning is issued, but function still works: serviceName is ignored.
/// - you must use add/remove 'normally' (one registration per observer), so better call removeObs(1 param) above!
TMSIF_DEPRECATED
static void remove(std::string const& serviceName, M_BuiltInTest::IService* observer);
/// @brief unregisters all observers previously registered with add...()
/// - if add() called only once, this is equivalent to removeObs()
TMSIF_DEPRECATED
static void shutdown();
/// @brief Use the new Api `ddkit::actors::CallbackInfo::current()` instead.
/// Call this method only from inside a callback.
TMSIF_DEPRECATED
static std::string getSource();
IServiceObsFactory() {}
private:
static void addCustom(M_BuiltInTest::IService* obs, StringSet custom, std::string serviceName, int domain);
static void addCustom(M_BuiltInTest::IService* obs, StringSet custom, std::string serviceName, int domain,
std::string clientName); // only used on client!
};
class IClient;
typedef std::shared_ptr<IClient> IClientPtr;
/// @brief new oo-api
class TMSIF_EXPORT Service {
public:
typedef M_BuiltInTest::IService InterfaceTypeReceiver;
typedef M_BuiltInTest::IClient InterfaceTypeSender;
#ifndef SWIG
/// @brief Create dds-readers + writers. remove on Service leaving scope (overridden methods are auto-detected),
template<typename T, typename IServiceDerived>
static typename std::enable_if<
std::is_same<T, int>::value &&
std::is_same<IServiceDerived, std::vector<ddkit::callback::Base*>
>::value, Service>::type
create(T domain, std::string serviceName, IServiceDerived& callbacks);
/// @brief Create dds-readers + writers. remove on Service leaving scope (overridden methods are auto-detected)
template<typename T, typename IServiceDerived>
static typename std::enable_if<
std::is_same<T, int>::value &&
!std::is_same<IServiceDerived, std::vector<ddkit::callback::Base*>
>::value, Service>::type
create(T domain, std::string serviceName, IServiceDerived& callbacks);
/// @brief Create dds-readers + writers. remove on Service leaving scope (overridden methods are auto-detected)
template<typename T, typename IServiceDerived>
static typename std::enable_if<
std::is_same<T, std::shared_ptr<ddkit::actors::Session>>::value &&
std::is_same<IServiceDerived, std::vector<ddkit::callback::Base*>
>::value, Service>::type
create(T session, std::string serviceName, IServiceDerived& callbacks);
/// @brief Create dds-readers + writers. remove on Service leaving scope (overridden methods are auto-detected)
template<typename T, typename IServiceDerived>
static typename std::enable_if<
std::is_same<T, std::shared_ptr<ddkit::actors::Session>>::value &&
!std::is_same<IServiceDerived, std::vector<ddkit::callback::Base*>
>::value, Service>::type
create(T session, std::string serviceName, IServiceDerived& callbacks);
static Service createWriteOnly(int domain, std::string serviceName);
static Service createWriteOnly(std::shared_ptr<ddkit::actors::Session> session, std::string serviceName);
#endif
/// @brief call operations on matching Clients
IClientPtr operator->();
Service& operator=(Service&& other);
void invalidate();
#ifndef SWIG
/// @brief (only for monitors: Listener, Inspector / resulting services are read-only!)
template<typename T, typename IServiceDerived>
static typename std::enable_if<
std::is_same<T, int>::value &&
std::is_same<IServiceDerived, std::vector<ddkit::callback::Base*>
>::value, Service>::type
createMonitor(T domain, std::string serviceName, IServiceDerived& callbacks);
/// @brief (only for monitors: Listener, Inspector / resulting services are read-only!)
template<typename T, typename IServiceDerived>
static typename std::enable_if<
std::is_same<T, int>::value &&
!std::is_same<IServiceDerived, std::vector<ddkit::callback::Base*>
>::value, Service>::type
createMonitor(T domain, std::string serviceName, IServiceDerived& callbacks);
/// @brief (only for monitors: Listener, Inspector / resulting services are read-only!)
template<typename T, typename IServiceDerived>
static typename std::enable_if<
std::is_same<T, std::shared_ptr<ddkit::actors::MonitorSession>>::value &&
std::is_same<IServiceDerived, std::vector<ddkit::callback::Base*>
>::value, Service>::type
createMonitor(T monitorSession, std::string serviceName, IServiceDerived& callbacks);
/// @brief (only for monitors: Listener, Inspector / resulting services are read-only!)
template<typename T, typename IServiceDerived>
static typename std::enable_if<
std::is_same<T, std::shared_ptr<ddkit::actors::MonitorSession>>::value &&
!std::is_same<IServiceDerived, std::vector<ddkit::callback::Base*>
>::value, Service>::type
createMonitor(T monitorSession, std::string serviceName, IServiceDerived& callbacks);
// MULTIPLEX
/// @brief Reading all serviceNames.
template<typename T, typename IServiceDerived>
static typename std::enable_if<
std::is_same<T, int>::value &&
std::is_same<IServiceDerived, std::vector<ddkit::callback::Base*>
>::value, Service>::type
createMonitor(T domain, IServiceDerived& callbacks);
/// @brief Reading all serviceNames.
template<typename T, typename IServiceDerived>
static typename std::enable_if<
std::is_same<T, int>::value &&
!std::is_same<IServiceDerived, std::vector<ddkit::callback::Base*>
>::value, Service>::type
createMonitor(T domain, IServiceDerived& callbacks);
/// @brief Reading all serviceNames.
template<typename T, typename IServiceDerived>
static typename std::enable_if
<std::is_same<T, std::shared_ptr<ddkit::actors::MonitorSession>>::value &&
std::is_same<IServiceDerived, std::vector<ddkit::callback::Base*>
>::value, Service>::type
createMonitor(T monitorSession, IServiceDerived& callbacks);
/// @brief Reading all serviceNames.
template<typename T, typename IServiceDerived>
static typename std::enable_if<
std::is_same<T, std::shared_ptr<ddkit::actors::MonitorSession>>::value &&
!std::is_same<IServiceDerived, std::vector<ddkit::callback::Base*>
>::value, Service>::type
createMonitor(T monitorSession, IServiceDerived& callbacks);
#endif
/// @brief true, if dds-able (false, if default-constructed or Session destructed)
bool isValid() const;
/// @brief Construct an invalid service-obj
/// (sometimes needed for beeing data-member, prefer create() instead)
Service();
Service(Service&& other);
Service(const Service& other) = default;
~Service();
std::shared_ptr<ddkit::actors::Session> getSession();
std::shared_ptr<ddkit::actors::MonitorSession> getMonitorSession();
// SWIG Wrapper only
static Service* _internalSwigCreateWriteOnly(int domain, std::string serviceName);
static Service* _internalSwigCreateWriteOnly(std::shared_ptr<ddkit::actors::Session> session, std::string serviceName);
static Service* _internalSwigCreate(int domain, std::string serviceName, IService& callbacks);
static Service* _internalSwigCreateMonitor(int domain, std::string serviceName, IService& callbacks);
static Service* _internalSwigCreateMonitor(int domain, IService& callbacks); // reading all serviceNames!
static Service* _internalSwigCreate(std::shared_ptr<ddkit::actors::Session> session, std::string serviceName, IService& callbacks);
static Service* _internalSwigCreateMonitor(std::shared_ptr<ddkit::actors::MonitorSession> session, std::string serviceName, IService& callbacks);
static Service* _internalSwigCreateMonitor(std::shared_ptr<ddkit::actors::MonitorSession> session, IService& callbacks); // reading all serviceNames!
private:
#ifdef _WIN32
#pragma warning(disable:4251) // MSVC would warn about shared/export/dll-inline-stuff here
#endif
ddkit::actors::ActorWeakPtr m_actor;
bool m_discardSenderOnDestruction;
bool m_discardObserverOnDestruction;
std::shared_ptr<ddkit::actors::Session> m_session;
std::shared_ptr<ddkit::actors::MonitorSession> m_monitorSession;
#ifdef _WIN32
#pragma warning(default:4251)
#endif
ddkit::actors::IActor& actor();
Service(ddkit::actors::ActorPtr actor, bool discardSenderOnDestruction, bool discardObserverOnDestruction,
std::shared_ptr<ddkit::actors::Session> session, std::shared_ptr<ddkit::actors::MonitorSession> monitorSession);
static bool isCheckMostDerivedClassType(ddkit::actors::Session& session);
static bool isCheckMostDerivedClassType(ddkit::actors::MonitorSession& monitorSession);
static Service createCustom(std::shared_ptr<ddkit::actors::Session> session, std::string serviceName, IService& callbacks, std::vector<std::string> methods);
static Service createCustomReadOnly(std::shared_ptr<ddkit::actors::MonitorSession> monitorSession, std::string serviceName, IService& callbacks, std::vector<std::string> methods);
static Service createCustomReadOnlyMultiplex(std::shared_ptr<ddkit::actors::MonitorSession> monitorSession, IService& callbacks, std::vector<std::string> methods);
static Service createCustom(std::shared_ptr<ddkit::actors::Session> session, std::string serviceName, std::map<std::string, std::vector<ddkit::callback::Base*>> callbacks, std::vector<std::string> methods);
static Service createCustomReadOnly(std::shared_ptr<ddkit::actors::MonitorSession> monitorSession, std::string serviceName, std::map<std::string, std::vector<ddkit::callback::Base*>> callbacks, std::vector<std::string> methods);
static Service createCustomReadOnlyMultiplex(std::shared_ptr<ddkit::actors::MonitorSession> monitorSession, std::map<std::string, std::vector<ddkit::callback::Base*>> callbacks, std::vector<std::string> methods);
};
class TMSIF_EXPORT IClientFactory {
public:
typedef M_BuiltInTest::IClient InterfaceType;
/// @brief Creates a sender for writing to an IClient
TMSIF_DEPRECATED
static IClient* create(std::string const& serviceName, int domain);
/// @brief Deletes the sender received from create()
/// - the sender must not be used any more afterwards (undefined behaviour)
TMSIF_DEPRECATED
static void remove(M_BuiltInTest::IClient* sender);
/// @brief deletes all senders received from create()
/// - if create() was called only once, this is equivalent to remove()
TMSIF_DEPRECATED
static void shutdown();
TMSIF_DEPRECATED
static IClient* create(std::string const& serviceName);
};
class TMSIF_EXPORT IClientObsFactory {
public:
typedef std::vector<std::string> StringSet;
typedef M_BuiltInTest::IClient InterfaceType;
/// @brief Register an observer for getting IClient-callbacks on it
template<class IClientDerived>
TMSIF_DEPRECATED
static void add(std::string const& serviceName, IClientDerived* obs, int domain);
TMSIF_DEPRECATED
static void addFiltered(std::string const& serviceName, M_BuiltInTest::IClient* obs, std::string const& ignoredOps);
/// @brief Register manually an observer for getting IClient-callbacks on it
/// - semicolon-separated std::string-list of not-to-override-methods
/// - unclear logic about derived ifaces, error-prone-syntax, better do not use
/// - logically deprecated, better use add() or new oo-API instead
TMSIF_DEPRECATED
static void addFiltered(std::string const& serviceName, M_BuiltInTest::IClient* obs, std::string const& ignoredOps, int domain);
/// @brief Unregister observer previously registered with add...()
TMSIF_DEPRECATED
static void removeObs(M_BuiltInTest::IClient* observer);
/// @brief - deprecated: on call a warning is issued, but function still works: serviceName is ignored.
/// - you must use add/remove 'normally' (one registration per observer), so better call removeObs(1 param) above!
TMSIF_DEPRECATED
static void remove(std::string const& serviceName, M_BuiltInTest::IClient* observer);
/// @brief unregisters all observers previously registered with add...()
/// - if add() called only once, this is equivalent to removeObs()
TMSIF_DEPRECATED
static void shutdown();
/// @brief Use the new Api `ddkit::actors::CallbackInfo::current()` instead.
/// Call this method only from inside a callback.
TMSIF_DEPRECATED
static std::string getSource();
IClientObsFactory() {}
/// @brief Calling add with clientName [IClientObsFactory only]
template<class IClientDerived>
TMSIF_DEPRECATED
static void add(std::string const& serviceName, IClientDerived* obs, int domain, std::string const& clientName);
/// @brief calling addFiltered with clientName [IClientObsFactory only]
/// - clientName is the former clientId - see also IServiceFactory::create(...clientName)
TMSIF_DEPRECATED
static void addFiltered(std::string const& serviceName, M_BuiltInTest::IClient* obs, std::string const& ignoredOps, int domain, std::string const& clientName);
private:
static void addCustom(M_BuiltInTest::IClient* obs, StringSet custom, std::string serviceName, int domain);
static void addCustom(M_BuiltInTest::IClient* obs, StringSet custom, std::string serviceName, int domain,
std::string clientName); // only used on client!
};
class IService;
typedef std::shared_ptr<IService> IServicePtr;
/// @brief new oo-api
class TMSIF_EXPORT Client {
public:
typedef M_BuiltInTest::IClient InterfaceTypeReceiver;
typedef M_BuiltInTest::IService InterfaceTypeSender;
#ifndef SWIG
/// @brief Create dds-readers + writers. remove on Client leaving scope (overridden methods are auto-detected),
template<typename T, typename IClientDerived>
static typename std::enable_if<
std::is_same<T, int>::value &&
std::is_same<IClientDerived, std::vector<ddkit::callback::Base*>
>::value, Client>::type
create(T domain, std::string serviceName, IClientDerived& callbacks);
/// @brief Create dds-readers + writers. remove on Client leaving scope (overridden methods are auto-detected)
template<typename T, typename IClientDerived>
static typename std::enable_if<
std::is_same<T, int>::value &&
!std::is_same<IClientDerived, std::vector<ddkit::callback::Base*>
>::value, Client>::type
create(T domain, std::string serviceName, IClientDerived& callbacks);
/// @brief Create dds-readers + writers. remove on Client leaving scope (overridden methods are auto-detected)
template<typename T, typename IClientDerived>
static typename std::enable_if<
std::is_same<T, std::shared_ptr<ddkit::actors::Session>>::value &&
std::is_same<IClientDerived, std::vector<ddkit::callback::Base*>
>::value, Client>::type
create(T session, std::string serviceName, IClientDerived& callbacks);
/// @brief Create dds-readers + writers. remove on Client leaving scope (overridden methods are auto-detected)
template<typename T, typename IClientDerived>
static typename std::enable_if<
std::is_same<T, std::shared_ptr<ddkit::actors::Session>>::value &&
!std::is_same<IClientDerived, std::vector<ddkit::callback::Base*>
>::value, Client>::type
create(T session, std::string serviceName, IClientDerived& callbacks);
static Client createWriteOnly(int domain, std::string serviceName);
static Client createWriteOnly(std::shared_ptr<ddkit::actors::Session> session, std::string serviceName);
#endif
/// @brief set client-display-name (former 'clientId')
void setName(std::string clientName);
/// @brief call operations on matching Services
IServicePtr operator->();
Client& operator=(Client&& other);
void invalidate();
/// @brief block, until the corresponding service appears.
void waitUntilConnected();
#ifndef SWIG
/// @brief (only for monitors: Listener, Inspector / resulting clients are read-only!)
template<typename T, typename IClientDerived>
static typename std::enable_if<
std::is_same<T, int>::value &&
std::is_same<IClientDerived, std::vector<ddkit::callback::Base*>
>::value, Client>::type
createMonitor(T domain, std::string serviceName, IClientDerived& callbacks);
/// @brief (only for monitors: Listener, Inspector / resulting clients are read-only!)
template<typename T, typename IClientDerived>
static typename std::enable_if<
std::is_same<T, int>::value &&
!std::is_same<IClientDerived, std::vector<ddkit::callback::Base*>
>::value, Client>::type
createMonitor(T domain, std::string serviceName, IClientDerived& callbacks);
/// @brief (only for monitors: Listener, Inspector / resulting clients are read-only!)
template<typename T, typename IClientDerived>
static typename std::enable_if<
std::is_same<T, std::shared_ptr<ddkit::actors::MonitorSession>>::value &&
std::is_same<IClientDerived, std::vector<ddkit::callback::Base*>
>::value, Client>::type
createMonitor(T monitorSession, std::string serviceName, IClientDerived& callbacks);
/// @brief (only for monitors: Listener, Inspector / resulting clients are read-only!)
template<typename T, typename IClientDerived>
static typename std::enable_if<
std::is_same<T, std::shared_ptr<ddkit::actors::MonitorSession>>::value &&
!std::is_same<IClientDerived, std::vector<ddkit::callback::Base*>
>::value, Client>::type
createMonitor(T monitorSession, std::string serviceName, IClientDerived& callbacks);
// MULTIPLEX
/// @brief Reading all serviceNames.
template<typename T, typename IClientDerived>
static typename std::enable_if<
std::is_same<T, int>::value &&
std::is_same<IClientDerived, std::vector<ddkit::callback::Base*>
>::value, Client>::type
createMonitor(T domain, IClientDerived& callbacks);
/// @brief Reading all serviceNames.
template<typename T, typename IClientDerived>
static typename std::enable_if<
std::is_same<T, int>::value &&
!std::is_same<IClientDerived, std::vector<ddkit::callback::Base*>
>::value, Client>::type
createMonitor(T domain, IClientDerived& callbacks);
/// @brief Reading all serviceNames.
template<typename T, typename IClientDerived>
static typename std::enable_if
<std::is_same<T, std::shared_ptr<ddkit::actors::MonitorSession>>::value &&
std::is_same<IClientDerived, std::vector<ddkit::callback::Base*>
>::value, Client>::type
createMonitor(T monitorSession, IClientDerived& callbacks);
/// @brief Reading all serviceNames.
template<typename T, typename IClientDerived>
static typename std::enable_if<
std::is_same<T, std::shared_ptr<ddkit::actors::MonitorSession>>::value &&
!std::is_same<IClientDerived, std::vector<ddkit::callback::Base*>
>::value, Client>::type
createMonitor(T monitorSession, IClientDerived& callbacks);
#endif
/// @brief true, if dds-able (false, if default-constructed or Session destructed)
bool isValid() const;
/// @brief Construct an invalid client-obj
/// (sometimes needed for beeing data-member, prefer create() instead)
Client();
Client(Client&& other);
Client(const Client& other) = default;
~Client();
std::shared_ptr<ddkit::actors::Session> getSession();
std::shared_ptr<ddkit::actors::MonitorSession> getMonitorSession();
// SWIG Wrapper only
static Client* _internalSwigCreateWriteOnly(int domain, std::string serviceName);
static Client* _internalSwigCreateWriteOnly(std::shared_ptr<ddkit::actors::Session> session, std::string serviceName);
static Client* _internalSwigCreate(int domain, std::string serviceName, IClient& callbacks);
static Client* _internalSwigCreateMonitor(int domain, std::string serviceName, IClient& callbacks);
static Client* _internalSwigCreateMonitor(int domain, IClient& callbacks); // reading all serviceNames!
static Client* _internalSwigCreate(std::shared_ptr<ddkit::actors::Session> session, std::string serviceName, IClient& callbacks);
static Client* _internalSwigCreateMonitor(std::shared_ptr<ddkit::actors::MonitorSession> session, std::string serviceName, IClient& callbacks);
static Client* _internalSwigCreateMonitor(std::shared_ptr<ddkit::actors::MonitorSession> session, IClient& callbacks); // reading all serviceNames!
private:
#ifdef _WIN32
#pragma warning(disable:4251) // MSVC would warn about shared/export/dll-inline-stuff here
#endif
ddkit::actors::ActorWeakPtr m_actor;
bool m_discardSenderOnDestruction;
bool m_discardObserverOnDestruction;
std::shared_ptr<ddkit::actors::Session> m_session;
std::shared_ptr<ddkit::actors::MonitorSession> m_monitorSession;
#ifdef _WIN32
#pragma warning(default:4251)
#endif
ddkit::actors::IActor& actor();
Client(ddkit::actors::ActorPtr actor, bool discardSenderOnDestruction, bool discardObserverOnDestruction,
std::shared_ptr<ddkit::actors::Session> session, std::shared_ptr<ddkit::actors::MonitorSession> monitorSession);
static bool isCheckMostDerivedClassType(ddkit::actors::Session& session);
static bool isCheckMostDerivedClassType(ddkit::actors::MonitorSession& monitorSession);
static Client createCustom(std::shared_ptr<ddkit::actors::Session> session, std::string serviceName, IClient& callbacks, std::vector<std::string> methods);
static Client createCustomReadOnly(std::shared_ptr<ddkit::actors::MonitorSession> monitorSession, std::string serviceName, IClient& callbacks, std::vector<std::string> methods);
static Client createCustomReadOnlyMultiplex(std::shared_ptr<ddkit::actors::MonitorSession> monitorSession, IClient& callbacks, std::vector<std::string> methods);
static Client createCustom(std::shared_ptr<ddkit::actors::Session> session, std::string serviceName, std::map<std::string, std::vector<ddkit::callback::Base*>> callbacks, std::vector<std::string> methods);
static Client createCustomReadOnly(std::shared_ptr<ddkit::actors::MonitorSession> monitorSession, std::string serviceName, std::map<std::string, std::vector<ddkit::callback::Base*>> callbacks, std::vector<std::string> methods);
static Client createCustomReadOnlyMultiplex(std::shared_ptr<ddkit::actors::MonitorSession> monitorSession, std::map<std::string, std::vector<ddkit::callback::Base*>> callbacks, std::vector<std::string> methods);
};
#ifndef SWIG
template<class IServiceDerived>
typename std::enable_if<std::is_same<IServiceDerived, std::vector<ddkit::callback::Base*>>::value, std::map<std::string, std::vector<ddkit::callback::Base*>>>::type
detectCallbacksIService(IServiceDerived& callbacks) {
std::map<std::string, std::vector<ddkit::callback::Base*>> methods;
for(auto& obj : callbacks) {
(void) obj; // classes without callbacks
// methods of M_BuiltInTest::IService
{
auto cb = dynamic_cast<ddkit::callback::Wrapper<M_BuiltInTest::IService, std::string const&>*>(obj);
if(cb && cb->isFunction(&M_BuiltInTest::IService::CmdStartIBitRoutine)) {
if(!methods.count("CmdStartIBitRoutine")) {
std::vector<ddkit::callback::Base*> c;
methods.insert(std::make_pair("CmdStartIBitRoutine", c));
}
methods["CmdStartIBitRoutine"].push_back(obj);
continue;
}
}
{
auto cb = dynamic_cast<ddkit::callback::Wrapper<M_BuiltInTest::IService, std::string const&>*>(obj);
if(cb && cb->isFunction(&M_BuiltInTest::IService::CmdCancelIBitRoutine)) {
if(!methods.count("CmdCancelIBitRoutine")) {
std::vector<ddkit::callback::Base*> c;
methods.insert(std::make_pair("CmdCancelIBitRoutine", c));
}
methods["CmdCancelIBitRoutine"].push_back(obj);
continue;
}
}
}
return methods;
}
template<class IServiceDerived>
typename std::enable_if<std::is_same<IServiceDerived, std::vector<ddkit::callback::Base*>>::value, std::vector<std::string>>::type
detectMethodsIService(IServiceDerived& callbacks, bool isCheckMostDerivedClassType) {
std::set<std::string> methods;
for(auto& obj : callbacks) {
(void) obj; // classes without callbacks
// methods of M_BuiltInTest::IService
{
auto cb = dynamic_cast<ddkit::callback::Wrapper<M_BuiltInTest::IService, std::string const&>*>(obj);
if(cb && cb->isFunction(&M_BuiltInTest::IService::CmdStartIBitRoutine)) {
methods.insert("CmdStartIBitRoutine");
continue;
}
}
{
auto cb = dynamic_cast<ddkit::callback::Wrapper<M_BuiltInTest::IService, std::string const&>*>(obj);
if(cb && cb->isFunction(&M_BuiltInTest::IService::CmdCancelIBitRoutine)) {
methods.insert("CmdCancelIBitRoutine");
continue;
}
}
}
std::vector<std::string> result(methods.begin(), methods.end());
return result;
}
template<class IServiceDerived>
typename std::enable_if<!std::is_same<IServiceDerived, std::vector<ddkit::callback::Base*>>::value, std::vector<std::string>>::type
detectMethodsIService(IServiceDerived& callbacks, bool isCheckMostDerivedClassType) {
// if user has casted its derived IService* to IService* (implicitly by going through some wrapper-proxy, which
// does not make use of a template-parameter, all functions will appear to be not overridden, so the compiler
// should cry:
static_assert(!std::is_same<IService, IServiceDerived>::value,
"\033[00;37m\033[40m"
"\n"
"\nCannot take your callbacks* while auto-detecting your overridden methods! It"
"\nappears to be of type IService* - but must be of derived class of IService* (that"
"\nis to say: it must be >your< class)."
"\nMost certainly this problem is triggered by you having a wrapper-method around"
"\nour add/create-methods and thus unintentionally casting up the callbacks* to"
"\nan IService* - a simple solution is to use a template-function as wrapper-method,"
"\nthereby keeping the type of your callbacks* original, while transferring to us."
"\n"
"\n(in case of new Service/Client-api all this refers not to * but to & instead) "
"\n"
"\nVisit .../confluence/display/RMS/%5BTMS-IF%5D+Troubleshooting (see"
"\n'detection of overridden methods') or contact ddkit-Team for more help."
"\n"
"\033[0m");
// compile-error due to static-assert should have avoided this already.
bool isInFactDerivedType = !std::is_same<M_BuiltInTest::IService,IServiceDerived>::value;
if(!isInFactDerivedType) {
throw std::logic_error("isInFactDerivedType is false");
}
if (isCheckMostDerivedClassType) {
// one may fool both tests by writing a wrapper with a different (generic) class, which overrides nothing,
// but only is base-class for other derived-classes, in which the methods are overridden.
// Or one could add multi-levels of inheritance and add some functions each level.
// In these cases the equalness of the template-parameter with the interface-class is not enough any more,
// to detect, if the correct (most bottom) class was given as pointer into the auto-detection.
// But another method works, as typeid cannot only be used to compare function-addresses for equality like
// in the auto-detect-functionality of adapterlib 7.0.0, but also classes of objects (the original purpose),
// and so we can check, if the template-type, that here is presenting itself, is the same type, as the object
// itself, that is given. If not, some slicing did occur, and some overridden methods would not be detected
// correctly, so we have to error here.
// - and now the magic happens:
if (typeid(callbacks) != typeid(IServiceDerived)) {
throw std::runtime_error("detectMethods called with 'sliced' type of your object. Your given"
" callbacks-pointer/reference maybe was (implicitly) casted to a base-class.");
}
}
// determine set of overridden methods (walk methods of inherited classes as well)
std::vector<std::string> methods;
// methods of M_BuiltInTest::IService
if (!std::is_same<decltype(&IService::CmdStartIBitRoutine),
decltype(&IServiceDerived::CmdStartIBitRoutine)
>::value) methods.push_back("CmdStartIBitRoutine");
if (!std::is_same<decltype(&IService::CmdCancelIBitRoutine),
decltype(&IServiceDerived::CmdCancelIBitRoutine)
>::value) methods.push_back("CmdCancelIBitRoutine");
return methods;
}
// static
template<class IServiceDerived>
void IServiceObsFactory::add(std::string const& serviceName, IServiceDerived* obs, int domain) {
ddkit::actors::SessionManager::instance(); // Must be first on the stack (init logging etc.)!
bool checkMostDerivedClassType = ddkit::actors::BackwardManager::instance().createOrGetSession_(domain)->isCheckMostDerivedClassType();
std::vector<std::string> methods = M_BuiltInTest::detectMethodsIService(*obs, checkMostDerivedClassType);
addCustom(obs, methods, serviceName, domain);
}
// static int domain, lambda
template<typename T, typename IServiceDerived>
typename std::enable_if<std::is_same<T, int>::value &&
std::is_same<IServiceDerived, std::vector<ddkit::callback::Base*>>::value, Service>::type
Service::create(T domain, std::string serviceName, IServiceDerived& callbacks) {
auto session = ddkit::actors::SessionFactory::instance().getSession(domain);
std::vector<std::string> methods = M_BuiltInTest::detectMethodsIService(callbacks, false);
std::map<std::string, std::vector<ddkit::callback::Base*>> lambdaMap = M_BuiltInTest::detectCallbacksIService(callbacks);
return createCustom(session, serviceName, lambdaMap, methods);
}
// static int domain, IServiceDerived
template<typename T, typename IServiceDerived>
typename std::enable_if<std::is_same<T, int>::value &&
!std::is_same<IServiceDerived, std::vector<ddkit::callback::Base*>>::value, Service>::type
Service::create(T domain, std::string serviceName, IServiceDerived& callbacks) {
auto session = ddkit::actors::SessionFactory::instance().getSession(domain);
std::vector<std::string> methods = M_BuiltInTest::detectMethodsIService(callbacks, isCheckMostDerivedClassType(*session.get()));
return createCustom(session, serviceName, callbacks, methods);
}
// static shared_ptr<Session> session, lambda
template<typename T, typename IServiceDerived>
typename std::enable_if<std::is_same<T, std::shared_ptr<ddkit::actors::Session>>::value &&
std::is_same<IServiceDerived, std::vector<ddkit::callback::Base*>>::value, Service>::type
Service::create(T session, std::string serviceName, IServiceDerived& callbacks) {
std::vector<std::string> methods = M_BuiltInTest::detectMethodsIService(callbacks, false);
std::map<std::string, std::vector<ddkit::callback::Base*>> lambdaMap = M_BuiltInTest::detectCallbacksIService(callbacks);
return createCustom(session, serviceName, lambdaMap, methods);
}
// static shared_ptr<Session> session, IServiceDerived
template<typename T, typename IServiceDerived>
typename std::enable_if<std::is_same<T, std::shared_ptr<ddkit::actors::Session>>::value &&
!std::is_same<IServiceDerived, std::vector<ddkit::callback::Base*>>::value, Service>::type
Service::create(T session, std::string serviceName, IServiceDerived& callbacks) {
std::vector<std::string> methods = M_BuiltInTest::detectMethodsIService(callbacks, isCheckMostDerivedClassType(*session.get()));
return createCustom(session, serviceName, callbacks, methods);
}
// static int domain, lambda
template<typename T, typename IServiceDerived>
typename std::enable_if<std::is_same<T, int>::value &&
std::is_same<IServiceDerived, std::vector<ddkit::callback::Base*>>::value, Service>::type
Service::createMonitor(T domain, std::string serviceName, IServiceDerived& callbacks) {
auto monitorSession = ddkit::actors::SessionFactory::instance().getMonitorSession(domain);
std::vector<std::string> methods = M_BuiltInTest::detectMethodsIService(callbacks, false);
std::map<std::string, std::vector<ddkit::callback::Base*>> lambdaMap = M_BuiltInTest::detectCallbacksIService(callbacks);
return createCustomReadOnly(monitorSession, serviceName, lambdaMap, methods);
}
// static int domain, IServiceDerived
template<typename T, typename IServiceDerived>
typename std::enable_if<std::is_same<T, int>::value &&
!std::is_same<IServiceDerived, std::vector<ddkit::callback::Base*>>::value, Service>::type
Service::createMonitor(T domain, std::string serviceName, IServiceDerived& callbacks) {
auto monitorSession = ddkit::actors::SessionFactory::instance().getMonitorSession(domain);
std::vector<std::string> methods = M_BuiltInTest::detectMethodsIService(callbacks, isCheckMostDerivedClassType(*monitorSession.get()));
return createCustomReadOnly(monitorSession, serviceName, callbacks, methods);
}
// static std::shared_ptr<ddkit::actors::MonitorSession> monitorSession, lambda
template<typename T, typename IServiceDerived>
typename std::enable_if<std::is_same<T, std::shared_ptr<ddkit::actors::MonitorSession>>::value &&
std::is_same<IServiceDerived, std::vector<ddkit::callback::Base*>>::value, Service>::type
Service::createMonitor(T monitorSession, std::string serviceName, IServiceDerived& callbacks) {
std::vector<std::string> methods = M_BuiltInTest::detectMethodsIService(callbacks, false);
std::map<std::string, std::vector<ddkit::callback::Base*>> lambdaMap = M_BuiltInTest::detectCallbacksIService(callbacks);
return createCustomReadOnly(monitorSession, serviceName, lambdaMap, methods);
}
// static std::shared_ptr<ddkit::actors::MonitorSession> monitorSession, IServiceDerived
template<typename T, typename IServiceDerived>
typename std::enable_if<std::is_same<T, std::shared_ptr<ddkit::actors::MonitorSession>>::value &&
!std::is_same<IServiceDerived, std::vector<ddkit::callback::Base*>>::value, Service>::type
Service::createMonitor(T monitorSession, std::string serviceName, IServiceDerived& callbacks) {
std::vector<std::string> methods = M_BuiltInTest::detectMethodsIService(callbacks, isCheckMostDerivedClassType(*monitorSession.get()));
return createCustomReadOnly(monitorSession, serviceName, callbacks, methods);
}
// static int domain, lambda
template<typename T, typename IServiceDerived>
typename std::enable_if<std::is_same<T, int>::value &&
std::is_same<IServiceDerived, std::vector<ddkit::callback::Base*>>::value, Service>::type
Service::createMonitor(T domain, IServiceDerived& callbacks) {
auto monitorSession = ddkit::actors::SessionFactory::instance().getMonitorSession(domain);
std::vector<std::string> methods = M_BuiltInTest::detectMethodsIService(callbacks, false);
std::map<std::string, std::vector<ddkit::callback::Base*>> lambdaMap = M_BuiltInTest::detectCallbacksIService(callbacks);
return createCustomReadOnlyMultiplex(monitorSession, lambdaMap, methods);
}
// static int domain, IServiceDerived
template<typename T, typename IServiceDerived>
typename std::enable_if<std::is_same<T, int>::value &&
!std::is_same<IServiceDerived, std::vector<ddkit::callback::Base*>>::value, Service>::type
Service::createMonitor(T domain, IServiceDerived& callbacks) {
auto monitorSession = ddkit::actors::SessionFactory::instance().getMonitorSession(domain);
std::vector<std::string> methods = M_BuiltInTest::detectMethodsIService(callbacks, isCheckMostDerivedClassType(*monitorSession.get()));
return createCustomReadOnlyMultiplex(monitorSession, callbacks, methods);
}
// static std::shared_ptr<ddkit::actors::MonitorSession> monitorSession, lambda
template<typename T, typename IServiceDerived>
typename std::enable_if<std::is_same<T, std::shared_ptr<ddkit::actors::MonitorSession>>::value &&
std::is_same<IServiceDerived, std::vector<ddkit::callback::Base*>>::value, Service>::type
Service::createMonitor(T monitorSession, IServiceDerived& callbacks) {
std::vector<std::string> methods = M_BuiltInTest::detectMethodsIService(callbacks, false);
std::map<std::string, std::vector<ddkit::callback::Base*>> lambdaMap = M_BuiltInTest::detectCallbacksIService(callbacks);
return createCustomReadOnlyMultiplex(monitorSession, lambdaMap, methods);
}
// static std::shared_ptr<ddkit::actors::MonitorSession> monitorSession, IServiceDerived
template<typename T, typename IServiceDerived>
typename std::enable_if<std::is_same<T, std::shared_ptr<ddkit::actors::MonitorSession>>::value &&
!std::is_same<IServiceDerived, std::vector<ddkit::callback::Base*>>::value, Service>::type
Service::createMonitor(T monitorSession, IServiceDerived& callbacks) {
std::vector<std::string> methods = M_BuiltInTest::detectMethodsIService(callbacks, isCheckMostDerivedClassType(*monitorSession.get()));
return createCustomReadOnlyMultiplex(monitorSession, callbacks, methods);
}
#endif
#ifndef SWIG
template<class IClientDerived>
typename std::enable_if<std::is_same<IClientDerived, std::vector<ddkit::callback::Base*>>::value, std::map<std::string, std::vector<ddkit::callback::Base*>>>::type
detectCallbacksIClient(IClientDerived& callbacks) {
std::map<std::string, std::vector<ddkit::callback::Base*>> methods;
for(auto& obj : callbacks) {
(void) obj; // classes without callbacks
// methods of M_BuiltInTest::IClient
{
auto cb = dynamic_cast<ddkit::callback::Wrapper<M_BuiltInTest::IClient, M_BuiltInTest::BitSettingsType const&>*>(obj);
if(cb && cb->isFunction(&M_BuiltInTest::IClient::ReportBitSettings)) {
if(!methods.count("ReportBitSettings")) {
std::vector<ddkit::callback::Base*> c;
methods.insert(std::make_pair("ReportBitSettings", c));
}
methods["ReportBitSettings"].push_back(obj);
continue;
}
}
{
auto cb = dynamic_cast<ddkit::callback::Wrapper<M_BuiltInTest::IClient, std::string const&, M_BuiltInTest::IBitRoutineState::Type, bool>*>(obj);
if(cb && cb->isFunction(&M_BuiltInTest::IClient::ReportIBitRoutineStatus)) {
if(!methods.count("ReportIBitRoutineStatus")) {
std::vector<ddkit::callback::Base*> c;
methods.insert(std::make_pair("ReportIBitRoutineStatus", c));
}
methods["ReportIBitRoutineStatus"].push_back(obj);
continue;
}
}
{
auto cb = dynamic_cast<ddkit::callback::Wrapper<M_BuiltInTest::IClient, std::string const&, M_BuiltInTest::BitStatusType const&, bool>*>(obj);
if(cb && cb->isFunction(&M_BuiltInTest::IClient::ReportIBitStatus)) {
if(!methods.count("ReportIBitStatus")) {
std::vector<ddkit::callback::Base*> c;
methods.insert(std::make_pair("ReportIBitStatus", c));
}
methods["ReportIBitStatus"].push_back(obj);
continue;
}
}
{
auto cb = dynamic_cast<ddkit::callback::Wrapper<M_BuiltInTest::IClient, std::string const&, M_BuiltInTest::BitStatusType const&, bool>*>(obj);
if(cb && cb->isFunction(&M_BuiltInTest::IClient::ReportPBitStatus)) {
if(!methods.count("ReportPBitStatus")) {
std::vector<ddkit::callback::Base*> c;
methods.insert(std::make_pair("ReportPBitStatus", c));
}
methods["ReportPBitStatus"].push_back(obj);
continue;
}
}
{
auto cb = dynamic_cast<ddkit::callback::Wrapper<M_BuiltInTest::IClient, std::string const&, M_BuiltInTest::BitStatusType const&, bool>*>(obj);
if(cb && cb->isFunction(&M_BuiltInTest::IClient::ReportCBitStatus)) {
if(!methods.count("ReportCBitStatus")) {
std::vector<ddkit::callback::Base*> c;
methods.insert(std::make_pair("ReportCBitStatus", c));
}
methods["ReportCBitStatus"].push_back(obj);
continue;
}
}
}
return methods;
}
template<class IClientDerived>
typename std::enable_if<std::is_same<IClientDerived, std::vector<ddkit::callback::Base*>>::value, std::vector<std::string>>::type
detectMethodsIClient(IClientDerived& callbacks, bool isCheckMostDerivedClassType) {
std::set<std::string> methods;
for(auto& obj : callbacks) {
(void) obj; // classes without callbacks
// methods of M_BuiltInTest::IClient
{
auto cb = dynamic_cast<ddkit::callback::Wrapper<M_BuiltInTest::IClient, M_BuiltInTest::BitSettingsType const&>*>(obj);
if(cb && cb->isFunction(&M_BuiltInTest::IClient::ReportBitSettings)) {
methods.insert("ReportBitSettings");
continue;
}
}
{
auto cb = dynamic_cast<ddkit::callback::Wrapper<M_BuiltInTest::IClient, std::string const&, M_BuiltInTest::IBitRoutineState::Type, bool>*>(obj);
if(cb && cb->isFunction(&M_BuiltInTest::IClient::ReportIBitRoutineStatus)) {
methods.insert("ReportIBitRoutineStatus");
continue;
}
}
{
auto cb = dynamic_cast<ddkit::callback::Wrapper<M_BuiltInTest::IClient, std::string const&, M_BuiltInTest::BitStatusType const&, bool>*>(obj);
if(cb && cb->isFunction(&M_BuiltInTest::IClient::ReportIBitStatus)) {
methods.insert("ReportIBitStatus");
continue;
}
}
{
auto cb = dynamic_cast<ddkit::callback::Wrapper<M_BuiltInTest::IClient, std::string const&, M_BuiltInTest::BitStatusType const&, bool>*>(obj);
if(cb && cb->isFunction(&M_BuiltInTest::IClient::ReportPBitStatus)) {
methods.insert("ReportPBitStatus");
continue;
}
}
{
auto cb = dynamic_cast<ddkit::callback::Wrapper<M_BuiltInTest::IClient, std::string const&, M_BuiltInTest::BitStatusType const&, bool>*>(obj);
if(cb && cb->isFunction(&M_BuiltInTest::IClient::ReportCBitStatus)) {
methods.insert("ReportCBitStatus");
continue;
}
}
}
std::vector<std::string> result(methods.begin(), methods.end());
return result;
}
template<class IClientDerived>
typename std::enable_if<!std::is_same<IClientDerived, std::vector<ddkit::callback::Base*>>::value, std::vector<std::string>>::type
detectMethodsIClient(IClientDerived& callbacks, bool isCheckMostDerivedClassType) {
// if user has casted its derived IClient* to IClient* (implicitly by going through some wrapper-proxy, which
// does not make use of a template-parameter, all functions will appear to be not overridden, so the compiler
// should cry:
static_assert(!std::is_same<IClient, IClientDerived>::value,
"\033[00;37m\033[40m"
"\n"
"\nCannot take your callbacks* while auto-detecting your overridden methods! It"
"\nappears to be of type IClient* - but must be of derived class of IClient* (that"
"\nis to say: it must be >your< class)."
"\nMost certainly this problem is triggered by you having a wrapper-method around"
"\nour add/create-methods and thus unintentionally casting up the callbacks* to"
"\nan IClient* - a simple solution is to use a template-function as wrapper-method,"
"\nthereby keeping the type of your callbacks* original, while transferring to us."
"\n"
"\n(in case of new Service/Client-api all this refers not to * but to & instead) "
"\n"
"\nVisit .../confluence/display/RMS/%5BTMS-IF%5D+Troubleshooting (see"
"\n'detection of overridden methods') or contact ddkit-Team for more help."
"\n"
"\033[0m");
// compile-error due to static-assert should have avoided this already.
bool isInFactDerivedType = !std::is_same<M_BuiltInTest::IClient,IClientDerived>::value;
if(!isInFactDerivedType) {
throw std::logic_error("isInFactDerivedType is false");
}
if (isCheckMostDerivedClassType) {
// one may fool both tests by writing a wrapper with a different (generic) class, which overrides nothing,
// but only is base-class for other derived-classes, in which the methods are overridden.
// Or one could add multi-levels of inheritance and add some functions each level.
// In these cases the equalness of the template-parameter with the interface-class is not enough any more,
// to detect, if the correct (most bottom) class was given as pointer into the auto-detection.
// But another method works, as typeid cannot only be used to compare function-addresses for equality like
// in the auto-detect-functionality of adapterlib 7.0.0, but also classes of objects (the original purpose),
// and so we can check, if the template-type, that here is presenting itself, is the same type, as the object
// itself, that is given. If not, some slicing did occur, and some overridden methods would not be detected
// correctly, so we have to error here.
// - and now the magic happens:
if (typeid(callbacks) != typeid(IClientDerived)) {
throw std::runtime_error("detectMethods called with 'sliced' type of your object. Your given"
" callbacks-pointer/reference maybe was (implicitly) casted to a base-class.");
}
}
// determine set of overridden methods (walk methods of inherited classes as well)
std::vector<std::string> methods;
// methods of M_BuiltInTest::IClient
if (!std::is_same<decltype(&IClient::ReportBitSettings),
decltype(&IClientDerived::ReportBitSettings)
>::value) methods.push_back("ReportBitSettings");
if (!std::is_same<decltype(&IClient::ReportIBitRoutineStatus),
decltype(&IClientDerived::ReportIBitRoutineStatus)
>::value) methods.push_back("ReportIBitRoutineStatus");
if (!std::is_same<decltype(&IClient::ReportIBitStatus),
decltype(&IClientDerived::ReportIBitStatus)
>::value) methods.push_back("ReportIBitStatus");
if (!std::is_same<decltype(&IClient::ReportPBitStatus),
decltype(&IClientDerived::ReportPBitStatus)
>::value) methods.push_back("ReportPBitStatus");
if (!std::is_same<decltype(&IClient::ReportCBitStatus),
decltype(&IClientDerived::ReportCBitStatus)
>::value) methods.push_back("ReportCBitStatus");
return methods;
}
// static
template<class IClientDerived>
void IClientObsFactory::add(std::string const& serviceName, IClientDerived* obs, int domain) {
ddkit::actors::SessionManager::instance(); // Must be first on the stack (init logging etc.)!
bool checkMostDerivedClassType = ddkit::actors::BackwardManager::instance().createOrGetSession_(domain)->isCheckMostDerivedClassType();
std::vector<std::string> methods = M_BuiltInTest::detectMethodsIClient(*obs, checkMostDerivedClassType);
addCustom(obs, methods, serviceName, domain);
}
// static
template<class IClientDerived>
void IClientObsFactory::add(std::string const& serviceName, IClientDerived* obs, int domain, std::string const& clientName) {
ddkit::actors::SessionManager::instance(); // Must be first on the stack (init logging etc.)!
bool checkMostDerivedClassType = ddkit::actors::BackwardManager::instance().createOrGetSession_(domain)->isCheckMostDerivedClassType();
std::vector<std::string> methods = M_BuiltInTest::detectMethodsIClient(*obs, checkMostDerivedClassType);
addCustom(obs, methods, serviceName, domain, clientName);
}
// static int domain, lambda
template<typename T, typename IClientDerived>
typename std::enable_if<std::is_same<T, int>::value &&
std::is_same<IClientDerived, std::vector<ddkit::callback::Base*>>::value, Client>::type
Client::create(T domain, std::string serviceName, IClientDerived& callbacks) {
auto session = ddkit::actors::SessionFactory::instance().getSession(domain);
std::vector<std::string> methods = M_BuiltInTest::detectMethodsIClient(callbacks, false);
std::map<std::string, std::vector<ddkit::callback::Base*>> lambdaMap = M_BuiltInTest::detectCallbacksIClient(callbacks);
return createCustom(session, serviceName, lambdaMap, methods);
}
// static int domain, IClientDerived
template<typename T, typename IClientDerived>
typename std::enable_if<std::is_same<T, int>::value &&
!std::is_same<IClientDerived, std::vector<ddkit::callback::Base*>>::value, Client>::type
Client::create(T domain, std::string serviceName, IClientDerived& callbacks) {
auto session = ddkit::actors::SessionFactory::instance().getSession(domain);
std::vector<std::string> methods = M_BuiltInTest::detectMethodsIClient(callbacks, isCheckMostDerivedClassType(*session.get()));
return createCustom(session, serviceName, callbacks, methods);
}
// static shared_ptr<Session> session, lambda
template<typename T, typename IClientDerived>
typename std::enable_if<std::is_same<T, std::shared_ptr<ddkit::actors::Session>>::value &&
std::is_same<IClientDerived, std::vector<ddkit::callback::Base*>>::value, Client>::type
Client::create(T session, std::string serviceName, IClientDerived& callbacks) {
std::vector<std::string> methods = M_BuiltInTest::detectMethodsIClient(callbacks, false);
std::map<std::string, std::vector<ddkit::callback::Base*>> lambdaMap = M_BuiltInTest::detectCallbacksIClient(callbacks);
return createCustom(session, serviceName, lambdaMap, methods);
}
// static shared_ptr<Session> session, IClientDerived
template<typename T, typename IClientDerived>
typename std::enable_if<std::is_same<T, std::shared_ptr<ddkit::actors::Session>>::value &&
!std::is_same<IClientDerived, std::vector<ddkit::callback::Base*>>::value, Client>::type
Client::create(T session, std::string serviceName, IClientDerived& callbacks) {
std::vector<std::string> methods = M_BuiltInTest::detectMethodsIClient(callbacks, isCheckMostDerivedClassType(*session.get()));
return createCustom(session, serviceName, callbacks, methods);
}
// static int domain, lambda
template<typename T, typename IClientDerived>
typename std::enable_if<std::is_same<T, int>::value &&
std::is_same<IClientDerived, std::vector<ddkit::callback::Base*>>::value, Client>::type
Client::createMonitor(T domain, std::string serviceName, IClientDerived& callbacks) {
auto monitorSession = ddkit::actors::SessionFactory::instance().getMonitorSession(domain);
std::vector<std::string> methods = M_BuiltInTest::detectMethodsIClient(callbacks, false);
std::map<std::string, std::vector<ddkit::callback::Base*>> lambdaMap = M_BuiltInTest::detectCallbacksIClient(callbacks);
return createCustomReadOnly(monitorSession, serviceName, lambdaMap, methods);
}
// static int domain, IClientDerived
template<typename T, typename IClientDerived>
typename std::enable_if<std::is_same<T, int>::value &&
!std::is_same<IClientDerived, std::vector<ddkit::callback::Base*>>::value, Client>::type
Client::createMonitor(T domain, std::string serviceName, IClientDerived& callbacks) {
auto monitorSession = ddkit::actors::SessionFactory::instance().getMonitorSession(domain);
std::vector<std::string> methods = M_BuiltInTest::detectMethodsIClient(callbacks, isCheckMostDerivedClassType(*monitorSession.get()));
return createCustomReadOnly(monitorSession, serviceName, callbacks, methods);
}
// static std::shared_ptr<ddkit::actors::MonitorSession> monitorSession, lambda
template<typename T, typename IClientDerived>
typename std::enable_if<std::is_same<T, std::shared_ptr<ddkit::actors::MonitorSession>>::value &&
std::is_same<IClientDerived, std::vector<ddkit::callback::Base*>>::value, Client>::type
Client::createMonitor(T monitorSession, std::string serviceName, IClientDerived& callbacks) {
std::vector<std::string> methods = M_BuiltInTest::detectMethodsIClient(callbacks, false);
std::map<std::string, std::vector<ddkit::callback::Base*>> lambdaMap = M_BuiltInTest::detectCallbacksIClient(callbacks);
return createCustomReadOnly(monitorSession, serviceName, lambdaMap, methods);
}
// static std::shared_ptr<ddkit::actors::MonitorSession> monitorSession, IClientDerived
template<typename T, typename IClientDerived>
typename std::enable_if<std::is_same<T, std::shared_ptr<ddkit::actors::MonitorSession>>::value &&
!std::is_same<IClientDerived, std::vector<ddkit::callback::Base*>>::value, Client>::type
Client::createMonitor(T monitorSession, std::string serviceName, IClientDerived& callbacks) {
std::vector<std::string> methods = M_BuiltInTest::detectMethodsIClient(callbacks, isCheckMostDerivedClassType(*monitorSession.get()));
return createCustomReadOnly(monitorSession, serviceName, callbacks, methods);
}
// static int domain, lambda
template<typename T, typename IClientDerived>
typename std::enable_if<std::is_same<T, int>::value &&
std::is_same<IClientDerived, std::vector<ddkit::callback::Base*>>::value, Client>::type
Client::createMonitor(T domain, IClientDerived& callbacks) {
auto monitorSession = ddkit::actors::SessionFactory::instance().getMonitorSession(domain);
std::vector<std::string> methods = M_BuiltInTest::detectMethodsIClient(callbacks, false);
std::map<std::string, std::vector<ddkit::callback::Base*>> lambdaMap = M_BuiltInTest::detectCallbacksIClient(callbacks);
return createCustomReadOnlyMultiplex(monitorSession, lambdaMap, methods);
}
// static int domain, IClientDerived
template<typename T, typename IClientDerived>
typename std::enable_if<std::is_same<T, int>::value &&
!std::is_same<IClientDerived, std::vector<ddkit::callback::Base*>>::value, Client>::type
Client::createMonitor(T domain, IClientDerived& callbacks) {
auto monitorSession = ddkit::actors::SessionFactory::instance().getMonitorSession(domain);
std::vector<std::string> methods = M_BuiltInTest::detectMethodsIClient(callbacks, isCheckMostDerivedClassType(*monitorSession.get()));
return createCustomReadOnlyMultiplex(monitorSession, callbacks, methods);
}
// static std::shared_ptr<ddkit::actors::MonitorSession> monitorSession, lambda
template<typename T, typename IClientDerived>
typename std::enable_if<std::is_same<T, std::shared_ptr<ddkit::actors::MonitorSession>>::value &&
std::is_same<IClientDerived, std::vector<ddkit::callback::Base*>>::value, Client>::type
Client::createMonitor(T monitorSession, IClientDerived& callbacks) {
std::vector<std::string> methods = M_BuiltInTest::detectMethodsIClient(callbacks, false);
std::map<std::string, std::vector<ddkit::callback::Base*>> lambdaMap = M_BuiltInTest::detectCallbacksIClient(callbacks);
return createCustomReadOnlyMultiplex(monitorSession, lambdaMap, methods);
}
// static std::shared_ptr<ddkit::actors::MonitorSession> monitorSession, IClientDerived
template<typename T, typename IClientDerived>
typename std::enable_if<std::is_same<T, std::shared_ptr<ddkit::actors::MonitorSession>>::value &&
!std::is_same<IClientDerived, std::vector<ddkit::callback::Base*>>::value, Client>::type
Client::createMonitor(T monitorSession, IClientDerived& callbacks) {
std::vector<std::string> methods = M_BuiltInTest::detectMethodsIClient(callbacks, isCheckMostDerivedClassType(*monitorSession.get()));
return createCustomReadOnlyMultiplex(monitorSession, callbacks, methods);
}
#endif
} // namespace M_BuiltInTest
#endif