/******************************************************************************** * Copyright (C) 2019 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * * * * This software is distributed under the terms of the * * GNU Lesser General Public Licence (LGPL) version 3, * * copied verbatim in the file "LICENSE" * ********************************************************************************/ #ifndef FAIR_MQ_SDK_DDSSESSION_H #define FAIR_MQ_SDK_DDSSESSION_H #include #include #include #include #include #include #include #include #include #include #include #include namespace fair::mq::sdk { /** * @enum DDSRMSPlugin DDSSession.h * @brief Supported DDS resource management system plugins */ enum class DDSRMSPlugin { localhost, ssh }; auto operator<<(std::ostream& os, DDSRMSPlugin plugin) -> std::ostream&; auto operator>>(std::istream& is, DDSRMSPlugin& plugin) -> std::istream&; class DDSTopology; class DDSAgent; class DDSChannel { public: using Id = std::uint64_t; }; /** * @class DDSSession DDSSession.h * @brief Represents a DDS session */ class DDSSession { public: using Id = std::string; using Quantity = std::uint32_t; using Path = boost::filesystem::path; explicit DDSSession(DDSEnvironment env = DDSEnvironment()); explicit DDSSession(Id existing, DDSEnvironment env = DDSEnvironment()); /// @brief Construct with already existing native DDS API objects /// @param nativeSession Existing and initialized CSession (either via create() or attach()) /// @param env Optional DDSEnv explicit DDSSession(std::shared_ptr nativeSession, DDSEnv env = {}); auto GetEnv() const -> DDSEnvironment; auto GetId() const -> Id; auto GetRMSPlugin() const -> DDSRMSPlugin; auto SetRMSPlugin(DDSRMSPlugin) -> void; auto GetRMSConfig() const -> Path; auto SetRMSConfig(Path) const -> void; auto IsStoppedOnDestruction() const -> bool; auto StopOnDestruction(bool stop = true) -> void; auto IsRunning() const -> bool; auto SubmitAgents(Quantity agents) -> void; struct AgentCount { Quantity idle = 0; Quantity active = 0; Quantity executing = 0; }; auto RequestAgentCount() -> AgentCount; auto RequestAgentInfo() -> std::vector; auto RequestTaskInfo() -> std::vector; struct CommanderInfo { int pid = -1; std::string activeTopologyName; }; auto RequestCommanderInfo() -> CommanderInfo; auto WaitForIdleAgents(Quantity) -> void; auto WaitForOnlyIdleAgents() -> void; auto WaitForExecutingAgents(Quantity) -> void; auto ActivateTopology(const Path& topoFile) -> void; auto ActivateTopology(DDSTopology) -> void; auto Stop() -> void; void StartDDSService(); void SubscribeToCommands(std::function); void UnsubscribeFromCommands(); void SendCommand(const std::string&, const std::string& = ""); void SendCommand(const std::string&, DDSChannel::Id); auto GetTaskId(DDSChannel::Id) const -> DDSTask::Id; friend auto operator<<(std::ostream& os, const DDSSession& session) -> std::ostream&; private: struct Impl; std::shared_ptr fImpl; }; auto getMostRecentRunningDDSSession(DDSEnv env = {}) -> DDSSession; } // namespace fair::mq::sdk #endif /* FAIR_MQ_SDK_DDSSESSION_H */