1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798 |
- #pragma once
- #include "rotor/forward.hpp"
- #include "rotor/address.hpp"
- #include "rotor/subscription_point.h"
- #include "rotor/message.h"
- #include <boost/unordered_map.hpp>
- #include <vector>
- #if defined(_MSC_VER)
- #pragma warning(push)
- #pragma warning(disable : 4251)
- #endif
- namespace rotor {
- struct ROTOR_API subscription_t {
-
- using message_type_t = const void *;
-
- using handlers_t = std::vector<handler_base_t *>;
-
- struct joint_handlers_t {
-
- handlers_t internal;
-
- handlers_t external;
- };
- subscription_t() noexcept;
-
- subscription_info_ptr_t materialize(const subscription_point_t &point) noexcept;
-
- void update(subscription_point_t &point, handler_ptr_t &new_handler) noexcept;
-
- void forget(const subscription_info_ptr_t &info) noexcept;
-
- const joint_handlers_t *get_recipients(const message_base_t &message) const noexcept;
-
- template <typename T> auto &access() noexcept;
- private:
- struct subscription_key_t {
- address_t *address;
- message_type_t message_type;
- inline bool operator==(const subscription_key_t &other) const noexcept {
- return address == other.address && message_type == other.message_type;
- }
- };
- struct subscription_key_hash_t {
- inline std::size_t operator()(const subscription_key_t &k) const noexcept {
- return std::size_t(k.address) + 0x9e3779b9 + (size_t(k.message_type) << 6) + (size_t(k.message_type) >> 2);
- }
- };
- using addressed_handlers_t = boost::unordered_map<subscription_key_t, joint_handlers_t, subscription_key_hash_t>;
- using info_container_t = boost::unordered_map<address_ptr_t, std::vector<subscription_info_ptr_t>>;
- address_t *main_address;
- info_container_t internal_infos;
- addressed_handlers_t mine_handlers;
- };
- }
- #if defined(_MSC_VER)
- #pragma warning(pop)
- #endif
|