Class Reference for E1039 Core & Analysis Software
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
OnlMonServer.h
Go to the documentation of this file.
1 #ifndef __H_OnlMonServer__H__
2 #define __H_OnlMonServer__H__
3 #include <string>
5 #include <pthread.h>
6 class TSocket;
7 
8 class OnlMonServer : public Fun4AllServer
9 {
10  //static std::string m_out_dir;
11  static std::string m_mon_host;
12  static int m_mon_port; //< The port being used
13  static int m_mon_port_0; //< The 1st number of available ports
14  static int m_mon_n_port; //< The number of available ports
15 
16  bool m_is_online;
17  bool m_go_end;
18  bool m_svr_ready;
19 
20  public:
21  static OnlMonServer *instance();
22  virtual ~OnlMonServer();
23 
24  int End();
25 
26  //static void SetOutDir (const std::string dir) { m_out_dir = dir ; }
27  static void SetHost (const std::string host) { m_mon_host = host; }
28  static void SetPort (const int port) { m_mon_port = port; }
29  static void SetPort0 (const int port) { m_mon_port_0 = port; }
30  static void SetNumPorts(const int num ) { m_mon_n_port = num ; }
31  //static std::string GetOutDir () { return m_out_dir ; }
32  static std::string GetHost () { return m_mon_host ; }
33  static int GetPort () { return m_mon_port ; }
34  static int GetPort0 () { return m_mon_port_0; }
35  static int GetNumPorts() { return m_mon_n_port; }
36 
37  void StartServer();
38  bool CloseExistingServer(const int port);
39  static void* FuncServer(void* arg);
40  void HandleConnection(TSocket* sock);
41  void SetOnline(const bool val) { m_is_online = val; }
42  bool GetOnline() { return m_is_online; }
43  void SetGoEnd(const bool val) { m_go_end = val; }
44  bool GetGoEnd() { return m_go_end; }
45  void SetServerReady(const bool val) { m_svr_ready = val; }
46  bool GetServerReady() { return m_svr_ready; }
47 
48 #ifndef __CINT__
49  pthread_mutex_t* GetMutex() { return &mutex; }
50  void GetMutex(pthread_mutex_t &lock) {lock = mutex;}
51  void SetThreadId(pthread_t &id) {serverthreadid = id;}
52 #endif
53 
54  protected:
55  OnlMonServer(const std::string &name = "OnlMonServer");
56 
57 #ifndef __CINT__
58  pthread_mutex_t mutex; //< Control the access to subsystem histograms.
59  pthread_t serverthreadid;
60 #endif
61 
62 };
63 
64 #endif
void GetMutex(pthread_mutex_t &lock)
Definition: OnlMonServer.h:50
OnlMonServer(const std::string &name="OnlMonServer")
Definition: OnlMonServer.cc:44
void HandleConnection(TSocket *sock)
static void SetPort0(const int port)
Definition: OnlMonServer.h:29
static void SetNumPorts(const int num)
Definition: OnlMonServer.h:30
static void SetHost(const std::string host)
Definition: OnlMonServer.h:27
virtual ~OnlMonServer()
Definition: OnlMonServer.cc:61
void SetOnline(const bool val)
Definition: OnlMonServer.h:41
pthread_mutex_t * GetMutex()
Definition: OnlMonServer.h:49
static int GetPort()
Definition: OnlMonServer.h:33
bool GetGoEnd()
Definition: OnlMonServer.h:44
static std::string GetHost()
Definition: OnlMonServer.h:32
void SetThreadId(pthread_t &id)
Definition: OnlMonServer.h:51
static int GetNumPorts()
Definition: OnlMonServer.h:35
void SetServerReady(const bool val)
Definition: OnlMonServer.h:45
void SetGoEnd(const bool val)
Definition: OnlMonServer.h:43
bool GetOnline()
Definition: OnlMonServer.h:42
pthread_t serverthreadid
Definition: OnlMonServer.h:59
bool CloseExistingServer(const int port)
Close an existing server process if such exists.
bool GetServerReady()
Definition: OnlMonServer.h:46
void StartServer()
Definition: OnlMonServer.cc:66
static int GetPort0()
Definition: OnlMonServer.h:34
static void SetPort(const int port)
Definition: OnlMonServer.h:28
static OnlMonServer * instance()
Definition: OnlMonServer.cc:34
static void * FuncServer(void *arg)
pthread_mutex_t mutex
Definition: OnlMonServer.h:58