1550 lines
75 KiB
C++
1550 lines
75 KiB
C++
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
|
//
|
|
// GENERATED CODE - do not edit (Generated by ddkit/genModelApi)
|
|
//
|
|
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
|
|
|
// MissileLauncher.hpp (rmodel-api)
|
|
|
|
|
|
#ifndef MissileLauncher_API
|
|
#define MissileLauncher_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/MissileLauncher.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_MissileLauncher {
|
|
|
|
|
|
|
|
class TMSIF_EXPORT IServiceFactory {
|
|
|
|
public:
|
|
typedef M_MissileLauncher::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_MissileLauncher::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_MissileLauncher::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_MissileLauncher::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_MissileLauncher::IService* obs, std::string const& ignoredOps, int domain);
|
|
|
|
/// @brief Unregister observer previously registered with add...()
|
|
TMSIF_DEPRECATED
|
|
static void removeObs(M_MissileLauncher::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_MissileLauncher::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_MissileLauncher::IService* obs, StringSet custom, std::string serviceName, int domain);
|
|
static void addCustom(M_MissileLauncher::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_MissileLauncher::IService InterfaceTypeReceiver;
|
|
typedef M_MissileLauncher::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_MissileLauncher::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_MissileLauncher::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_MissileLauncher::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_MissileLauncher::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_MissileLauncher::IClient* obs, std::string const& ignoredOps, int domain);
|
|
|
|
/// @brief Unregister observer previously registered with add...()
|
|
TMSIF_DEPRECATED
|
|
static void removeObs(M_MissileLauncher::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_MissileLauncher::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_MissileLauncher::IClient* obs, std::string const& ignoredOps, int domain, std::string const& clientName);
|
|
|
|
|
|
private:
|
|
static void addCustom(M_MissileLauncher::IClient* obs, StringSet custom, std::string serviceName, int domain);
|
|
static void addCustom(M_MissileLauncher::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_MissileLauncher::IClient InterfaceTypeReceiver;
|
|
typedef M_MissileLauncher::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_Effector::IService
|
|
{
|
|
auto cb = dynamic_cast<ddkit::callback::Wrapper<M_Effector::IService, bool>*>(obj);
|
|
if(cb && cb->isFunction(&M_Effector::IService::CmdSetOperationMode)) {
|
|
if(!methods.count("CmdSetOperationMode")) {
|
|
std::vector<ddkit::callback::Base*> c;
|
|
methods.insert(std::make_pair("CmdSetOperationMode", c));
|
|
}
|
|
|
|
methods["CmdSetOperationMode"].push_back(obj);
|
|
continue;
|
|
}
|
|
}
|
|
{
|
|
auto cb = dynamic_cast<ddkit::callback::Wrapper<M_Effector::IService, M_Effector::EffectorTrackingMode::Type>*>(obj);
|
|
if(cb && cb->isFunction(&M_Effector::IService::CmdSetTrackingMode)) {
|
|
if(!methods.count("CmdSetTrackingMode")) {
|
|
std::vector<ddkit::callback::Base*> c;
|
|
methods.insert(std::make_pair("CmdSetTrackingMode", c));
|
|
}
|
|
|
|
methods["CmdSetTrackingMode"].push_back(obj);
|
|
continue;
|
|
}
|
|
}
|
|
{
|
|
auto cb = dynamic_cast<ddkit::callback::Wrapper<M_Effector::IService, bool>*>(obj);
|
|
if(cb && cb->isFunction(&M_Effector::IService::CmdArm)) {
|
|
if(!methods.count("CmdArm")) {
|
|
std::vector<ddkit::callback::Base*> c;
|
|
methods.insert(std::make_pair("CmdArm", c));
|
|
}
|
|
|
|
methods["CmdArm"].push_back(obj);
|
|
continue;
|
|
}
|
|
}
|
|
{
|
|
auto cb = dynamic_cast<ddkit::callback::Wrapper<M_Effector::IService, bool>*>(obj);
|
|
if(cb && cb->isFunction(&M_Effector::IService::CmdFire)) {
|
|
if(!methods.count("CmdFire")) {
|
|
std::vector<ddkit::callback::Base*> c;
|
|
methods.insert(std::make_pair("CmdFire", c));
|
|
}
|
|
|
|
methods["CmdFire"].push_back(obj);
|
|
continue;
|
|
}
|
|
}
|
|
{
|
|
auto cb = dynamic_cast<ddkit::callback::Wrapper<M_Effector::IService, std::string const&>*>(obj);
|
|
if(cb && cb->isFunction(&M_Effector::IService::CmdSetSelectedAmmunition)) {
|
|
if(!methods.count("CmdSetSelectedAmmunition")) {
|
|
std::vector<ddkit::callback::Base*> c;
|
|
methods.insert(std::make_pair("CmdSetSelectedAmmunition", c));
|
|
}
|
|
|
|
methods["CmdSetSelectedAmmunition"].push_back(obj);
|
|
continue;
|
|
}
|
|
}
|
|
{
|
|
auto cb = dynamic_cast<ddkit::callback::Wrapper<M_Effector::IService, M_Common::RateOfFireRpmType>*>(obj);
|
|
if(cb && cb->isFunction(&M_Effector::IService::CmdSetRateOfFire)) {
|
|
if(!methods.count("CmdSetRateOfFire")) {
|
|
std::vector<ddkit::callback::Base*> c;
|
|
methods.insert(std::make_pair("CmdSetRateOfFire", c));
|
|
}
|
|
|
|
methods["CmdSetRateOfFire"].push_back(obj);
|
|
continue;
|
|
}
|
|
}
|
|
{
|
|
auto cb = dynamic_cast<ddkit::callback::Wrapper<M_Effector::IService, uint32_t>*>(obj);
|
|
if(cb && cb->isFunction(&M_Effector::IService::CmdSetBurstLength)) {
|
|
if(!methods.count("CmdSetBurstLength")) {
|
|
std::vector<ddkit::callback::Base*> c;
|
|
methods.insert(std::make_pair("CmdSetBurstLength", c));
|
|
}
|
|
|
|
methods["CmdSetBurstLength"].push_back(obj);
|
|
continue;
|
|
}
|
|
}
|
|
{
|
|
auto cb = dynamic_cast<ddkit::callback::Wrapper<M_Effector::IService, std::string const&, uint32_t>*>(obj);
|
|
if(cb && cb->isFunction(&M_Effector::IService::CmdSetAmmunitionCount)) {
|
|
if(!methods.count("CmdSetAmmunitionCount")) {
|
|
std::vector<ddkit::callback::Base*> c;
|
|
methods.insert(std::make_pair("CmdSetAmmunitionCount", c));
|
|
}
|
|
|
|
methods["CmdSetAmmunitionCount"].push_back(obj);
|
|
continue;
|
|
}
|
|
}
|
|
{
|
|
auto cb = dynamic_cast<ddkit::callback::Wrapper<M_Effector::IService, std::string const&, uint32_t>*>(obj);
|
|
if(cb && cb->isFunction(&M_Effector::IService::CmdSetAmmunitionMaxCount)) {
|
|
if(!methods.count("CmdSetAmmunitionMaxCount")) {
|
|
std::vector<ddkit::callback::Base*> c;
|
|
methods.insert(std::make_pair("CmdSetAmmunitionMaxCount", c));
|
|
}
|
|
|
|
methods["CmdSetAmmunitionMaxCount"].push_back(obj);
|
|
continue;
|
|
}
|
|
}
|
|
{
|
|
auto cb = dynamic_cast<ddkit::callback::Wrapper<M_Effector::IService, std::string const&, uint32_t>*>(obj);
|
|
if(cb && cb->isFunction(&M_Effector::IService::CmdSetShotCountLifeCycle)) {
|
|
if(!methods.count("CmdSetShotCountLifeCycle")) {
|
|
std::vector<ddkit::callback::Base*> c;
|
|
methods.insert(std::make_pair("CmdSetShotCountLifeCycle", c));
|
|
}
|
|
|
|
methods["CmdSetShotCountLifeCycle"].push_back(obj);
|
|
continue;
|
|
}
|
|
}
|
|
// methods of M_Teleoperation::IService
|
|
// methods of M_MissileLauncher::IService
|
|
{
|
|
auto cb = dynamic_cast<ddkit::callback::Wrapper<M_MissileLauncher::IService, std::string const&>*>(obj);
|
|
if(cb && cb->isFunction(&M_MissileLauncher::IService::ConfigPreselectedMissileStation)) {
|
|
if(!methods.count("ConfigPreselectedMissileStation")) {
|
|
std::vector<ddkit::callback::Base*> c;
|
|
methods.insert(std::make_pair("ConfigPreselectedMissileStation", c));
|
|
}
|
|
|
|
methods["ConfigPreselectedMissileStation"].push_back(obj);
|
|
continue;
|
|
}
|
|
}
|
|
{
|
|
auto cb = dynamic_cast<ddkit::callback::Wrapper<M_MissileLauncher::IService, M_MissileLauncher::TrajectoryKind::Type>*>(obj);
|
|
if(cb && cb->isFunction(&M_MissileLauncher::IService::ConfigTrajectory)) {
|
|
if(!methods.count("ConfigTrajectory")) {
|
|
std::vector<ddkit::callback::Base*> c;
|
|
methods.insert(std::make_pair("ConfigTrajectory", c));
|
|
}
|
|
|
|
methods["ConfigTrajectory"].push_back(obj);
|
|
continue;
|
|
}
|
|
}
|
|
{
|
|
auto cb = dynamic_cast<ddkit::callback::Wrapper<M_MissileLauncher::IService, bool>*>(obj);
|
|
if(cb && cb->isFunction(&M_MissileLauncher::IService::CmdAllowExternalLoading)) {
|
|
if(!methods.count("CmdAllowExternalLoading")) {
|
|
std::vector<ddkit::callback::Base*> c;
|
|
methods.insert(std::make_pair("CmdAllowExternalLoading", c));
|
|
}
|
|
|
|
methods["CmdAllowExternalLoading"].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_Effector::IService
|
|
{
|
|
auto cb = dynamic_cast<ddkit::callback::Wrapper<M_Effector::IService, bool>*>(obj);
|
|
if(cb && cb->isFunction(&M_Effector::IService::CmdSetOperationMode)) {
|
|
methods.insert("CmdSetOperationMode");
|
|
continue;
|
|
}
|
|
}
|
|
{
|
|
auto cb = dynamic_cast<ddkit::callback::Wrapper<M_Effector::IService, M_Effector::EffectorTrackingMode::Type>*>(obj);
|
|
if(cb && cb->isFunction(&M_Effector::IService::CmdSetTrackingMode)) {
|
|
methods.insert("CmdSetTrackingMode");
|
|
continue;
|
|
}
|
|
}
|
|
{
|
|
auto cb = dynamic_cast<ddkit::callback::Wrapper<M_Effector::IService, bool>*>(obj);
|
|
if(cb && cb->isFunction(&M_Effector::IService::CmdArm)) {
|
|
methods.insert("CmdArm");
|
|
continue;
|
|
}
|
|
}
|
|
{
|
|
auto cb = dynamic_cast<ddkit::callback::Wrapper<M_Effector::IService, bool>*>(obj);
|
|
if(cb && cb->isFunction(&M_Effector::IService::CmdFire)) {
|
|
methods.insert("CmdFire");
|
|
continue;
|
|
}
|
|
}
|
|
{
|
|
auto cb = dynamic_cast<ddkit::callback::Wrapper<M_Effector::IService, std::string const&>*>(obj);
|
|
if(cb && cb->isFunction(&M_Effector::IService::CmdSetSelectedAmmunition)) {
|
|
methods.insert("CmdSetSelectedAmmunition");
|
|
continue;
|
|
}
|
|
}
|
|
{
|
|
auto cb = dynamic_cast<ddkit::callback::Wrapper<M_Effector::IService, M_Common::RateOfFireRpmType>*>(obj);
|
|
if(cb && cb->isFunction(&M_Effector::IService::CmdSetRateOfFire)) {
|
|
methods.insert("CmdSetRateOfFire");
|
|
continue;
|
|
}
|
|
}
|
|
{
|
|
auto cb = dynamic_cast<ddkit::callback::Wrapper<M_Effector::IService, uint32_t>*>(obj);
|
|
if(cb && cb->isFunction(&M_Effector::IService::CmdSetBurstLength)) {
|
|
methods.insert("CmdSetBurstLength");
|
|
continue;
|
|
}
|
|
}
|
|
{
|
|
auto cb = dynamic_cast<ddkit::callback::Wrapper<M_Effector::IService, std::string const&, uint32_t>*>(obj);
|
|
if(cb && cb->isFunction(&M_Effector::IService::CmdSetAmmunitionCount)) {
|
|
methods.insert("CmdSetAmmunitionCount");
|
|
continue;
|
|
}
|
|
}
|
|
{
|
|
auto cb = dynamic_cast<ddkit::callback::Wrapper<M_Effector::IService, std::string const&, uint32_t>*>(obj);
|
|
if(cb && cb->isFunction(&M_Effector::IService::CmdSetAmmunitionMaxCount)) {
|
|
methods.insert("CmdSetAmmunitionMaxCount");
|
|
continue;
|
|
}
|
|
}
|
|
{
|
|
auto cb = dynamic_cast<ddkit::callback::Wrapper<M_Effector::IService, std::string const&, uint32_t>*>(obj);
|
|
if(cb && cb->isFunction(&M_Effector::IService::CmdSetShotCountLifeCycle)) {
|
|
methods.insert("CmdSetShotCountLifeCycle");
|
|
continue;
|
|
}
|
|
}
|
|
// methods of M_Teleoperation::IService
|
|
// methods of M_MissileLauncher::IService
|
|
{
|
|
auto cb = dynamic_cast<ddkit::callback::Wrapper<M_MissileLauncher::IService, std::string const&>*>(obj);
|
|
if(cb && cb->isFunction(&M_MissileLauncher::IService::ConfigPreselectedMissileStation)) {
|
|
methods.insert("ConfigPreselectedMissileStation");
|
|
continue;
|
|
}
|
|
}
|
|
{
|
|
auto cb = dynamic_cast<ddkit::callback::Wrapper<M_MissileLauncher::IService, M_MissileLauncher::TrajectoryKind::Type>*>(obj);
|
|
if(cb && cb->isFunction(&M_MissileLauncher::IService::ConfigTrajectory)) {
|
|
methods.insert("ConfigTrajectory");
|
|
continue;
|
|
}
|
|
}
|
|
{
|
|
auto cb = dynamic_cast<ddkit::callback::Wrapper<M_MissileLauncher::IService, bool>*>(obj);
|
|
if(cb && cb->isFunction(&M_MissileLauncher::IService::CmdAllowExternalLoading)) {
|
|
methods.insert("CmdAllowExternalLoading");
|
|
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_MissileLauncher::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_Effector::IService
|
|
if (!std::is_same<decltype(&IService::CmdSetOperationMode),
|
|
decltype(&IServiceDerived::CmdSetOperationMode)
|
|
>::value) methods.push_back("CmdSetOperationMode");
|
|
if (!std::is_same<decltype(&IService::CmdSetTrackingMode),
|
|
decltype(&IServiceDerived::CmdSetTrackingMode)
|
|
>::value) methods.push_back("CmdSetTrackingMode");
|
|
if (!std::is_same<decltype(&IService::CmdArm),
|
|
decltype(&IServiceDerived::CmdArm)
|
|
>::value) methods.push_back("CmdArm");
|
|
if (!std::is_same<decltype(&IService::CmdFire),
|
|
decltype(&IServiceDerived::CmdFire)
|
|
>::value) methods.push_back("CmdFire");
|
|
if (!std::is_same<decltype(&IService::CmdSetSelectedAmmunition),
|
|
decltype(&IServiceDerived::CmdSetSelectedAmmunition)
|
|
>::value) methods.push_back("CmdSetSelectedAmmunition");
|
|
if (!std::is_same<decltype(&IService::CmdSetRateOfFire),
|
|
decltype(&IServiceDerived::CmdSetRateOfFire)
|
|
>::value) methods.push_back("CmdSetRateOfFire");
|
|
if (!std::is_same<decltype(&IService::CmdSetBurstLength),
|
|
decltype(&IServiceDerived::CmdSetBurstLength)
|
|
>::value) methods.push_back("CmdSetBurstLength");
|
|
if (!std::is_same<decltype(&IService::CmdSetAmmunitionCount),
|
|
decltype(&IServiceDerived::CmdSetAmmunitionCount)
|
|
>::value) methods.push_back("CmdSetAmmunitionCount");
|
|
if (!std::is_same<decltype(&IService::CmdSetAmmunitionMaxCount),
|
|
decltype(&IServiceDerived::CmdSetAmmunitionMaxCount)
|
|
>::value) methods.push_back("CmdSetAmmunitionMaxCount");
|
|
if (!std::is_same<decltype(&IService::CmdSetShotCountLifeCycle),
|
|
decltype(&IServiceDerived::CmdSetShotCountLifeCycle)
|
|
>::value) methods.push_back("CmdSetShotCountLifeCycle");
|
|
// methods of M_Teleoperation::IService
|
|
// methods of M_MissileLauncher::IService
|
|
if (!std::is_same<decltype(&IService::ConfigPreselectedMissileStation),
|
|
decltype(&IServiceDerived::ConfigPreselectedMissileStation)
|
|
>::value) methods.push_back("ConfigPreselectedMissileStation");
|
|
if (!std::is_same<decltype(&IService::ConfigTrajectory),
|
|
decltype(&IServiceDerived::ConfigTrajectory)
|
|
>::value) methods.push_back("ConfigTrajectory");
|
|
if (!std::is_same<decltype(&IService::CmdAllowExternalLoading),
|
|
decltype(&IServiceDerived::CmdAllowExternalLoading)
|
|
>::value) methods.push_back("CmdAllowExternalLoading");
|
|
|
|
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_MissileLauncher::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_MissileLauncher::detectMethodsIService(callbacks, false);
|
|
std::map<std::string, std::vector<ddkit::callback::Base*>> lambdaMap = M_MissileLauncher::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_MissileLauncher::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_MissileLauncher::detectMethodsIService(callbacks, false);
|
|
std::map<std::string, std::vector<ddkit::callback::Base*>> lambdaMap = M_MissileLauncher::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_MissileLauncher::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_MissileLauncher::detectMethodsIService(callbacks, false);
|
|
std::map<std::string, std::vector<ddkit::callback::Base*>> lambdaMap = M_MissileLauncher::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_MissileLauncher::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_MissileLauncher::detectMethodsIService(callbacks, false);
|
|
std::map<std::string, std::vector<ddkit::callback::Base*>> lambdaMap = M_MissileLauncher::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_MissileLauncher::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_MissileLauncher::detectMethodsIService(callbacks, false);
|
|
std::map<std::string, std::vector<ddkit::callback::Base*>> lambdaMap = M_MissileLauncher::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_MissileLauncher::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_MissileLauncher::detectMethodsIService(callbacks, false);
|
|
std::map<std::string, std::vector<ddkit::callback::Base*>> lambdaMap = M_MissileLauncher::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_MissileLauncher::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_Effector::IClient
|
|
{
|
|
auto cb = dynamic_cast<ddkit::callback::Wrapper<M_Effector::IClient, M_Effector::EffectorSettingsType const&>*>(obj);
|
|
if(cb && cb->isFunction(&M_Effector::IClient::ReportEffectorSettings)) {
|
|
if(!methods.count("ReportEffectorSettings")) {
|
|
std::vector<ddkit::callback::Base*> c;
|
|
methods.insert(std::make_pair("ReportEffectorSettings", c));
|
|
}
|
|
|
|
methods["ReportEffectorSettings"].push_back(obj);
|
|
continue;
|
|
}
|
|
}
|
|
{
|
|
auto cb = dynamic_cast<ddkit::callback::Wrapper<M_Effector::IClient, M_Effector::EffectorStatusType const&, bool>*>(obj);
|
|
if(cb && cb->isFunction(&M_Effector::IClient::ReportEffectorStatus)) {
|
|
if(!methods.count("ReportEffectorStatus")) {
|
|
std::vector<ddkit::callback::Base*> c;
|
|
methods.insert(std::make_pair("ReportEffectorStatus", c));
|
|
}
|
|
|
|
methods["ReportEffectorStatus"].push_back(obj);
|
|
continue;
|
|
}
|
|
}
|
|
{
|
|
auto cb = dynamic_cast<ddkit::callback::Wrapper<M_Effector::IClient, std::string const&, std::string const&, M_Effector::EffectorTubeStatusType const&, bool>*>(obj);
|
|
if(cb && cb->isFunction(&M_Effector::IClient::ReportEffectorTubeStatus)) {
|
|
if(!methods.count("ReportEffectorTubeStatus")) {
|
|
std::vector<ddkit::callback::Base*> c;
|
|
methods.insert(std::make_pair("ReportEffectorTubeStatus", c));
|
|
}
|
|
|
|
methods["ReportEffectorTubeStatus"].push_back(obj);
|
|
continue;
|
|
}
|
|
}
|
|
// methods of M_Teleoperation::IClient
|
|
{
|
|
auto cb = dynamic_cast<ddkit::callback::Wrapper<M_Teleoperation::IClient, M_Teleoperation::TeleoperationCtrlSettingsType const&>*>(obj);
|
|
if(cb && cb->isFunction(&M_Teleoperation::IClient::ReportTeleoperationCtrlSettings)) {
|
|
if(!methods.count("ReportTeleoperationCtrlSettings")) {
|
|
std::vector<ddkit::callback::Base*> c;
|
|
methods.insert(std::make_pair("ReportTeleoperationCtrlSettings", c));
|
|
}
|
|
|
|
methods["ReportTeleoperationCtrlSettings"].push_back(obj);
|
|
continue;
|
|
}
|
|
}
|
|
{
|
|
auto cb = dynamic_cast<ddkit::callback::Wrapper<M_Teleoperation::IClient, std::string const&, M_Teleoperation::BatteryStatusType const&, bool>*>(obj);
|
|
if(cb && cb->isFunction(&M_Teleoperation::IClient::ReportBatteryStatus)) {
|
|
if(!methods.count("ReportBatteryStatus")) {
|
|
std::vector<ddkit::callback::Base*> c;
|
|
methods.insert(std::make_pair("ReportBatteryStatus", c));
|
|
}
|
|
|
|
methods["ReportBatteryStatus"].push_back(obj);
|
|
continue;
|
|
}
|
|
}
|
|
{
|
|
auto cb = dynamic_cast<ddkit::callback::Wrapper<M_Teleoperation::IClient, std::string const&, M_Teleoperation::RadioConnectionStatusType const&, bool>*>(obj);
|
|
if(cb && cb->isFunction(&M_Teleoperation::IClient::ReportRadioConnectionStatus)) {
|
|
if(!methods.count("ReportRadioConnectionStatus")) {
|
|
std::vector<ddkit::callback::Base*> c;
|
|
methods.insert(std::make_pair("ReportRadioConnectionStatus", c));
|
|
}
|
|
|
|
methods["ReportRadioConnectionStatus"].push_back(obj);
|
|
continue;
|
|
}
|
|
}
|
|
// methods of M_MissileLauncher::IClient
|
|
{
|
|
auto cb = dynamic_cast<ddkit::callback::Wrapper<M_MissileLauncher::IClient, M_MissileLauncher::MissileLauncherSettingsType const&>*>(obj);
|
|
if(cb && cb->isFunction(&M_MissileLauncher::IClient::ReportMissileLauncherSettings)) {
|
|
if(!methods.count("ReportMissileLauncherSettings")) {
|
|
std::vector<ddkit::callback::Base*> c;
|
|
methods.insert(std::make_pair("ReportMissileLauncherSettings", c));
|
|
}
|
|
|
|
methods["ReportMissileLauncherSettings"].push_back(obj);
|
|
continue;
|
|
}
|
|
}
|
|
{
|
|
auto cb = dynamic_cast<ddkit::callback::Wrapper<M_MissileLauncher::IClient, M_MissileLauncher::MissileLauncherStatusType const&, bool>*>(obj);
|
|
if(cb && cb->isFunction(&M_MissileLauncher::IClient::ReportMissileLauncherStatus)) {
|
|
if(!methods.count("ReportMissileLauncherStatus")) {
|
|
std::vector<ddkit::callback::Base*> c;
|
|
methods.insert(std::make_pair("ReportMissileLauncherStatus", c));
|
|
}
|
|
|
|
methods["ReportMissileLauncherStatus"].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_Effector::IClient
|
|
{
|
|
auto cb = dynamic_cast<ddkit::callback::Wrapper<M_Effector::IClient, M_Effector::EffectorSettingsType const&>*>(obj);
|
|
if(cb && cb->isFunction(&M_Effector::IClient::ReportEffectorSettings)) {
|
|
methods.insert("ReportEffectorSettings");
|
|
continue;
|
|
}
|
|
}
|
|
{
|
|
auto cb = dynamic_cast<ddkit::callback::Wrapper<M_Effector::IClient, M_Effector::EffectorStatusType const&, bool>*>(obj);
|
|
if(cb && cb->isFunction(&M_Effector::IClient::ReportEffectorStatus)) {
|
|
methods.insert("ReportEffectorStatus");
|
|
continue;
|
|
}
|
|
}
|
|
{
|
|
auto cb = dynamic_cast<ddkit::callback::Wrapper<M_Effector::IClient, std::string const&, std::string const&, M_Effector::EffectorTubeStatusType const&, bool>*>(obj);
|
|
if(cb && cb->isFunction(&M_Effector::IClient::ReportEffectorTubeStatus)) {
|
|
methods.insert("ReportEffectorTubeStatus");
|
|
continue;
|
|
}
|
|
}
|
|
// methods of M_Teleoperation::IClient
|
|
{
|
|
auto cb = dynamic_cast<ddkit::callback::Wrapper<M_Teleoperation::IClient, M_Teleoperation::TeleoperationCtrlSettingsType const&>*>(obj);
|
|
if(cb && cb->isFunction(&M_Teleoperation::IClient::ReportTeleoperationCtrlSettings)) {
|
|
methods.insert("ReportTeleoperationCtrlSettings");
|
|
continue;
|
|
}
|
|
}
|
|
{
|
|
auto cb = dynamic_cast<ddkit::callback::Wrapper<M_Teleoperation::IClient, std::string const&, M_Teleoperation::BatteryStatusType const&, bool>*>(obj);
|
|
if(cb && cb->isFunction(&M_Teleoperation::IClient::ReportBatteryStatus)) {
|
|
methods.insert("ReportBatteryStatus");
|
|
continue;
|
|
}
|
|
}
|
|
{
|
|
auto cb = dynamic_cast<ddkit::callback::Wrapper<M_Teleoperation::IClient, std::string const&, M_Teleoperation::RadioConnectionStatusType const&, bool>*>(obj);
|
|
if(cb && cb->isFunction(&M_Teleoperation::IClient::ReportRadioConnectionStatus)) {
|
|
methods.insert("ReportRadioConnectionStatus");
|
|
continue;
|
|
}
|
|
}
|
|
// methods of M_MissileLauncher::IClient
|
|
{
|
|
auto cb = dynamic_cast<ddkit::callback::Wrapper<M_MissileLauncher::IClient, M_MissileLauncher::MissileLauncherSettingsType const&>*>(obj);
|
|
if(cb && cb->isFunction(&M_MissileLauncher::IClient::ReportMissileLauncherSettings)) {
|
|
methods.insert("ReportMissileLauncherSettings");
|
|
continue;
|
|
}
|
|
}
|
|
{
|
|
auto cb = dynamic_cast<ddkit::callback::Wrapper<M_MissileLauncher::IClient, M_MissileLauncher::MissileLauncherStatusType const&, bool>*>(obj);
|
|
if(cb && cb->isFunction(&M_MissileLauncher::IClient::ReportMissileLauncherStatus)) {
|
|
methods.insert("ReportMissileLauncherStatus");
|
|
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_MissileLauncher::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_Effector::IClient
|
|
if (!std::is_same<decltype(&IClient::ReportEffectorSettings),
|
|
decltype(&IClientDerived::ReportEffectorSettings)
|
|
>::value) methods.push_back("ReportEffectorSettings");
|
|
if (!std::is_same<decltype(&IClient::ReportEffectorStatus),
|
|
decltype(&IClientDerived::ReportEffectorStatus)
|
|
>::value) methods.push_back("ReportEffectorStatus");
|
|
if (!std::is_same<decltype(&IClient::ReportEffectorTubeStatus),
|
|
decltype(&IClientDerived::ReportEffectorTubeStatus)
|
|
>::value) methods.push_back("ReportEffectorTubeStatus");
|
|
// methods of M_Teleoperation::IClient
|
|
if (!std::is_same<decltype(&IClient::ReportTeleoperationCtrlSettings),
|
|
decltype(&IClientDerived::ReportTeleoperationCtrlSettings)
|
|
>::value) methods.push_back("ReportTeleoperationCtrlSettings");
|
|
if (!std::is_same<decltype(&IClient::ReportBatteryStatus),
|
|
decltype(&IClientDerived::ReportBatteryStatus)
|
|
>::value) methods.push_back("ReportBatteryStatus");
|
|
if (!std::is_same<decltype(&IClient::ReportRadioConnectionStatus),
|
|
decltype(&IClientDerived::ReportRadioConnectionStatus)
|
|
>::value) methods.push_back("ReportRadioConnectionStatus");
|
|
// methods of M_MissileLauncher::IClient
|
|
if (!std::is_same<decltype(&IClient::ReportMissileLauncherSettings),
|
|
decltype(&IClientDerived::ReportMissileLauncherSettings)
|
|
>::value) methods.push_back("ReportMissileLauncherSettings");
|
|
if (!std::is_same<decltype(&IClient::ReportMissileLauncherStatus),
|
|
decltype(&IClientDerived::ReportMissileLauncherStatus)
|
|
>::value) methods.push_back("ReportMissileLauncherStatus");
|
|
|
|
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_MissileLauncher::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_MissileLauncher::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_MissileLauncher::detectMethodsIClient(callbacks, false);
|
|
std::map<std::string, std::vector<ddkit::callback::Base*>> lambdaMap = M_MissileLauncher::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_MissileLauncher::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_MissileLauncher::detectMethodsIClient(callbacks, false);
|
|
std::map<std::string, std::vector<ddkit::callback::Base*>> lambdaMap = M_MissileLauncher::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_MissileLauncher::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_MissileLauncher::detectMethodsIClient(callbacks, false);
|
|
std::map<std::string, std::vector<ddkit::callback::Base*>> lambdaMap = M_MissileLauncher::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_MissileLauncher::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_MissileLauncher::detectMethodsIClient(callbacks, false);
|
|
std::map<std::string, std::vector<ddkit::callback::Base*>> lambdaMap = M_MissileLauncher::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_MissileLauncher::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_MissileLauncher::detectMethodsIClient(callbacks, false);
|
|
std::map<std::string, std::vector<ddkit::callback::Base*>> lambdaMap = M_MissileLauncher::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_MissileLauncher::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_MissileLauncher::detectMethodsIClient(callbacks, false);
|
|
std::map<std::string, std::vector<ddkit::callback::Base*>> lambdaMap = M_MissileLauncher::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_MissileLauncher::detectMethodsIClient(callbacks, isCheckMostDerivedClassType(*monitorSession.get()));
|
|
return createCustomReadOnlyMultiplex(monitorSession, callbacks, methods);
|
|
}
|
|
|
|
#endif
|
|
|
|
|
|
|
|
} // namespace M_MissileLauncher
|
|
|
|
|
|
#endif
|