mux.hpp
Go to the documentation of this file.
00001 
00006 /*****************************************************************************
00007 ** Ifdefs
00008 *****************************************************************************/
00009 
00010 #ifndef mm_mux_demux_MUX_HPP_
00011 #define mm_mux_demux_MUX_HPP_
00012 
00013 /*****************************************************************************
00014 ** Includes
00015 *****************************************************************************/
00016 
00017 #include <map>
00018 #include <memory>
00019 #include <string>
00020 #include <mm_messages.hpp>
00021 
00022 /*****************************************************************************
00023 ** Namespaces
00024 *****************************************************************************/
00025 
00026 namespace mm_mux_demux {
00027 namespace impl {
00028 
00029 /*****************************************************************************
00030  ** Interfaces
00031  *****************************************************************************/
00032 
00033 class MessageMux {
00034 public:
00035   MessageMux(const std::string& name,
00036              const std::string& url,
00037              const mm_messages::Verbosity::Level& verbosity=mm_messages::Verbosity::QUIET,
00038              const bool bind = true
00039              );
00040   ~MessageMux();
00041   int send(const unsigned int& id, const mm_messages::ByteArray& msg_buffer);
00042 
00043 private:
00044   std::string name, url;
00045   int socket, endpoint_id;
00046   mm_messages::Verbosity::Level verbosity;
00047 };
00048 
00049 } // namespace impl
00050 } // mm_mux_demux
00051 
00052 /*****************************************************************************
00053 ** Namespaces
00054 *****************************************************************************/
00055 
00056 namespace mm_mux_demux {
00057 
00058 /*****************************************************************************
00059 ** Interfaces
00060 *****************************************************************************/
00061 
00062 class MessageMux {
00063 public:
00064   typedef std::map<std::string, std::shared_ptr<impl::MessageMux>> MuxMap;
00065   typedef std::pair<std::string, std::shared_ptr<impl::MessageMux>> MuxMapPair;
00066   typedef std::map<std::string, std::shared_ptr<impl::MessageMux>>::iterator MuxMapIterator;
00067   typedef std::map<std::string, std::shared_ptr<impl::MessageMux>>::const_iterator MuxMapConstIterator;
00068 
00069   enum Errors {
00070     NotAvailable = -1  // when you try to connect to <name>, but <name> has not yet been started
00071   };
00072   static void start(const std::string& name,
00073                     const std::string& url,
00074                     const mm_messages::Verbosity::Level& verbosity=mm_messages::Verbosity::QUIET,
00075                     const bool bind = true
00076                    );
00077   static void shutdown(const std::string& name);  // shutdown only this mux
00078   static void shutdown(); // shutdown all muxes
00079   static MuxMap& multiplexers();
00080   static int send(const std::string& name, const unsigned int& id, const mm_messages::ByteArray& msg_buffer);
00081 };
00082 
00083 } // namespace mm_mux_demux
00084 
00085 #endif /* mm_mux_demux_MUX_HPP_ */


mm_mux_demux
Author(s): Daniel Stonier
autogenerated on Thu Jun 6 2019 21:13:22