From: caprice Date: Tue, 29 Apr 2014 07:45:57 +0000 (+0900) Subject: class post_officeを追加 X-Git-Url: http://git.sourceforge.jp/view?a=commitdiff_plain;ds=sidebyside;h=e718c0d2a8368ab9cee1e7f7767f06c20f4c7294;p=gikomona%2Flibcore.git class post_officeを追加 --- diff --git a/include/communication/post-office.hpp b/include/communication/post-office.hpp new file mode 100644 index 0000000..a18b95d --- /dev/null +++ b/include/communication/post-office.hpp @@ -0,0 +1,48 @@ + +#ifndef GIKOMONA_CORE_POST_OFFICE_HPP +#define GIKOMONA_CORE_POST_OFFICE_HPP + +#include +#include +#include +#include + +#include "GikoMona.hpp" +#include "string.hpp" +#include "communication.hpp" +#include "message.hpp" +#include "application-type.hpp" + +namespace monazilla { namespace GikoMona { namespace core { namespace communication { + +class post_office { +public: + explicit post_office(const communicate_id self_id); + ~post_office(); + + bool connect(const communicate_id connect_to); + bool disconnect(const communicate_id disconnect_from); + bool disconnect_all(); + + template + bool send(const communicate_id to, MessageType&& msg); + + mona_string receive(const communicate_id originator_id); + +private: + bool send_string(const communicate_id to, mona_string&& src); + std::string create_mailbox_name(const communicate_id mb_user_id); + + const communicate_id self; + shared_memory gm_shmem; // GikoMona全体で共有されているメモリ + mailbox *my_mailbox; + std::unordered_map mailbox_map; + boost::interprocess::named_mutex my_mailbox_mutex; + + const char *shared_memory_name = "monazilla.GikoMona.shared-memory"; + const char *ref_counter_name = "monazilla.GikoMona.reference-counter"; +}; + +} } } } + +#endif // GIKOMONA_CORE_POST_OFFICE_HPP