nidas  v1.2-1520
StatusThread.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 
27 #ifndef NIDAS_CORE_STATUSTHREAD_H
28 #define NIDAS_CORE_STATUSTHREAD_H
29 
31 #include <nidas/util/Socket.h>
32 #include <nidas/util/Thread.h>
33 
34 namespace nidas { namespace core {
35 
36 class DSMServer;
37 
43 {
44 public:
48  StatusThread(const std::string& name);
49 
50 // Define this if you want to multicast over all available multicast interfaces.
51 // #define SEND_ALL_INTERFACES
52 
53 #ifdef SEND_ALL_INTERFACES
54 
67  std::vector<nidas::util::Inet4NetworkInterface>& ifaces,
68  const std::string& statstr);
69 #endif
70 
76  const std::string& statstr);
77 
78 private:
79 
81  StatusThread(const StatusThread&);
82 
85 };
86 
87 // ------------------
88 
89 
113 {
114 public:
115  DSMEngineStat(const std::string& name,const nidas::util::SocketAddress& saddr):
116  StatusThread(name),_sockAddr(saddr.clone()) {};
117 
119  {
120  delete _sockAddr;
121  }
122 
123  int run() throw(nidas::util::Exception);
124 
125 private:
126  nidas::util::SocketAddress* _sockAddr;
127 
130 
132  DSMEngineStat& operator=(const DSMEngineStat&);
133 };
134 
173 {
174 public:
175 
176  DSMServerStat(const std::string& name,DSMServer* svr);
177 
178  int run() throw(nidas::util::Exception);
179 
180 private:
181 
182  void setup();
183 
185 
190 
193 
196 };
197 
198 }} // namespace nidas namespace core
199 
200 #endif
int _uSecPeriod
Wakeup period.
Definition: StatusThread.h:189
A datagram socket to be used for multicasts.
Definition: Socket.h:1241
DSMEngineStat(const std::string &name, const nidas::util::SocketAddress &saddr)
Definition: StatusThread.h:115
StatusThread(const std::string &name)
Constructor.
Definition: StatusThread.cc:52
An interface for a socket address.
Definition: SocketAddress.h:36
A socket for sending or receiving datagrams, either unicast, broadcast or multicast.
Definition: Socket.h:912
nidas::util::SocketAddress * _sockAddr
Definition: StatusThread.h:126
Thread which provides status from a dsm_server on a datagram socket.
Definition: StatusThread.h:172
DSMEngineStat & operator=(const DSMEngineStat &)
No assignment.
void sendStatus(nidas::util::DatagramSocket *dsock, nidas::util::SocketAddress *saddr, const std::string &statstr)
Send string over DatagramSocket.
Definition: StatusThread.cc:57
DSMServer * _server
Definition: StatusThread.h:184
Definition: Exception.h:35
Definition: Thread.h:80
A thread that runs periodically checking and multicasting the status of a DSMEngine.
Definition: StatusThread.h:42
StatusThread & operator=(const StatusThread &)
No assignment.
Thread which provides status in XML form from a dsm on a datagram socket, to be read by the status_li...
Definition: StatusThread.h:112
~DSMEngineStat()
Definition: StatusThread.h:118
A provider of services to a DSM.
Definition: DSMServer.h:50
int run()
The method which will run in its own thread.
Definition: StatusThread.cc:84
Support for IP version 4 host address.
Definition: Inet4Address.h:46