1384 lines
66 KiB
C++
1384 lines
66 KiB
C++
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
|
//
|
|
// GENERATED CODE - do not edit (Generated by ddkit/genModelApi)
|
|
//
|
|
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
|
|
|
// Alert.hpp (rmodel-api)
|
|
|
|
|
|
#ifndef Alert_API
|
|
#define Alert_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/Alert.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_Alert {
|
|
|
|
|
|
|
|
class TMSIF_EXPORT IServiceFactory {
|
|
|
|
public:
|
|
typedef M_Alert::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_Alert::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_Alert::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_Alert::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_Alert::IService* obs, std::string const& ignoredOps, int domain);
|
|
|
|
/// @brief Unregister observer previously registered with add...()
|
|
TMSIF_DEPRECATED
|
|
static void removeObs(M_Alert::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_Alert::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_Alert::IService* obs, StringSet custom, std::string serviceName, int domain);
|
|
static void addCustom(M_Alert::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_Alert::IService InterfaceTypeReceiver;
|
|
typedef M_Alert::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_Alert::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_Alert::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_Alert::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_Alert::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_Alert::IClient* obs, std::string const& ignoredOps, int domain);
|
|
|
|
/// @brief Unregister observer previously registered with add...()
|
|
TMSIF_DEPRECATED
|
|
static void removeObs(M_Alert::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_Alert::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_Alert::IClient* obs, std::string const& ignoredOps, int domain, std::string const& clientName);
|
|
|
|
|
|
private:
|
|
static void addCustom(M_Alert::IClient* obs, StringSet custom, std::string serviceName, int domain);
|
|
static void addCustom(M_Alert::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_Alert::IClient InterfaceTypeReceiver;
|
|
typedef M_Alert::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_Alert::IService
|
|
{
|
|
auto cb = dynamic_cast<ddkit::callback::Wrapper<M_Alert::IService, M_Alert::AlarmConditionInfoType const&>*>(obj);
|
|
if(cb && cb->isFunction(&M_Alert::IService::CmdRaiseAlarm)) {
|
|
if(!methods.count("CmdRaiseAlarm")) {
|
|
std::vector<ddkit::callback::Base*> c;
|
|
methods.insert(std::make_pair("CmdRaiseAlarm", c));
|
|
}
|
|
|
|
methods["CmdRaiseAlarm"].push_back(obj);
|
|
continue;
|
|
}
|
|
}
|
|
{
|
|
auto cb = dynamic_cast<ddkit::callback::Wrapper<M_Alert::IService, M_Alert::AlarmConditionInfoType const&>*>(obj);
|
|
if(cb && cb->isFunction(&M_Alert::IService::CmdResolveAlarm)) {
|
|
if(!methods.count("CmdResolveAlarm")) {
|
|
std::vector<ddkit::callback::Base*> c;
|
|
methods.insert(std::make_pair("CmdResolveAlarm", c));
|
|
}
|
|
|
|
methods["CmdResolveAlarm"].push_back(obj);
|
|
continue;
|
|
}
|
|
}
|
|
{
|
|
auto cb = dynamic_cast<ddkit::callback::Wrapper<M_Alert::IService, M_Alert::AlertIdListType const&>*>(obj);
|
|
if(cb && cb->isFunction(&M_Alert::IService::CmdAcknowledgeAlarm)) {
|
|
if(!methods.count("CmdAcknowledgeAlarm")) {
|
|
std::vector<ddkit::callback::Base*> c;
|
|
methods.insert(std::make_pair("CmdAcknowledgeAlarm", c));
|
|
}
|
|
|
|
methods["CmdAcknowledgeAlarm"].push_back(obj);
|
|
continue;
|
|
}
|
|
}
|
|
{
|
|
auto cb = dynamic_cast<ddkit::callback::Wrapper<M_Alert::IService, M_Alert::AlarmConditionInfoType const&>*>(obj);
|
|
if(cb && cb->isFunction(&M_Alert::IService::CmdOverrideAlarmCondition)) {
|
|
if(!methods.count("CmdOverrideAlarmCondition")) {
|
|
std::vector<ddkit::callback::Base*> c;
|
|
methods.insert(std::make_pair("CmdOverrideAlarmCondition", c));
|
|
}
|
|
|
|
methods["CmdOverrideAlarmCondition"].push_back(obj);
|
|
continue;
|
|
}
|
|
}
|
|
{
|
|
auto cb = dynamic_cast<ddkit::callback::Wrapper<M_Alert::IService, M_Alert::AlarmConditionInfoType const&>*>(obj);
|
|
if(cb && cb->isFunction(&M_Alert::IService::CmdUnoverrideAlarmCondition)) {
|
|
if(!methods.count("CmdUnoverrideAlarmCondition")) {
|
|
std::vector<ddkit::callback::Base*> c;
|
|
methods.insert(std::make_pair("CmdUnoverrideAlarmCondition", c));
|
|
}
|
|
|
|
methods["CmdUnoverrideAlarmCondition"].push_back(obj);
|
|
continue;
|
|
}
|
|
}
|
|
{
|
|
auto cb = dynamic_cast<ddkit::callback::Wrapper<M_Alert::IService, M_Alert::AlertIdListType const&>*>(obj);
|
|
if(cb && cb->isFunction(&M_Alert::IService::CmdClearAlarm)) {
|
|
if(!methods.count("CmdClearAlarm")) {
|
|
std::vector<ddkit::callback::Base*> c;
|
|
methods.insert(std::make_pair("CmdClearAlarm", c));
|
|
}
|
|
|
|
methods["CmdClearAlarm"].push_back(obj);
|
|
continue;
|
|
}
|
|
}
|
|
{
|
|
auto cb = dynamic_cast<ddkit::callback::Wrapper<M_Alert::IService, M_Alert::AlertIdType const&, M_Alert::ThreatLogType const&>*>(obj);
|
|
if(cb && cb->isFunction(&M_Alert::IService::CmdRaiseThreatAlert)) {
|
|
if(!methods.count("CmdRaiseThreatAlert")) {
|
|
std::vector<ddkit::callback::Base*> c;
|
|
methods.insert(std::make_pair("CmdRaiseThreatAlert", c));
|
|
}
|
|
|
|
methods["CmdRaiseThreatAlert"].push_back(obj);
|
|
continue;
|
|
}
|
|
}
|
|
{
|
|
auto cb = dynamic_cast<ddkit::callback::Wrapper<M_Alert::IService, M_Alert::AlertIdListType const&>*>(obj);
|
|
if(cb && cb->isFunction(&M_Alert::IService::CmdCancelThreatAlert)) {
|
|
if(!methods.count("CmdCancelThreatAlert")) {
|
|
std::vector<ddkit::callback::Base*> c;
|
|
methods.insert(std::make_pair("CmdCancelThreatAlert", c));
|
|
}
|
|
|
|
methods["CmdCancelThreatAlert"].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_Alert::IService
|
|
{
|
|
auto cb = dynamic_cast<ddkit::callback::Wrapper<M_Alert::IService, M_Alert::AlarmConditionInfoType const&>*>(obj);
|
|
if(cb && cb->isFunction(&M_Alert::IService::CmdRaiseAlarm)) {
|
|
methods.insert("CmdRaiseAlarm");
|
|
continue;
|
|
}
|
|
}
|
|
{
|
|
auto cb = dynamic_cast<ddkit::callback::Wrapper<M_Alert::IService, M_Alert::AlarmConditionInfoType const&>*>(obj);
|
|
if(cb && cb->isFunction(&M_Alert::IService::CmdResolveAlarm)) {
|
|
methods.insert("CmdResolveAlarm");
|
|
continue;
|
|
}
|
|
}
|
|
{
|
|
auto cb = dynamic_cast<ddkit::callback::Wrapper<M_Alert::IService, M_Alert::AlertIdListType const&>*>(obj);
|
|
if(cb && cb->isFunction(&M_Alert::IService::CmdAcknowledgeAlarm)) {
|
|
methods.insert("CmdAcknowledgeAlarm");
|
|
continue;
|
|
}
|
|
}
|
|
{
|
|
auto cb = dynamic_cast<ddkit::callback::Wrapper<M_Alert::IService, M_Alert::AlarmConditionInfoType const&>*>(obj);
|
|
if(cb && cb->isFunction(&M_Alert::IService::CmdOverrideAlarmCondition)) {
|
|
methods.insert("CmdOverrideAlarmCondition");
|
|
continue;
|
|
}
|
|
}
|
|
{
|
|
auto cb = dynamic_cast<ddkit::callback::Wrapper<M_Alert::IService, M_Alert::AlarmConditionInfoType const&>*>(obj);
|
|
if(cb && cb->isFunction(&M_Alert::IService::CmdUnoverrideAlarmCondition)) {
|
|
methods.insert("CmdUnoverrideAlarmCondition");
|
|
continue;
|
|
}
|
|
}
|
|
{
|
|
auto cb = dynamic_cast<ddkit::callback::Wrapper<M_Alert::IService, M_Alert::AlertIdListType const&>*>(obj);
|
|
if(cb && cb->isFunction(&M_Alert::IService::CmdClearAlarm)) {
|
|
methods.insert("CmdClearAlarm");
|
|
continue;
|
|
}
|
|
}
|
|
{
|
|
auto cb = dynamic_cast<ddkit::callback::Wrapper<M_Alert::IService, M_Alert::AlertIdType const&, M_Alert::ThreatLogType const&>*>(obj);
|
|
if(cb && cb->isFunction(&M_Alert::IService::CmdRaiseThreatAlert)) {
|
|
methods.insert("CmdRaiseThreatAlert");
|
|
continue;
|
|
}
|
|
}
|
|
{
|
|
auto cb = dynamic_cast<ddkit::callback::Wrapper<M_Alert::IService, M_Alert::AlertIdListType const&>*>(obj);
|
|
if(cb && cb->isFunction(&M_Alert::IService::CmdCancelThreatAlert)) {
|
|
methods.insert("CmdCancelThreatAlert");
|
|
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_Alert::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_Alert::IService
|
|
if (!std::is_same<decltype(&IService::CmdRaiseAlarm),
|
|
decltype(&IServiceDerived::CmdRaiseAlarm)
|
|
>::value) methods.push_back("CmdRaiseAlarm");
|
|
if (!std::is_same<decltype(&IService::CmdResolveAlarm),
|
|
decltype(&IServiceDerived::CmdResolveAlarm)
|
|
>::value) methods.push_back("CmdResolveAlarm");
|
|
if (!std::is_same<decltype(&IService::CmdAcknowledgeAlarm),
|
|
decltype(&IServiceDerived::CmdAcknowledgeAlarm)
|
|
>::value) methods.push_back("CmdAcknowledgeAlarm");
|
|
if (!std::is_same<decltype(&IService::CmdOverrideAlarmCondition),
|
|
decltype(&IServiceDerived::CmdOverrideAlarmCondition)
|
|
>::value) methods.push_back("CmdOverrideAlarmCondition");
|
|
if (!std::is_same<decltype(&IService::CmdUnoverrideAlarmCondition),
|
|
decltype(&IServiceDerived::CmdUnoverrideAlarmCondition)
|
|
>::value) methods.push_back("CmdUnoverrideAlarmCondition");
|
|
if (!std::is_same<decltype(&IService::CmdClearAlarm),
|
|
decltype(&IServiceDerived::CmdClearAlarm)
|
|
>::value) methods.push_back("CmdClearAlarm");
|
|
if (!std::is_same<decltype(&IService::CmdRaiseThreatAlert),
|
|
decltype(&IServiceDerived::CmdRaiseThreatAlert)
|
|
>::value) methods.push_back("CmdRaiseThreatAlert");
|
|
if (!std::is_same<decltype(&IService::CmdCancelThreatAlert),
|
|
decltype(&IServiceDerived::CmdCancelThreatAlert)
|
|
>::value) methods.push_back("CmdCancelThreatAlert");
|
|
|
|
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_Alert::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_Alert::detectMethodsIService(callbacks, false);
|
|
std::map<std::string, std::vector<ddkit::callback::Base*>> lambdaMap = M_Alert::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_Alert::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_Alert::detectMethodsIService(callbacks, false);
|
|
std::map<std::string, std::vector<ddkit::callback::Base*>> lambdaMap = M_Alert::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_Alert::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_Alert::detectMethodsIService(callbacks, false);
|
|
std::map<std::string, std::vector<ddkit::callback::Base*>> lambdaMap = M_Alert::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_Alert::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_Alert::detectMethodsIService(callbacks, false);
|
|
std::map<std::string, std::vector<ddkit::callback::Base*>> lambdaMap = M_Alert::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_Alert::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_Alert::detectMethodsIService(callbacks, false);
|
|
std::map<std::string, std::vector<ddkit::callback::Base*>> lambdaMap = M_Alert::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_Alert::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_Alert::detectMethodsIService(callbacks, false);
|
|
std::map<std::string, std::vector<ddkit::callback::Base*>> lambdaMap = M_Alert::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_Alert::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_Alert::IClient
|
|
{
|
|
auto cb = dynamic_cast<ddkit::callback::Wrapper<M_Alert::IClient, M_Alert::AlertSettingsType const&>*>(obj);
|
|
if(cb && cb->isFunction(&M_Alert::IClient::ReportAlertSettings)) {
|
|
if(!methods.count("ReportAlertSettings")) {
|
|
std::vector<ddkit::callback::Base*> c;
|
|
methods.insert(std::make_pair("ReportAlertSettings", c));
|
|
}
|
|
|
|
methods["ReportAlertSettings"].push_back(obj);
|
|
continue;
|
|
}
|
|
}
|
|
{
|
|
auto cb = dynamic_cast<ddkit::callback::Wrapper<M_Alert::IClient, M_Alert::AlertStatusType const&, bool>*>(obj);
|
|
if(cb && cb->isFunction(&M_Alert::IClient::ReportAlertStatus)) {
|
|
if(!methods.count("ReportAlertStatus")) {
|
|
std::vector<ddkit::callback::Base*> c;
|
|
methods.insert(std::make_pair("ReportAlertStatus", c));
|
|
}
|
|
|
|
methods["ReportAlertStatus"].push_back(obj);
|
|
continue;
|
|
}
|
|
}
|
|
{
|
|
auto cb = dynamic_cast<ddkit::callback::Wrapper<M_Alert::IClient, M_Alert::AlertIdType const&, M_Alert::AlarmLogType const&, bool>*>(obj);
|
|
if(cb && cb->isFunction(&M_Alert::IClient::ReportAlarmLog)) {
|
|
if(!methods.count("ReportAlarmLog")) {
|
|
std::vector<ddkit::callback::Base*> c;
|
|
methods.insert(std::make_pair("ReportAlarmLog", c));
|
|
}
|
|
|
|
methods["ReportAlarmLog"].push_back(obj);
|
|
continue;
|
|
}
|
|
}
|
|
{
|
|
auto cb = dynamic_cast<ddkit::callback::Wrapper<M_Alert::IClient, std::string const&, M_Alert::AlarmAnnunciationType const&, bool>*>(obj);
|
|
if(cb && cb->isFunction(&M_Alert::IClient::ReportAlarmAnnunciation)) {
|
|
if(!methods.count("ReportAlarmAnnunciation")) {
|
|
std::vector<ddkit::callback::Base*> c;
|
|
methods.insert(std::make_pair("ReportAlarmAnnunciation", c));
|
|
}
|
|
|
|
methods["ReportAlarmAnnunciation"].push_back(obj);
|
|
continue;
|
|
}
|
|
}
|
|
{
|
|
auto cb = dynamic_cast<ddkit::callback::Wrapper<M_Alert::IClient, M_Alert::AlertIdType const&, M_Alert::ThreatLogType const&, bool>*>(obj);
|
|
if(cb && cb->isFunction(&M_Alert::IClient::ReportThreatLog)) {
|
|
if(!methods.count("ReportThreatLog")) {
|
|
std::vector<ddkit::callback::Base*> c;
|
|
methods.insert(std::make_pair("ReportThreatLog", c));
|
|
}
|
|
|
|
methods["ReportThreatLog"].push_back(obj);
|
|
continue;
|
|
}
|
|
}
|
|
{
|
|
auto cb = dynamic_cast<ddkit::callback::Wrapper<M_Alert::IClient, M_Alert::ThreatAnnunciationType const&, bool>*>(obj);
|
|
if(cb && cb->isFunction(&M_Alert::IClient::ReportThreatAnnunciation)) {
|
|
if(!methods.count("ReportThreatAnnunciation")) {
|
|
std::vector<ddkit::callback::Base*> c;
|
|
methods.insert(std::make_pair("ReportThreatAnnunciation", c));
|
|
}
|
|
|
|
methods["ReportThreatAnnunciation"].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_Alert::IClient
|
|
{
|
|
auto cb = dynamic_cast<ddkit::callback::Wrapper<M_Alert::IClient, M_Alert::AlertSettingsType const&>*>(obj);
|
|
if(cb && cb->isFunction(&M_Alert::IClient::ReportAlertSettings)) {
|
|
methods.insert("ReportAlertSettings");
|
|
continue;
|
|
}
|
|
}
|
|
{
|
|
auto cb = dynamic_cast<ddkit::callback::Wrapper<M_Alert::IClient, M_Alert::AlertStatusType const&, bool>*>(obj);
|
|
if(cb && cb->isFunction(&M_Alert::IClient::ReportAlertStatus)) {
|
|
methods.insert("ReportAlertStatus");
|
|
continue;
|
|
}
|
|
}
|
|
{
|
|
auto cb = dynamic_cast<ddkit::callback::Wrapper<M_Alert::IClient, M_Alert::AlertIdType const&, M_Alert::AlarmLogType const&, bool>*>(obj);
|
|
if(cb && cb->isFunction(&M_Alert::IClient::ReportAlarmLog)) {
|
|
methods.insert("ReportAlarmLog");
|
|
continue;
|
|
}
|
|
}
|
|
{
|
|
auto cb = dynamic_cast<ddkit::callback::Wrapper<M_Alert::IClient, std::string const&, M_Alert::AlarmAnnunciationType const&, bool>*>(obj);
|
|
if(cb && cb->isFunction(&M_Alert::IClient::ReportAlarmAnnunciation)) {
|
|
methods.insert("ReportAlarmAnnunciation");
|
|
continue;
|
|
}
|
|
}
|
|
{
|
|
auto cb = dynamic_cast<ddkit::callback::Wrapper<M_Alert::IClient, M_Alert::AlertIdType const&, M_Alert::ThreatLogType const&, bool>*>(obj);
|
|
if(cb && cb->isFunction(&M_Alert::IClient::ReportThreatLog)) {
|
|
methods.insert("ReportThreatLog");
|
|
continue;
|
|
}
|
|
}
|
|
{
|
|
auto cb = dynamic_cast<ddkit::callback::Wrapper<M_Alert::IClient, M_Alert::ThreatAnnunciationType const&, bool>*>(obj);
|
|
if(cb && cb->isFunction(&M_Alert::IClient::ReportThreatAnnunciation)) {
|
|
methods.insert("ReportThreatAnnunciation");
|
|
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_Alert::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_Alert::IClient
|
|
if (!std::is_same<decltype(&IClient::ReportAlertSettings),
|
|
decltype(&IClientDerived::ReportAlertSettings)
|
|
>::value) methods.push_back("ReportAlertSettings");
|
|
if (!std::is_same<decltype(&IClient::ReportAlertStatus),
|
|
decltype(&IClientDerived::ReportAlertStatus)
|
|
>::value) methods.push_back("ReportAlertStatus");
|
|
if (!std::is_same<decltype(&IClient::ReportAlarmLog),
|
|
decltype(&IClientDerived::ReportAlarmLog)
|
|
>::value) methods.push_back("ReportAlarmLog");
|
|
if (!std::is_same<decltype(&IClient::ReportAlarmAnnunciation),
|
|
decltype(&IClientDerived::ReportAlarmAnnunciation)
|
|
>::value) methods.push_back("ReportAlarmAnnunciation");
|
|
if (!std::is_same<decltype(&IClient::ReportThreatLog),
|
|
decltype(&IClientDerived::ReportThreatLog)
|
|
>::value) methods.push_back("ReportThreatLog");
|
|
if (!std::is_same<decltype(&IClient::ReportThreatAnnunciation),
|
|
decltype(&IClientDerived::ReportThreatAnnunciation)
|
|
>::value) methods.push_back("ReportThreatAnnunciation");
|
|
|
|
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_Alert::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_Alert::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_Alert::detectMethodsIClient(callbacks, false);
|
|
std::map<std::string, std::vector<ddkit::callback::Base*>> lambdaMap = M_Alert::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_Alert::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_Alert::detectMethodsIClient(callbacks, false);
|
|
std::map<std::string, std::vector<ddkit::callback::Base*>> lambdaMap = M_Alert::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_Alert::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_Alert::detectMethodsIClient(callbacks, false);
|
|
std::map<std::string, std::vector<ddkit::callback::Base*>> lambdaMap = M_Alert::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_Alert::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_Alert::detectMethodsIClient(callbacks, false);
|
|
std::map<std::string, std::vector<ddkit::callback::Base*>> lambdaMap = M_Alert::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_Alert::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_Alert::detectMethodsIClient(callbacks, false);
|
|
std::map<std::string, std::vector<ddkit::callback::Base*>> lambdaMap = M_Alert::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_Alert::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_Alert::detectMethodsIClient(callbacks, false);
|
|
std::map<std::string, std::vector<ddkit::callback::Base*>> lambdaMap = M_Alert::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_Alert::detectMethodsIClient(callbacks, isCheckMostDerivedClassType(*monitorSession.get()));
|
|
return createCustomReadOnlyMultiplex(monitorSession, callbacks, methods);
|
|
}
|
|
|
|
#endif
|
|
|
|
|
|
|
|
} // namespace M_Alert
|
|
|
|
|
|
#endif
|