bug in RC
[anna.git] / include / anna / comm / TransportFactoryImpl.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_TransportFactoryImpl_hpp
10 #define anna_comm_TransportFactoryImpl_hpp
11
12 #include <anna/core/util/Recycler.hpp>
13
14 #include <anna/comm/TransportFactory.hpp>
15
16 namespace anna {
17
18 namespace comm {
19
20 class Transport;
21
22 /**
23   Transport factory implementation
24 */
25 template <typename T> class TransportFactoryImpl  : public TransportFactory {
26 public:
27   /**
28      Constructor.
29   */
30   TransportFactoryImpl() : TransportFactory(T::className()) {;}
31
32 private:
33   Recycler <T> a_transports;
34
35   Transport* create() throw() {
36     Transport* result = static_cast <Transport*>(a_transports.create());
37     int overQuotaSize;
38
39     if((overQuotaSize = TransportFactory::getOverQuotaSize()) != 0)
40       result->setOverQuotaSize(overQuotaSize);
41
42     return result;
43   }
44   void release(Transport* transport) throw() { a_transports.release(static_cast <T*>(transport)); }
45 };
46
47 }
48 }
49
50 #endif
51