1 // ANNA - Anna is Not 'N' Anymore
3 // (c) Copyright 2005-2014 Eduardo Ramos Testillano & Francisco Ruiz Rayo
5 // https://bitbucket.org/testillano/anna
7 // Redistribution and use in source and binary forms, with or without
8 // modification, are permitted provided that the following conditions
11 // * Redistributions of source code must retain the above copyright
12 // notice, this list of conditions and the following disclaimer.
13 // * Redistributions in binary form must reproduce the above
14 // copyright notice, this list of conditions and the following disclaimer
15 // in the documentation and/or other materials provided with the
17 // * Neither the name of Google Inc. nor the names of its
18 // contributors may be used to endorse or promote products derived from
19 // this software without specific prior written permission.
21 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
22 // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
23 // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
24 // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
25 // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
26 // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
27 // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
28 // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
29 // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
30 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
31 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
33 // Authors: eduardo.ramos.testillano@gmail.com
34 // cisco.tierra@gmail.com
37 #ifndef anna_comm_ServerAllocator_hpp
38 #define anna_comm_ServerAllocator_hpp
47 class TransportFactory;
51 Instanciador de anna::comm::Server se usa para poder instanciar distintos tipos
52 de anna::comm::Server desde la clase anna::comm::Host.
54 \see Host::createServer
57 class ServerAllocator {
60 Constructor. Recoge los parametros con los que crear el servidor.
61 \param name Nombre logico del servidor.
62 \param host Instancia de la maquina sobre la que esta atendiento peticiones.
63 \param remotePort Puerto sobre el que atiende peticiones.
64 \param autoRecovery Indica si en caso de caida se debe intentar la recuperacion
65 automatica de la conexion.
66 \param transportFactory Factoria de protocolos de transporte usada por los ClientSocket asociados a este
68 \param ignoreIncomingMessages Indicador de ignorar mensajes entrantes.
70 ServerAllocator(const std::string& name, const Host& host, const int remotePort, const bool autoRecovery, TransportFactory* transportFactory = NULL, const bool ignoreIncomingMessages = false) :
73 a_remotePort(remotePort),
74 a_autoRecovery(autoRecovery),
75 a_transportFactory(transportFactory),
76 a_ignoreIncomingMessages(ignoreIncomingMessages)
81 \param other Instanciador del que copiar.
83 ServerAllocator(const ServerAllocator& other) :
86 a_remotePort(other.a_remotePort),
87 a_autoRecovery(other.a_autoRecovery),
88 a_transportFactory(other.a_transportFactory),
89 a_ignoreIncomingMessages(other.a_ignoreIncomingMessages)
95 virtual ~ServerAllocator() {;}
98 Devuelve el nombre logico del servidor.
99 \return el nombre logico del servidor.
101 const std::string& getName() const throw() { return a_name; }
104 Devuelve el puerto sobre el que atiende peticiones.
105 \return el puerto sobre el que atiende peticiones.
107 int getRemotePort() const throw() { return a_remotePort; }
110 Indica si se ha indicado que en caso de caida se debe intentar la recuperacion
111 automatica de la conexion.
112 \return \em true si se ha indicado que en caso de caida se debe intentar la recuperacion
113 automatica de la conexion o \em false en caso contrario.
115 bool autoRecovery() const throw() { return a_autoRecovery; }
118 * Devuelve \em true si el indicador que ignora los mensajes entrantes está activo, o \em false en otro caso.
119 * \return \em true si el indicador que ignora los mensajes entrantes está activo, o \em false en otro caso.
121 bool getIgnoreIncomingMessages() const throw() { return a_ignoreIncomingMessages; }
124 Crea una instancia particular de anna::comm::Server usando los parametros establecidos
126 \return una instancia particular de anna::comm::Server.
128 virtual Server* apply() const throw();
131 const std::string a_name;
133 const int a_remotePort;
135 TransportFactory* a_transportFactory;
136 const bool a_ignoreIncomingMessages;