Remove dynamic exceptions
[anna.git] / include / anna / test / Communicator.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_test_Communicator_hpp
10 #define anna_test_Communicator_hpp
11
12 #include <anna/comm/Communicator.hpp>
13
14 namespace test {
15
16 using namespace anna;
17
18 class Communicator : public comm::Communicator {
19 public:
20    Communicator () : comm::Communicator (),
21       a_maxMessage (-1), 
22       a_messageCounter (0), 
23       a_successCounter (0),
24       a_initTime (0),
25       a_avgDelay ("AvgDelay"),
26       a_delay (0)
27    {;}
28    
29    void setDelay (const Millisecond delay) { a_delay = delay; }
30    void setMaxMessage (const int maxMessage) { a_maxMessage = maxMessage; }
31    
32    int getMaxMessage () const { return a_maxMessage; }
33    int getMessage () const { return a_messageCounter; }
34
35    bool canContinue (const comm::ClientSocket&) noexcept(false);
36    void delay () noexcept(false);   
37    
38    void terminate () ;
39 private:
40    Millisecond a_delay;
41    Millisecond a_initTime;
42    int a_maxMessage;
43    int a_messageCounter;
44    int a_successCounter;
45    Average <Microsecond> a_avgDelay;
46    
47    void eventOverQuota (const comm::ClientSocket&) ;      
48
49 };
50
51 }
52
53 #endif