nidas  v1.2-1520
StatusListener.h
Go to the documentation of this file.
1 // -*- mode: C++; indent-tabs-mode: nil; c-basic-offset: 4; tab-width: 4; -*-
2 // vim: set shiftwidth=4 softtabstop=4 expandtab:
3 /*
4  ********************************************************************
5  ** NIDAS: NCAR In-situ Data Acquistion Software
6  **
7  ** 2005, Copyright University Corporation for Atmospheric Research
8  **
9  ** This program is free software; you can redistribute it and/or modify
10  ** it under the terms of the GNU General Public License as published by
11  ** the Free Software Foundation; either version 2 of the License, or
12  ** (at your option) any later version.
13  **
14  ** This program is distributed in the hope that it will be useful,
15  ** but WITHOUT ANY WARRANTY; without even the implied warranty of
16  ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17  ** GNU General Public License for more details.
18  **
19  ** The LICENSE.txt file accompanying this software contains
20  ** a copy of the GNU General Public License. If it is not found,
21  ** write to the Free Software Foundation, Inc.,
22  ** 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
23  **
24  ********************************************************************
25 */
26 #ifndef NIDAS_CORE_STATUSLISTENER_H
27 #define NIDAS_CORE_STATUSLISTENER_H
28 
29 #include <xercesc/sax2/XMLReaderFactory.hpp> // provides SAX2XMLReader
30 #include <xmlrpcpp/XmlRpc.h>
31 
32 #include <nidas/util/Thread.h>
33 
34 #include <iostream> // cerr
35 #include <map>
36 
37 namespace nidas { namespace core {
38 
39 class StatusHandler;
40 class GetClocks;
41 class GetStatus;
42 
43 
46 {
47  friend class StatusHandler;
48  friend class GetClocks;
49  friend class GetStatus;
50 
51 public:
54 
55  int run() throw(nidas::util::Exception);
56 
57 private:
59  nidas::util::Mutex _clocksMutex;
60  nidas::util::Mutex _statusMutex;
61 
63  std::map < std::string, std::string > _clocks;
64  std::map < std::string, std::string > _oldclk;
65  std::map < std::string, int >_nstale;
66 
68  std::map < std::string, std::string > _status;
69 
71  std::map < std::string, std::string > _samplePool;
72 
74  xercesc::SAX2XMLReader * _parser;
75 
78 
81 
83  StatusListener& operator=(const StatusListener&);
84 };
85 
86 
88 class GetClocks:public XmlRpc::XmlRpcServerMethod
89 {
90 public:
91  GetClocks(XmlRpc::XmlRpcServer * s, StatusListener * lstn):
92  XmlRpc::XmlRpcServerMethod("GetClocks", s), _listener(lstn)
93  {
94  }
95 
96  void execute(XmlRpc::XmlRpcValue & params,
97  XmlRpc::XmlRpcValue & result);
98 
99  std::string help()
100  {
101  return std::string("help GetClocks");
102  }
103 
104 private:
106  StatusListener * _listener;
107 
109  GetClocks(const GetClocks&);
110 
112  GetClocks& operator=(const GetClocks&);
113 };
114 
116 class GetStatus:public XmlRpc::XmlRpcServerMethod
117 {
118 public:
119  GetStatus(XmlRpc::XmlRpcServer * s,
121  lstn):XmlRpc::XmlRpcServerMethod("GetStatus", s),
122  _listener(lstn)
123  {
124  }
125 
126  void execute(XmlRpc::XmlRpcValue & params,
127  XmlRpc::XmlRpcValue & result);
128 
129  std::string help() {
130  return std::string("help GetStatus");
131  }
132 
133 private:
136 
138  GetStatus(const GetStatus&);
139 
141  GetStatus& operator=(const GetStatus&);
142 
143 };
144 
145 }} // namespace nidas namespace core
146 
147 #endif
~StatusListener()
Definition: StatusListener.cc:73
std::string help()
Definition: StatusListener.h:129
gets a list of current status reports for each broadcasting DSM.
Definition: StatusListener.h:116
int run()
The method which will run in its own thread.
Definition: StatusListener.cc:80
StatusListener * _listener
reference to listener thread
Definition: StatusListener.h:135
nidas::util::Mutex _clocksMutex
provide mutually exclusive access to these maps.
Definition: StatusListener.h:59
friend class GetClocks
Definition: StatusListener.h:48
StatusListener()
Definition: StatusListener.cc:45
friend class GetStatus
Definition: StatusListener.h:49
This class implements handling routines for the SAX2 parser.
Definition: StatusHandler.h:41
GetClocks(XmlRpc::XmlRpcServer *s, StatusListener *lstn)
Definition: StatusListener.h:91
Definition: Thread.h:80
std::map< std::string, std::string > _clocks
this map contains the latest clock from each DSM
Definition: StatusListener.h:63
StatusListener & operator=(const StatusListener &)
No assignment.
std::map< std::string, std::string > _status
this map contains the latest status message from each DSM
Definition: StatusListener.h:68
StatusHandler * _handler
SAX handler.
Definition: StatusListener.h:77
nidas::util::Mutex _statusMutex
Definition: StatusListener.h:60
std::map< std::string, std::string > _samplePool
this map contains the latest sample pool message from each DSM
Definition: StatusListener.h:71
std::map< std::string, int > _nstale
Definition: StatusListener.h:65
StatusListener * _listener
reference to listener thread
Definition: StatusListener.h:106
thread that listens to multicast messages from all of the DSMs.
Definition: StatusListener.h:45
std::map< std::string, std::string > _oldclk
Definition: StatusListener.h:64
xercesc::SAX2XMLReader * _parser
SAX parser.
Definition: StatusListener.h:74
GetStatus(XmlRpc::XmlRpcServer *s, StatusListener *lstn)
Definition: StatusListener.h:119
gets a list of current clock times for each broadcasting DSM.
Definition: StatusListener.h:88
std::string help()
Definition: StatusListener.h:99