Remove dynamic exceptions
[anna.git] / include / anna / test / Control.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_Control_hpp
10 #define anna_test_Control_hpp
11
12 #include <anna/core/mt/Mutex.hpp>
13 #include <anna/core/util/Average.hpp>
14 #include <anna/core/util/Millisecond.hpp>
15 #include <anna/core/util/Microsecond.hpp>
16
17 namespace anna {
18    namespace xml {
19       class Node;
20    }
21    namespace comm {
22       class Communicator;
23       namespace socket {
24          class Client;
25       }
26    }
27 }
28
29 namespace test {
30
31 using namespace anna;
32
33 class Control : public Mutex {
34 public:
35    Control (comm::Communicator* engine);
36
37    void setDelay (const Millisecond delay) { a_delay = delay; }
38    void setMaxMessage (const int maxMessage) { a_maxMessage = maxMessage; }
39
40    int getMaxMessage () const { return a_maxMessage; }
41
42    bool canContinue (const comm::socket::Client& clientSocket) noexcept(false);
43    void delay () noexcept(false);
44    Millisecond latency (const Millisecond& init) noexcept(false);
45
46    void report () ;
47    void stop () noexcept(false);
48
49    xml::Node* asXML (xml::Node* parent) ;
50
51 private:
52    comm::Communicator& a_engine;
53    Millisecond a_delay;
54    Millisecond a_initTime;
55    int a_maxMessage;
56    Average <Microsecond> a_avgDelay;
57    Average <Millisecond> a_avgLatency;
58 };
59
60 }
61
62 #endif