1 // ANNA - Anna is Not Nothingness Anymore //
3 // (c) Copyright 2005-2015 Eduardo Ramos Testillano & Francisco Ruiz Rayo //
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 //
9 #include <anna/core/mt/Guard.hpp>
11 #include <anna/comm/handler/Manager.hpp>
14 using namespace anna::comm;
16 template <> comm::Communicator* handler::Manager::BinderSocketAllocator::st_communicator = NULL;
17 template <> comm::Communicator* handler::Manager::ServerSocketAllocator::st_communicator = NULL;
18 template <> comm::Communicator* handler::Manager::LocalConnectionAllocator::st_communicator = NULL;
19 template <> comm::Communicator* handler::Manager::RemoteConnectionAllocator::st_communicator = NULL;
20 template <> comm::Communicator* handler::Manager::DatagramSocketAllocator::st_communicator = NULL;
21 template <> comm::Communicator* handler::Manager::ClientSocketAllocator::st_communicator = NULL;
23 void handler::Manager::initialize(Communicator* communicator)
25 BinderSocketAllocator::st_communicator = communicator;
26 ServerSocketAllocator::st_communicator = communicator;
27 LocalConnectionAllocator::st_communicator = communicator;
28 RemoteConnectionAllocator::st_communicator = communicator;
29 DatagramSocketAllocator::st_communicator = communicator;
30 ClientSocketAllocator::st_communicator = communicator;
33 Handler* handler::Manager::createHandler(comm::BinderSocket* binderSocket)
35 handler::BinderSocket* result = a_binderSockets.create();
36 result->setup(binderSocket);
40 Handler* handler::Manager::createHandler(comm::ServerSocket* serverSocket)
42 handler::ServerSocket* result = a_serverSockets.create();
43 result->setup(serverSocket);
47 Handler* handler::Manager::createHandler(comm::LocalConnection* localConnection)
49 handler::LocalConnection* result = a_localConnections.create();
50 result->setup(localConnection);
54 Handler* handler::Manager::createHandler(comm::RemoteConnection* remoteConnection)
56 handler::RemoteConnection* result = a_remoteConnections.create();
57 result->setup(remoteConnection);
61 Handler* handler::Manager::createHandler(comm::DatagramSocket* datagramSocket)
63 handler::DatagramSocket* result = a_datagramSockets.create();
64 result->setup(datagramSocket);
68 Handler* handler::Manager::createHandler(comm::ClientSocket* clientSocket)
70 handler::ClientSocket* result = a_clientSockets.create();
71 result->setup(clientSocket);
75 void handler::Manager::releaseHandler(Handler* handler)
80 switch(handler->getType()) {
81 case Handler::Type::BinderSocket:
82 a_binderSockets.release(static_cast <BinderSocket*>(handler));
84 case Handler::Type::ServerSocket:
85 a_serverSockets.release(static_cast <ServerSocket*>(handler));
87 case Handler::Type::LocalConnection:
88 a_localConnections.release(static_cast <LocalConnection*>(handler));
90 case Handler::Type::RemoteConnection:
91 a_remoteConnections.release(static_cast <RemoteConnection*>(handler));
93 case Handler::Type::DatagramSocket:
94 a_datagramSockets.release(static_cast <DatagramSocket*>(handler));
96 case Handler::Type::ClientSocket:
97 a_clientSockets.release(static_cast <ClientSocket*>(handler));