Remove dynamic exceptions
[anna.git] / include / anna / comm / handler / Manager.hpp
1 // ANNA - Anna is Not Nothingness Anymore                                                         //
2 //                                                                                                //
3 // (c) Copyright 2005-2015 Eduardo Ramos Testillano & Francisco Ruiz Rayo                         //
4 //                                                                                                //
5 // See project site at http://redmine.teslayout.com/projects/anna-suite                           //
6 // See accompanying file LICENSE or copy at http://www.teslayout.com/projects/public/anna.LICENSE //
7
8
9 #ifndef anna_comm_handler_Manager_hpp
10 #define anna_comm_handler_Manager_hpp
11
12 #include <anna/core/Singleton.hpp>
13 #include <anna/core/util/Recycler.hpp>
14
15 #include <anna/comm/handler/Allocator.hpp>
16 #include <anna/comm/handler/BinderSocket.hpp>
17 #include <anna/comm/handler/ServerSocket.hpp>
18 #include <anna/comm/handler/LocalConnection.hpp>
19 #include <anna/comm/handler/RemoteConnection.hpp>
20 #include <anna/comm/handler/DatagramSocket.hpp>
21 #include <anna/comm/handler/ClientSocket.hpp>
22
23 namespace anna {
24
25 namespace comm {
26
27 class Handler;
28 class Communicator;
29
30 namespace handler {
31
32 class Manager : public Singleton <Manager> {
33 public:
34   typedef handler::Allocator <handler::BinderSocket> BinderSocketAllocator;
35   typedef handler::Allocator <handler::ServerSocket> ServerSocketAllocator;
36   typedef handler::Allocator <handler::LocalConnection> LocalConnectionAllocator;
37   typedef handler::Allocator <handler::RemoteConnection> RemoteConnectionAllocator;
38   typedef handler::Allocator <handler::DatagramSocket> DatagramSocketAllocator;
39   typedef handler::Allocator <handler::ClientSocket> ClientSocketAllocator;
40
41   void initialize(Communicator*) ;
42
43   comm::Handler* createHandler(comm::BinderSocket*) noexcept(false);
44   comm::Handler* createHandler(comm::ServerSocket*) noexcept(false);
45   comm::Handler* createHandler(comm::LocalConnection*) noexcept(false);
46   comm::Handler* createHandler(comm::RemoteConnection*) noexcept(false);
47   comm::Handler* createHandler(comm::DatagramSocket*) noexcept(false);
48   comm::Handler* createHandler(comm::ClientSocket*) noexcept(false);
49
50   void releaseHandler(Handler*) ;
51
52 private:
53   Recycler <handler::BinderSocket, BinderSocketAllocator> a_binderSockets;
54   Recycler <handler::ServerSocket, ServerSocketAllocator> a_serverSockets;
55   Recycler <handler::LocalConnection, LocalConnectionAllocator> a_localConnections;
56   Recycler <handler::RemoteConnection, RemoteConnectionAllocator> a_remoteConnections;
57   Recycler <handler::DatagramSocket, DatagramSocketAllocator> a_datagramSockets;
58   Recycler <handler::ClientSocket, ClientSocketAllocator> a_clientSockets;
59
60   Manager() {;}
61   Manager(const Manager&);
62
63   friend class Singleton <Manager>;
64 };
65
66 }
67 }
68 }
69
70 #endif
71