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

1362 lines
66 KiB
C++

///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//
// GENERATED CODE - do not edit (Generated by ddkit/genModelApi)
//
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// SignalGenerator.hpp (rmodel-api)
#ifndef SignalGenerator_API
#define SignalGenerator_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/SignalGenerator.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_SignalGenerator {
class TMSIF_EXPORT IServiceFactory {
public:
typedef M_SignalGenerator::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_SignalGenerator::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_SignalGenerator::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_SignalGenerator::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_SignalGenerator::IService* obs, std::string const& ignoredOps, int domain);
/// @brief Unregister observer previously registered with add...()
TMSIF_DEPRECATED
static void removeObs(M_SignalGenerator::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_SignalGenerator::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_SignalGenerator::IService* obs, StringSet custom, std::string serviceName, int domain);
static void addCustom(M_SignalGenerator::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_SignalGenerator::IService InterfaceTypeReceiver;
typedef M_SignalGenerator::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_SignalGenerator::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_SignalGenerator::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_SignalGenerator::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_SignalGenerator::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_SignalGenerator::IClient* obs, std::string const& ignoredOps, int domain);
/// @brief Unregister observer previously registered with add...()
TMSIF_DEPRECATED
static void removeObs(M_SignalGenerator::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_SignalGenerator::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_SignalGenerator::IClient* obs, std::string const& ignoredOps, int domain, std::string const& clientName);
private:
static void addCustom(M_SignalGenerator::IClient* obs, StringSet custom, std::string serviceName, int domain);
static void addCustom(M_SignalGenerator::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_SignalGenerator::IClient InterfaceTypeReceiver;
typedef M_SignalGenerator::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_SignalGenerator::IService
{
auto cb = dynamic_cast<ddkit::callback::Wrapper<M_SignalGenerator::IService, uint32_t>*>(obj);
if(cb && cb->isFunction(&M_SignalGenerator::IService::ConfigGeneratorState)) {
if(!methods.count("ConfigGeneratorState")) {
std::vector<ddkit::callback::Base*> c;
methods.insert(std::make_pair("ConfigGeneratorState", c));
}
methods["ConfigGeneratorState"].push_back(obj);
continue;
}
}
{
auto cb = dynamic_cast<ddkit::callback::Wrapper<M_SignalGenerator::IService, uint32_t>*>(obj);
if(cb && cb->isFunction(&M_SignalGenerator::IService::ConfigControllerOperationMode)) {
if(!methods.count("ConfigControllerOperationMode")) {
std::vector<ddkit::callback::Base*> c;
methods.insert(std::make_pair("ConfigControllerOperationMode", c));
}
methods["ConfigControllerOperationMode"].push_back(obj);
continue;
}
}
{
auto cb = dynamic_cast<ddkit::callback::Wrapper<M_SignalGenerator::IService, uint32_t>*>(obj);
if(cb && cb->isFunction(&M_SignalGenerator::IService::ConfigControlMode)) {
if(!methods.count("ConfigControlMode")) {
std::vector<ddkit::callback::Base*> c;
methods.insert(std::make_pair("ConfigControlMode", c));
}
methods["ConfigControlMode"].push_back(obj);
continue;
}
}
{
auto cb = dynamic_cast<ddkit::callback::Wrapper<M_SignalGenerator::IService, uint32_t, uint32_t, uint32_t, M_Common::ULongListType const&>*>(obj);
if(cb && cb->isFunction(&M_SignalGenerator::IService::ConfigTestSetup)) {
if(!methods.count("ConfigTestSetup")) {
std::vector<ddkit::callback::Base*> c;
methods.insert(std::make_pair("ConfigTestSetup", c));
}
methods["ConfigTestSetup"].push_back(obj);
continue;
}
}
{
auto cb = dynamic_cast<ddkit::callback::Wrapper<M_SignalGenerator::IService, M_SignalGenerator::WaveformType const&>*>(obj);
if(cb && cb->isFunction(&M_SignalGenerator::IService::ConfigWaveform)) {
if(!methods.count("ConfigWaveform")) {
std::vector<ddkit::callback::Base*> c;
methods.insert(std::make_pair("ConfigWaveform", c));
}
methods["ConfigWaveform"].push_back(obj);
continue;
}
}
{
auto cb = dynamic_cast<ddkit::callback::Wrapper<M_SignalGenerator::IService, uint32_t, M_SignalGenerator::SampleListType const&>*>(obj);
if(cb && cb->isFunction(&M_SignalGenerator::IService::ConfigAmplitudeScaling)) {
if(!methods.count("ConfigAmplitudeScaling")) {
std::vector<ddkit::callback::Base*> c;
methods.insert(std::make_pair("ConfigAmplitudeScaling", c));
}
methods["ConfigAmplitudeScaling"].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_SignalGenerator::IService
{
auto cb = dynamic_cast<ddkit::callback::Wrapper<M_SignalGenerator::IService, uint32_t>*>(obj);
if(cb && cb->isFunction(&M_SignalGenerator::IService::ConfigGeneratorState)) {
methods.insert("ConfigGeneratorState");
continue;
}
}
{
auto cb = dynamic_cast<ddkit::callback::Wrapper<M_SignalGenerator::IService, uint32_t>*>(obj);
if(cb && cb->isFunction(&M_SignalGenerator::IService::ConfigControllerOperationMode)) {
methods.insert("ConfigControllerOperationMode");
continue;
}
}
{
auto cb = dynamic_cast<ddkit::callback::Wrapper<M_SignalGenerator::IService, uint32_t>*>(obj);
if(cb && cb->isFunction(&M_SignalGenerator::IService::ConfigControlMode)) {
methods.insert("ConfigControlMode");
continue;
}
}
{
auto cb = dynamic_cast<ddkit::callback::Wrapper<M_SignalGenerator::IService, uint32_t, uint32_t, uint32_t, M_Common::ULongListType const&>*>(obj);
if(cb && cb->isFunction(&M_SignalGenerator::IService::ConfigTestSetup)) {
methods.insert("ConfigTestSetup");
continue;
}
}
{
auto cb = dynamic_cast<ddkit::callback::Wrapper<M_SignalGenerator::IService, M_SignalGenerator::WaveformType const&>*>(obj);
if(cb && cb->isFunction(&M_SignalGenerator::IService::ConfigWaveform)) {
methods.insert("ConfigWaveform");
continue;
}
}
{
auto cb = dynamic_cast<ddkit::callback::Wrapper<M_SignalGenerator::IService, uint32_t, M_SignalGenerator::SampleListType const&>*>(obj);
if(cb && cb->isFunction(&M_SignalGenerator::IService::ConfigAmplitudeScaling)) {
methods.insert("ConfigAmplitudeScaling");
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_SignalGenerator::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_SignalGenerator::IService
if (!std::is_same<decltype(&IService::ConfigGeneratorState),
decltype(&IServiceDerived::ConfigGeneratorState)
>::value) methods.push_back("ConfigGeneratorState");
if (!std::is_same<decltype(&IService::ConfigControllerOperationMode),
decltype(&IServiceDerived::ConfigControllerOperationMode)
>::value) methods.push_back("ConfigControllerOperationMode");
if (!std::is_same<decltype(&IService::ConfigControlMode),
decltype(&IServiceDerived::ConfigControlMode)
>::value) methods.push_back("ConfigControlMode");
if (!std::is_same<decltype(&IService::ConfigTestSetup),
decltype(&IServiceDerived::ConfigTestSetup)
>::value) methods.push_back("ConfigTestSetup");
if (!std::is_same<decltype(&IService::ConfigWaveform),
decltype(&IServiceDerived::ConfigWaveform)
>::value) methods.push_back("ConfigWaveform");
if (!std::is_same<decltype(&IService::ConfigAmplitudeScaling),
decltype(&IServiceDerived::ConfigAmplitudeScaling)
>::value) methods.push_back("ConfigAmplitudeScaling");
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_SignalGenerator::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_SignalGenerator::detectMethodsIService(callbacks, false);
std::map<std::string, std::vector<ddkit::callback::Base*>> lambdaMap = M_SignalGenerator::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_SignalGenerator::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_SignalGenerator::detectMethodsIService(callbacks, false);
std::map<std::string, std::vector<ddkit::callback::Base*>> lambdaMap = M_SignalGenerator::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_SignalGenerator::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_SignalGenerator::detectMethodsIService(callbacks, false);
std::map<std::string, std::vector<ddkit::callback::Base*>> lambdaMap = M_SignalGenerator::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_SignalGenerator::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_SignalGenerator::detectMethodsIService(callbacks, false);
std::map<std::string, std::vector<ddkit::callback::Base*>> lambdaMap = M_SignalGenerator::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_SignalGenerator::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_SignalGenerator::detectMethodsIService(callbacks, false);
std::map<std::string, std::vector<ddkit::callback::Base*>> lambdaMap = M_SignalGenerator::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_SignalGenerator::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_SignalGenerator::detectMethodsIService(callbacks, false);
std::map<std::string, std::vector<ddkit::callback::Base*>> lambdaMap = M_SignalGenerator::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_SignalGenerator::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_SignalGenerator::IClient
{
auto cb = dynamic_cast<ddkit::callback::Wrapper<M_SignalGenerator::IClient, uint32_t>*>(obj);
if(cb && cb->isFunction(&M_SignalGenerator::IClient::ReportGeneratorState)) {
if(!methods.count("ReportGeneratorState")) {
std::vector<ddkit::callback::Base*> c;
methods.insert(std::make_pair("ReportGeneratorState", c));
}
methods["ReportGeneratorState"].push_back(obj);
continue;
}
}
{
auto cb = dynamic_cast<ddkit::callback::Wrapper<M_SignalGenerator::IClient, uint32_t>*>(obj);
if(cb && cb->isFunction(&M_SignalGenerator::IClient::ReportControllerOperationMode)) {
if(!methods.count("ReportControllerOperationMode")) {
std::vector<ddkit::callback::Base*> c;
methods.insert(std::make_pair("ReportControllerOperationMode", c));
}
methods["ReportControllerOperationMode"].push_back(obj);
continue;
}
}
{
auto cb = dynamic_cast<ddkit::callback::Wrapper<M_SignalGenerator::IClient, uint32_t>*>(obj);
if(cb && cb->isFunction(&M_SignalGenerator::IClient::ReportControlMode)) {
if(!methods.count("ReportControlMode")) {
std::vector<ddkit::callback::Base*> c;
methods.insert(std::make_pair("ReportControlMode", c));
}
methods["ReportControlMode"].push_back(obj);
continue;
}
}
{
auto cb = dynamic_cast<ddkit::callback::Wrapper<M_SignalGenerator::IClient, uint32_t>*>(obj);
if(cb && cb->isFunction(&M_SignalGenerator::IClient::ReportTestMode)) {
if(!methods.count("ReportTestMode")) {
std::vector<ddkit::callback::Base*> c;
methods.insert(std::make_pair("ReportTestMode", c));
}
methods["ReportTestMode"].push_back(obj);
continue;
}
}
{
auto cb = dynamic_cast<ddkit::callback::Wrapper<M_SignalGenerator::IClient, uint32_t>*>(obj);
if(cb && cb->isFunction(&M_SignalGenerator::IClient::ReportTestAxis)) {
if(!methods.count("ReportTestAxis")) {
std::vector<ddkit::callback::Base*> c;
methods.insert(std::make_pair("ReportTestAxis", c));
}
methods["ReportTestAxis"].push_back(obj);
continue;
}
}
{
auto cb = dynamic_cast<ddkit::callback::Wrapper<M_SignalGenerator::IClient, uint32_t>*>(obj);
if(cb && cb->isFunction(&M_SignalGenerator::IClient::ReportTestSource)) {
if(!methods.count("ReportTestSource")) {
std::vector<ddkit::callback::Base*> c;
methods.insert(std::make_pair("ReportTestSource", c));
}
methods["ReportTestSource"].push_back(obj);
continue;
}
}
{
auto cb = dynamic_cast<ddkit::callback::Wrapper<M_SignalGenerator::IClient, M_Common::DoubleListType const&>*>(obj);
if(cb && cb->isFunction(&M_SignalGenerator::IClient::EventSensorOutput)) {
if(!methods.count("EventSensorOutput")) {
std::vector<ddkit::callback::Base*> c;
methods.insert(std::make_pair("EventSensorOutput", c));
}
methods["EventSensorOutput"].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_SignalGenerator::IClient
{
auto cb = dynamic_cast<ddkit::callback::Wrapper<M_SignalGenerator::IClient, uint32_t>*>(obj);
if(cb && cb->isFunction(&M_SignalGenerator::IClient::ReportGeneratorState)) {
methods.insert("ReportGeneratorState");
continue;
}
}
{
auto cb = dynamic_cast<ddkit::callback::Wrapper<M_SignalGenerator::IClient, uint32_t>*>(obj);
if(cb && cb->isFunction(&M_SignalGenerator::IClient::ReportControllerOperationMode)) {
methods.insert("ReportControllerOperationMode");
continue;
}
}
{
auto cb = dynamic_cast<ddkit::callback::Wrapper<M_SignalGenerator::IClient, uint32_t>*>(obj);
if(cb && cb->isFunction(&M_SignalGenerator::IClient::ReportControlMode)) {
methods.insert("ReportControlMode");
continue;
}
}
{
auto cb = dynamic_cast<ddkit::callback::Wrapper<M_SignalGenerator::IClient, uint32_t>*>(obj);
if(cb && cb->isFunction(&M_SignalGenerator::IClient::ReportTestMode)) {
methods.insert("ReportTestMode");
continue;
}
}
{
auto cb = dynamic_cast<ddkit::callback::Wrapper<M_SignalGenerator::IClient, uint32_t>*>(obj);
if(cb && cb->isFunction(&M_SignalGenerator::IClient::ReportTestAxis)) {
methods.insert("ReportTestAxis");
continue;
}
}
{
auto cb = dynamic_cast<ddkit::callback::Wrapper<M_SignalGenerator::IClient, uint32_t>*>(obj);
if(cb && cb->isFunction(&M_SignalGenerator::IClient::ReportTestSource)) {
methods.insert("ReportTestSource");
continue;
}
}
{
auto cb = dynamic_cast<ddkit::callback::Wrapper<M_SignalGenerator::IClient, M_Common::DoubleListType const&>*>(obj);
if(cb && cb->isFunction(&M_SignalGenerator::IClient::EventSensorOutput)) {
methods.insert("EventSensorOutput");
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_SignalGenerator::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_SignalGenerator::IClient
if (!std::is_same<decltype(&IClient::ReportGeneratorState),
decltype(&IClientDerived::ReportGeneratorState)
>::value) methods.push_back("ReportGeneratorState");
if (!std::is_same<decltype(&IClient::ReportControllerOperationMode),
decltype(&IClientDerived::ReportControllerOperationMode)
>::value) methods.push_back("ReportControllerOperationMode");
if (!std::is_same<decltype(&IClient::ReportControlMode),
decltype(&IClientDerived::ReportControlMode)
>::value) methods.push_back("ReportControlMode");
if (!std::is_same<decltype(&IClient::ReportTestMode),
decltype(&IClientDerived::ReportTestMode)
>::value) methods.push_back("ReportTestMode");
if (!std::is_same<decltype(&IClient::ReportTestAxis),
decltype(&IClientDerived::ReportTestAxis)
>::value) methods.push_back("ReportTestAxis");
if (!std::is_same<decltype(&IClient::ReportTestSource),
decltype(&IClientDerived::ReportTestSource)
>::value) methods.push_back("ReportTestSource");
if (!std::is_same<decltype(&IClient::EventSensorOutput),
decltype(&IClientDerived::EventSensorOutput)
>::value) methods.push_back("EventSensorOutput");
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_SignalGenerator::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_SignalGenerator::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_SignalGenerator::detectMethodsIClient(callbacks, false);
std::map<std::string, std::vector<ddkit::callback::Base*>> lambdaMap = M_SignalGenerator::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_SignalGenerator::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_SignalGenerator::detectMethodsIClient(callbacks, false);
std::map<std::string, std::vector<ddkit::callback::Base*>> lambdaMap = M_SignalGenerator::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_SignalGenerator::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_SignalGenerator::detectMethodsIClient(callbacks, false);
std::map<std::string, std::vector<ddkit::callback::Base*>> lambdaMap = M_SignalGenerator::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_SignalGenerator::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_SignalGenerator::detectMethodsIClient(callbacks, false);
std::map<std::string, std::vector<ddkit::callback::Base*>> lambdaMap = M_SignalGenerator::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_SignalGenerator::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_SignalGenerator::detectMethodsIClient(callbacks, false);
std::map<std::string, std::vector<ddkit::callback::Base*>> lambdaMap = M_SignalGenerator::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_SignalGenerator::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_SignalGenerator::detectMethodsIClient(callbacks, false);
std::map<std::string, std::vector<ddkit::callback::Base*>> lambdaMap = M_SignalGenerator::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_SignalGenerator::detectMethodsIClient(callbacks, isCheckMostDerivedClassType(*monitorSession.get()));
return createCustomReadOnlyMultiplex(monitorSession, callbacks, methods);
}
#endif
} // namespace M_SignalGenerator
#endif