123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166 |
- #ifndef BOOST_ASIO_DETAIL_SERVICE_REGISTRY_HPP
- #define BOOST_ASIO_DETAIL_SERVICE_REGISTRY_HPP
- #if defined(_MSC_VER) && (_MSC_VER >= 1200)
- # pragma once
- #endif
- #include <boost/asio/detail/config.hpp>
- #include <typeinfo>
- #include <boost/asio/detail/mutex.hpp>
- #include <boost/asio/detail/noncopyable.hpp>
- #include <boost/asio/detail/type_traits.hpp>
- #include <boost/asio/execution_context.hpp>
- #include <boost/asio/detail/push_options.hpp>
- namespace boost {
- namespace asio {
- class io_context;
- namespace detail {
- template <typename T>
- class typeid_wrapper {};
- class service_registry
- : private noncopyable
- {
- public:
-
- BOOST_ASIO_DECL service_registry(execution_context& owner);
-
- BOOST_ASIO_DECL ~service_registry();
-
- BOOST_ASIO_DECL void shutdown_services();
-
- BOOST_ASIO_DECL void destroy_services();
-
- BOOST_ASIO_DECL void notify_fork(execution_context::fork_event fork_ev);
-
-
-
- template <typename Service>
- Service& use_service();
-
-
-
-
-
- template <typename Service>
- Service& use_service(io_context& owner);
-
-
- template <typename Service>
- void add_service(Service* new_service);
-
- template <typename Service>
- bool has_service() const;
- private:
-
- template <typename Service>
- static void init_key(execution_context::service::key& key, ...);
- #if !defined(BOOST_ASIO_NO_TYPEID)
-
- template <typename Service>
- static void init_key(execution_context::service::key& key,
- typename enable_if<
- is_base_of<typename Service::key_type, Service>::value>::type*);
- #endif
-
- BOOST_ASIO_DECL static void init_key_from_id(
- execution_context::service::key& key,
- const execution_context::id& id);
- #if !defined(BOOST_ASIO_NO_TYPEID)
-
- template <typename Service>
- static void init_key_from_id(execution_context::service::key& key,
- const service_id<Service>& );
- #endif
-
- BOOST_ASIO_DECL static bool keys_match(
- const execution_context::service::key& key1,
- const execution_context::service::key& key2);
-
- typedef execution_context::service*(*factory_type)(void*);
-
- template <typename Service, typename Owner>
- static execution_context::service* create(void* owner);
-
- BOOST_ASIO_DECL static void destroy(execution_context::service* service);
-
- struct auto_service_ptr;
- friend struct auto_service_ptr;
- struct auto_service_ptr
- {
- execution_context::service* ptr_;
- ~auto_service_ptr() { destroy(ptr_); }
- };
-
-
-
- BOOST_ASIO_DECL execution_context::service* do_use_service(
- const execution_context::service::key& key,
- factory_type factory, void* owner);
-
-
- BOOST_ASIO_DECL void do_add_service(
- const execution_context::service::key& key,
- execution_context::service* new_service);
-
- BOOST_ASIO_DECL bool do_has_service(
- const execution_context::service::key& key) const;
-
- mutable boost::asio::detail::mutex mutex_;
-
- execution_context& owner_;
-
- execution_context::service* first_service_;
- };
- }
- }
- }
- #include <boost/asio/detail/pop_options.hpp>
- #include <boost/asio/detail/impl/service_registry.hpp>
- #if defined(BOOST_ASIO_HEADER_ONLY)
- # include <boost/asio/detail/impl/service_registry.ipp>
- #endif
- #endif
|