1 /*
2  * Copyright (C) 2009 Codership Oy <info@codership.com>
3  */
4 
5 #ifndef GCOMM_PROTOSTACK_HPP
6 #define GCOMM_PROTOSTACK_HPP
7 
8 #include "gcomm/protolay.hpp"
9 
10 #include "gu_lock.hpp"
11 
12 #include <vector>
13 #include <deque>
14 
15 namespace gcomm
16 {
17     class Socket;
18     class Acceptor;
19     class Protostack;
20     class Protonet;
21     class BoostProtonet;
22 }
23 
24 
25 class gcomm::Protostack
26 {
27 public:
Protostack()28     Protostack() : protos_(), mutex_() { }
29     void push_proto(Protolay* p);
30     void pop_proto(Protolay* p);
31     gu::datetime::Date handle_timers();
32     void dispatch(const void* id, const Datagram& dg,
33                   const ProtoUpMeta& um);
34     bool set_param(const std::string&, const std::string&,
35                    Protolay::sync_param_cb_t& sync_param_cb);
enter()36     void enter() { mutex_.lock(); }
leave()37     void leave() { mutex_.unlock(); }
38 private:
39     friend class Protonet;
40     std::deque<Protolay*> protos_;
41     gu::Mutex mutex_;
42 };
43 
44 
45 #endif // GCOMM_PROTOSTACK_HPP
46