E-MailRelay

- Main Page
- Namespaces
- Classes
- Files

- File List
- File Members

gmonitor.h
Go to the documentation of this file.
1 //
2 // Copyright (C) 2001-2018 Graeme Walker <graeme_walker@users.sourceforge.net>
3 //
4 // This program is free software: you can redistribute it and/or modify
5 // it under the terms of the GNU General Public License as published by
6 // the Free Software Foundation, either version 3 of the License, or
7 // (at your option) any later version.
8 //
9 // This program is distributed in the hope that it will be useful,
10 // but WITHOUT ANY WARRANTY; without even the implied warranty of
11 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 // GNU General Public License for more details.
13 //
14 // You should have received a copy of the GNU General Public License
15 // along with this program. If not, see <http://www.gnu.org/licenses/>.
16 // ===
17 ///
18 /// \file gmonitor.h
19 ///
20
21 #ifndef G_NET_MONITOR__H
22 #define G_NET_MONITOR__H
23
24 #include "gdef.h"
25 #include "gslot.h"
26 #include "gconnection.h"
27 #include <iostream>
28 #include <utility>
29
30 namespace GNet
31 {
32 class Monitor ;
33 class MonitorImp ;
34 }
35
36 /// \class GNet::Monitor
37 /// A singleton for monitoring GNet::SimpleClient and GNet::ServerPeer
38 /// connections and for storing their TLS certificates.
39 /// \see GNet::SimpleClient, GNet::ServerPeer
40 ///
41 class GNet::Monitor
42 {
43 public:
44 Monitor() ;
45 ///< Default constructor.
46
47 virtual ~Monitor() ;
48 ///< Destructor.
49
50 static Monitor * instance() ;
51 ///< Returns the singleton pointer. Returns null if none.
52
53 void addClient( const Connection & simple_client ) ;
54 ///< Adds a client connection.
55
56 void removeClient( const Connection & simple_client ) ;
57 ///< Removes a client connection.
58
59 void addServerPeer( const Connection & server_peer ) ;
60 ///< Adds a server connection.
61
62 void removeServerPeer( const Connection & server_peer ) ;
63 ///< Removes a server connection.
64
65 void report( std::ostream & stream ,
66 const std::string & line_prefix = std::string() ,
67 const std::string & eol = std::string("\n") ) const ;
68 ///< Reports itself onto a stream.
69
70 void report( G::StringArray & out ) const ;
71 ///< Reports itself into a three-column table.
72
73 std::pair<std::string,bool> findCertificate( const std::string & certificate ) ;
74 ///< Returns a short id for the given certificate and a boolean
75 ///< flag to indicate if it is a new certificate id that has
76 ///< not been returned before.
77
78 G::Slot::Signal2<std::string,std::string> & signal() ;
79 ///< Provides a callback signal which can be connect()ed
80 ///< to a slot.
81 ///<
82 ///< The signal emits events with two string parameters:
83 ///< the first is "in" or "out", and the second is
84 ///< "start" or "stop".
85
86 private:
87 Monitor( const Monitor & ) ;
88 void operator=( const Monitor & ) ;
89
90 private:
91 static Monitor * & pthis() ;
92 MonitorImp * m_imp ;
93 G::Slot::Signal2<std::string,std::string> m_signal ;
94 } ;
95
96 #endif
GNet::Monitor::removeServerPeer
void removeServerPeer(const Connection &server_peer)
Removes a server connection.
Definition: gmonitor.cpp:142
GNet
Network classes.
Definition: gaddress.h:29
G::Slot::Signal2< std::string, std::string >
GNet::Monitor::report
void report(std::ostream &stream, const std::string &line_prefix=std::string(), const std::string &eol=std::string("\n")) const
Reports itself onto a stream.
Definition: gmonitor.cpp:153
G::StringArray
std::vector< std::string > StringArray
A std::vector of std::strings.
Definition: gstrings.h:33
GNet::Monitor::addClient
void addClient(const Connection &simple_client)
Adds a client connection.
Definition: gmonitor.cpp:123
gslot.h
GNet::Monitor::signal
G::Slot::Signal2< std::string, std::string > & signal()
Provides a callback signal which can be connect()ed to a slot.
Definition: gmonitor.cpp:118
GNet::MonitorImp
A pimple-pattern implementation class for GNet::Monitor.
Definition: gmonitor.cpp:35
GNet::Monitor
A singleton for monitoring GNet::SimpleClient and GNet::ServerPeer connections and for storing their ...
Definition: gmonitor.h:41
GNet::Monitor::instance
static Monitor * instance()
Returns the singleton pointer. Returns null if none.
Definition: gmonitor.cpp:113
GNet::Monitor::~Monitor
virtual ~Monitor()
Destructor.
Definition: gmonitor.cpp:107
GNet::Monitor::removeClient
void removeClient(const Connection &simple_client)
Removes a client connection.
Definition: gmonitor.cpp:129
GNet::Monitor::addServerPeer
void addServerPeer(const Connection &server_peer)
Adds a server connection.
Definition: gmonitor.cpp:135
GNet::Connection
An abstract interface which provides address information for a network connection.
Definition: gconnection.h:37
GNet::Monitor::findCertificate
std::pair< std::string, bool > findCertificate(const std::string &certificate)
Returns a short id for the given certificate and a boolean flag to indicate if it is a new certificat...
Definition: gmonitor.cpp:148
gconnection.h
GNet::Monitor::Monitor
Monitor()
Default constructor.
Definition: gmonitor.cpp:100