YAMI4 C++
name_resolver.h
1 // Copyright Maciej Sobczak 2008-2019.
2 // This file is part of YAMI4.
3 //
4 // YAMI4 is free software: you can redistribute it and/or modify
5 // it under the terms of the GNU General Public License as published by
6 // the Free Software Foundation, either version 3 of the License, or
7 // (at your option) any later version.
8 //
9 // YAMI4 is distributed in the hope that it will be useful,
10 // but WITHOUT ANY WARRANTY; without even the implied warranty of
11 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 // GNU General Public License for more details.
13 //
14 // You should have received a copy of the GNU General Public License
15 // along with YAMI4. If not, see <http://www.gnu.org/licenses/>.
16 
17 #ifndef YAMICPP_NAME_RESOLVER_H_INCLUDED
18 #define YAMICPP_NAME_RESOLVER_H_INCLUDED
19 
20 #include "incoming_message_dispatcher_base.h"
21 #include <map>
22 #include <memory>
23 #include <string>
24 
25 // selected per platform
26 #include <mutex.h>
27 
28 namespace yami
29 {
30 
31 namespace details
32 {
33 
34 class name_resolver
35 {
36 public:
37  name_resolver();
38  ~name_resolver();
39 
40  void register_object(const std::string & name,
41  std::unique_ptr<incoming_message_dispatcher_base> & object);
42 
43  void unregister_object(const std::string & name);
44 
45  incoming_message_dispatcher_base * resolve(
46  const std::string & name) const;
47 
48 private:
49  name_resolver(const name_resolver &);
50  void operator=(const name_resolver &);
51 
52  typedef std::map<std::string, incoming_message_dispatcher_base *>
53  map_type;
54 
55  map_type map_;
56  incoming_message_dispatcher_base * any_callback_;
57  mutable mutex mtx_;
58 };
59 
60 } // namespace details
61 
62 } // namespace yami
63 
64 #endif // YAMICPP_NAME_RESOLVER_H_INCLUDED
Namespace devoted to everything related to YAMI4.
Definition: activity_statistics_monitor.cpp:27