Remove dynamic exceptions
[anna.git] / include / anna / comm / internal / ConnectionRecover.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_internal_ConnectionRecover_hpp
10 #define anna_comm_internal_ConnectionRecover_hpp
11
12 #include <anna/core/RuntimeException.hpp>
13
14 #include <anna/core/util/Millisecond.hpp>
15
16 namespace anna {
17
18 namespace xml {
19 class Node;
20 }
21
22 namespace comm {
23
24 class Server;
25 class Communicator;
26
27 class ConnectionRecover {
28 public:
29   bool isRunning() const { return a_isRunning; }
30
31   void annotateFault(Server* server) ;
32 //   bool contains (Server* server) const ;
33 //   void erase (Server* server) ;
34   xml::Node* asXML(xml::Node* parent) const noexcept(false);
35
36 private:
37   typedef std::vector <Server*> break_container;
38   typedef break_container::iterator break_iterator;
39
40   comm::Communicator& a_communicator;
41   break_container a_breaks;
42   break_iterator a_recovering;
43   bool a_isRunning;
44   Millisecond a_nextTime;
45
46   ConnectionRecover(Communicator* communicator) : a_communicator(*communicator), a_isRunning(false) {;}
47   void tryRecover() ;
48
49   friend class Communicator;
50 };
51
52 }
53 }
54
55 #endif
56