NCBI C++ ToolKit
server_monitor.hpp
Go to the documentation of this file.

Go to the SVN repository for this file.

1 #ifndef CONNECT___SERVER_MONITOR__HPP
2 #define CONNECT___SERVER_MONITOR__HPP
3 
4 /* $Id: server_monitor.hpp 68399 2015-08-05 15:18:50Z vakatov $
5  * ===========================================================================
6  *
7  * PUBLIC DOMAIN NOTICE
8  * National Center for Biotechnology Information
9  *
10  * This software/database is a "United States Government Work" under the
11  * terms of the United States Copyright Act. It was written as part of
12  * the author's official duties as a United States Government employee and
13  * thus cannot be copyrighted. This software/database is freely available
14  * to the public for use. The National Library of Medicine and the U.S.
15  * Government have not placed any restriction on its use or reproduction.
16  *
17  * Although all reasonable efforts have been taken to ensure the accuracy
18  * and reliability of the software and data, the NLM and the U.S.
19  * Government do not and cannot warrant the performance or results that
20  * may be obtained by using this software or data. The NLM and the U.S.
21  * Government disclaim all warranties, express or implied, including
22  * warranties of performance, merchantability or fitness for any particular
23  * purpose.
24  *
25  * Please cite the author in any work or product based on this material.
26  *
27  * ===========================================================================
28  *
29  * Authors: Anatoliy Kuznetsov, Victor Joukov
30  *
31  * File Description: Server monitoring
32  *
33  */
34 
35 #include <corelib/ncbimtx.hpp>
36 #include <connect/ncbi_socket.hpp>
37 
38 
40 
41 /** @addtogroup ThreadedServer
42  *
43  * @{
44  */
45 
46 /// Base interface for monitoring
47 ///
49 {
50  virtual ~IServer_Monitor() {}
51 
52  /// Check if monitoring is active
53  virtual bool IsActive() = 0;
54  /// Send message
55  virtual void Send(const char* msg, size_t length) = 0;
56  /// Send message
57  virtual void Send(const string& str) = 0;
58 };
59 
60 
61 
62 /// Server monitor
63 ///
65 {
66 public:
68 
69  virtual ~CServer_Monitor();
70  /// Pass open socket for monitor output. The original socket is
71  /// empty afterwards, ownership is handled by monitor. It activates
72  /// the monitor.
73  void SetSocket(CSocket& socket);
74  bool IsMonitorActive();
75  void SendMessage(const char* msg, size_t length);
76  void SendString(const string& str);
77 
78  /// @name IServer_Monitor interface
79  /// @{
80  virtual bool IsActive();
81  virtual void Send(const char* msg, size_t length);
82  virtual void Send(const string& str);
83  ///@}
84 
85 private:
88 private:
91 };
92 
93 /* @} */
94 
95 
97 
98 #endif /* CONNECT___SERVER_MONITOR__HPP */
CFastMutex –.
Definition: ncbimtx.hpp:667
Server monitor.
CSocket::
static const char * str(char *buf, int n)
Definition: stats.c:84
#define END_NCBI_SCOPE
End previously defined NCBI scope.
Definition: ncbistl.hpp:103
#define BEGIN_NCBI_SCOPE
Define ncbi namespace.
Definition: ncbistl.hpp:100
CServer_Monitor & operator=(const CServer_Monitor &)
virtual void Send(const string &str)=0
Send message.
virtual bool IsActive()=0
Check if monitoring is active.
virtual void Send(const char *msg, size_t length)=0
Send message.
CServer_Monitor(const CServer_Monitor &)
virtual ~IServer_Monitor()
#define NCBI_XCONNECT_EXPORT
Multi-threading – mutexes; rw-locks; semaphore.
Base interface for monitoring.
Modified on Sun Apr 21 03:38:57 2024 by modify_doxy.py rev. 669887