Remove dynamic exceptions
[anna.git] / include / anna / comm / ReceiverFactoryImpl.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_ReceiverFactoryImpl_hpp
10 #define anna_comm_ReceiverFactoryImpl_hpp
11
12 #include <anna/core/util/Recycler.hpp>
13
14 #include <anna/comm/ReceiverFactory.hpp>
15
16 namespace anna {
17
18 namespace comm {
19
20 class Factory;
21
22 /**
23    Implementacion por defecto de una factoria de receptores.
24
25    \param T Clase del receptor instanciado por esta factoria. Debe implementar el constructor
26    vacio y un metodo que devuelve el nombre de la clase con la firma:
27
28    \code
29       static const char* className () ;
30    \encode
31 */
32 template <typename T> class ReceiverFactoryImpl : public ReceiverFactory {
33 public:
34   /**
35      Constructor.
36   */
37   ReceiverFactoryImpl() : ReceiverFactory(T::className()) {;}
38
39 private:
40   Recycler<T> a_receivers;
41
42   Receiver* do_create() { return a_receivers.create(); }
43   void do_release(Receiver* receiver) { a_receivers.release(static_cast <T*>(receiver)); }
44 };
45
46 }
47 }
48
49 #endif
50