1 // ANNA - Anna is Not Nothingness Anymore //
3 // (c) Copyright 2005-2015 Eduardo Ramos Testillano & Francisco Ruiz Rayo //
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 //
9 #ifndef anna_diameter_comm_Timer_hpp
10 #define anna_diameter_comm_Timer_hpp
12 #include <anna/core/RuntimeException.hpp>
13 #include <anna/core/Allocator.hpp>
14 #include <anna/timex/Transaction.hpp>
30 class Timer : public anna::timex::Transaction {
33 struct Type { enum _v { ResponseExpiration, SessionUnbind, SessionRecover, LocalServerAttach }; };
35 // getters for responses
36 Response* getResponse() { return reinterpret_cast <Response*>(getContext()); }
37 const Response* getResponse() const { return reinterpret_cast <const Response*>(getContext()); }
39 // getters for session (client-session at the moment)
40 Session* getSession() { return reinterpret_cast <Session*>(getContext()); }
41 const Session* getSession() const { return reinterpret_cast <const Session*>(getContext()); }
43 // getters for local server
44 LocalServer* getLocalServer() { return reinterpret_cast <LocalServer*>(getContext()); }
45 const LocalServer* getLocalServer() const { return reinterpret_cast <const LocalServer*>(getContext()); }
47 std::string asString() const ;
55 void expire(anna::timex::Engine*) noexcept(false);
57 Type::_v getType() const { return a_type; }
58 void setType(const Type::_v type) { a_type = type; }
59 static const char* asText(const Type::_v) ;
62 friend class TimerManager;
63 friend class anna::Allocator<Timer>;