Line data Source code
1 :
2 : /* Copyright (c) 2017, Human Brain Project
3 : * Stefan.Eilemann@epfl.ch
4 : */
5 :
6 : #pragma once
7 :
8 : #include <zeroeq/receiver.h> // base class
9 :
10 : namespace zeroeq
11 : {
12 : /**
13 : * Monitors a Sender and notifies on events on its socket.
14 : *
15 : * @warning: Installing multiple monitors on a single Sender has undefined
16 : * behaviour.
17 : */
18 : class Monitor : public Receiver
19 : {
20 : public:
21 : /** Monitor the given sender. */
22 : ZEROEQ_API explicit Monitor(Sender& sender);
23 :
24 : /** Monitor the given sender and notify with the given shared group. */
25 : ZEROEQ_API Monitor(Sender& sender, Receiver& shared);
26 :
27 : /** Destroy this monitor*/
28 : ZEROEQ_API ~Monitor();
29 :
30 : /** Notify of a new connection to the sender. */
31 0 : virtual void notifyNewConnection() {}
32 :
33 : class Impl;
34 :
35 : private:
36 : std::unique_ptr<Impl> _impl;
37 :
38 : Monitor(const Monitor&) = delete;
39 : Monitor& operator=(const Monitor&) = delete;
40 :
41 : // Receiver API
42 : void addSockets(std::vector<zeroeq::detail::Socket>& entries) final;
43 : bool process(zeroeq::detail::Socket& socket) final;
44 : };
45 : }
|