VideoTools
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
gmonitor.h
Go to the documentation of this file.
1 //
2 // Copyright (C) 2017 Graeme Walker
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_GNET_MONITOR_H
22 #define G_GNET_MONITOR_H
23 
24 #include "gdef.h"
25 #include "gslot.h"
26 #include "gnet.h"
27 #include "gconnection.h"
28 #include <iostream>
29 #include <utility>
30 
31 namespace GNet
32 {
33  class Monitor ;
34  class MonitorImp ;
35 }
36 
37 /// \class GNet::Monitor
38 /// A singleton for monitoring GNet::SimpleClient and GNet::ServerPeer
39 /// connections and for storing their TLS certificates.
40 /// \see GNet::SimpleClient, GNet::ServerPeer
41 ///
43 {
44 public:
45  Monitor() ;
46  ///< Default constructor.
47 
48  virtual ~Monitor() ;
49  ///< Destructor.
50 
51  static Monitor * instance() ;
52  ///< Returns the singleton pointer. Returns null if none.
53 
54  void addClient( const Connection & simple_client ) ;
55  ///< Adds a client connection.
56 
57  void removeClient( const Connection & simple_client ) ;
58  ///< Removes a client connection.
59 
60  void addServerPeer( const Connection & server_peer ) ;
61  ///< Adds a server connection.
62 
63  void removeServerPeer( const Connection & server_peer ) ;
64  ///< Removes a server connection.
65 
66  void report( std::ostream & stream ,
67  const std::string & line_prefix = std::string() ,
68  const std::string & eol = std::string("\n") ) const ;
69  ///< Reports itself onto a stream.
70 
71  void report( G::StringArray & out ) const ;
72  ///< Reports itself into a three-column table.
73 
74  std::pair<std::string,bool> findCertificate( const std::string & certificate ) ;
75  ///< Returns a short id for the given certificate and a boolean
76  ///< flag to indicate if it is a new certificate id that has
77  ///< not been returned before.
78 
80  ///< Provides a callback signal which can be connect()ed
81  ///< to a slot.
82  ///<
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 ;
94 } ;
95 
96 #endif
void removeServerPeer(const Connection &server_peer)
Removes a server connection.
Definition: gmonitor.cpp:143
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:154
std::vector< std::string > StringArray
A std::vector of std::strings.
Definition: gstrings.h:33
void addClient(const Connection &simple_client)
Adds a client connection.
Definition: gmonitor.cpp:124
G::Slot::Signal2< std::string, std::string > & signal()
Provides a callback signal which can be connect()ed to a slot.
Definition: gmonitor.cpp:119
A pimple-pattern implementation class for GNet::Monitor.
Definition: gmonitor.cpp:36
A singleton for monitoring GNet::SimpleClient and GNet::ServerPeer connections and for storing their ...
Definition: gmonitor.h:42
static Monitor * instance()
Returns the singleton pointer. Returns null if none.
Definition: gmonitor.cpp:114
virtual ~Monitor()
Destructor.
Definition: gmonitor.cpp:108
void removeClient(const Connection &simple_client)
Removes a client connection.
Definition: gmonitor.cpp:130
void addServerPeer(const Connection &server_peer)
Adds a server connection.
Definition: gmonitor.cpp:136
An interface which provides address information for a network connection.
Definition: gconnection.h:37
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:149
Monitor()
Default constructor.
Definition: gmonitor.cpp:101