nidas  v1.2-1520
DSMServerApp.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  ** 2009, 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_DSMSERVERAPP_H
28 #define NIDAS_CORE_DSMSERVERAPP_H
29 
30 #include "Datasets.h"
31 #include "XMLException.h"
32 #include "NidasApp.h"
34 #include <nidas/util/IOException.h>
36 
37 #include <signal.h>
38 
39 namespace nidas { namespace core {
40 
41 class Project;
42 class DSMServer;
43 class DSMServerIntf;
44 class DSMServerStat;
45 
46 class DSMServerApp {
47 public:
48 
49  DSMServerApp();
50 
51  ~DSMServerApp();
52 
56  static int main(int argc, char** argv) throw();
57 
58  static DSMServerApp* getInstance() { return _instance; }
59 
60  void initLogger();
61 
62  int initProcess();
63 
64  int run() throw();
65 
66  int parseRunstring(int argc, char** argv);
67 
71  int usage();
72 
76  void parseXMLConfigFile(const std::string& xmlFileName,Project&)
77  throw(nidas::core::XMLException,
78  nidas::util::InvalidParameterException,nidas::util::IOException);
79 
80  void startXmlRpcThread() throw(nidas::util::Exception);
81 
82  void killXmlRpcThread() throw();
83 
84  void startStatusThread(DSMServer* svr) throw(nidas::util::Exception);
85 
86  void killStatusThread() throw();
87 
91  const std::string& getXMLFileName() { return _xmlFileName; }
92 
94 
95 private:
96 
102  void setupSignals();
103 
110  void waitForSignal(int timeoutSecs);
111 
113 
115 
119  bool _debug;
120 
124  std::string _xmlFileName;
125 
129  std::string _configsXMLName;
130 
132 
135 
137 
139 
141 
142  sigset_t _signalMask;
143 
144  pthread_t _myThreadId;
145 
146  std::string _datasetName;
147 
149 
152 
154  DSMServerApp(const DSMServerApp &);
155 
158 };
159 
160 }} // namespace nidas namespace core
161 
162 #endif
void waitForSignal(int timeoutSecs)
Unblock and wait for signals of interest up to timeoutSecs.
Definition: DSMServerApp.cc:387
Definition: DSMServerApp.h:114
const std::string & getXMLFileName()
What is the XML configuration file name.
Definition: DSMServerApp.h:91
int initProcess()
Definition: DSMServerApp.cc:204
static DSMServerApp * _instance
Definition: DSMServerApp.h:112
Exception which can be built from an xerces::XMLException, xercesc::SAXException, or xercesc::DOMExce...
Definition: XMLException.h:43
Definition: DSMServerApp.h:114
DSMServerApp & operator=(const DSMServerApp &)
Assignment not needed.
bool _externalControl
Definition: DSMServerApp.h:138
Definition: DSMServerApp.h:46
DSMServerIntf * _xmlrpcThread
This thread provides XML-based Remote Procedure calls.
Definition: DSMServerApp.h:134
std::string _xmlFileName
The xml file that is being used for configuration information.
Definition: DSMServerApp.h:124
static int main(int argc, char **argv)
Run DSMServerApp from the unix command line.
Definition: DSMServerApp.cc:153
A Dataset is a named collection of parameters, that are used in data processing.
Definition: Datasets.h:47
Thread which provides status from a dsm_server on a datagram socket.
Definition: StatusThread.h:172
Definition: DSMServerApp.h:114
DSMServerApp()
Definition: DSMServerApp.cc:62
void startXmlRpcThread()
Definition: DSMServerApp.cc:315
Definition: DSMServerApp.h:114
enum runState _runState
Definition: DSMServerApp.h:131
int parseRunstring(int argc, char **argv)
Definition: DSMServerApp.cc:88
Dataset getDataset()
Definition: DSMServerApp.cc:456
static DSMServerApp * getInstance()
Definition: DSMServerApp.h:58
~DSMServerApp()
Definition: DSMServerApp.cc:82
int run()
Definition: DSMServerApp.cc:211
void parseXMLConfigFile(const std::string &xmlFileName, Project &)
Invoke a XMLCachingParser to parse the XML and initialize the Project.
Definition: DSMServerApp.cc:426
int usage()
Send usage message to cerr.
Definition: DSMServerApp.cc:134
NidasAppArg ExternalControl
Definition: DSMServerApp.h:150
A NidasAppArg is command-line argument which can be handled by NidasApp.
Definition: NidasApp.h:73
void startStatusThread(DSMServer *svr)
Definition: DSMServerApp.cc:340
void initLogger()
Definition: DSMServerApp.cc:199
void setupSignals()
Create a signal mask, and block those masked signals.
Definition: DSMServerApp.cc:374
A thread that provides XML-based Remote Procedure Calls to web interfaces from the DSMServer...
Definition: DSMServerIntf.h:43
runState
Definition: DSMServerApp.h:114
NidasApp handles common options for NIDAS applications.
Definition: NidasApp.h:572
NidasAppArg OptionalProcessing
Definition: DSMServerApp.h:151
DSMServerStat * _statusThread
Definition: DSMServerApp.h:136
std::string _datasetName
Definition: DSMServerApp.h:146
Definition: Project.h:60
pthread_t _myThreadId
Definition: DSMServerApp.h:144
sigset_t _signalMask
Definition: DSMServerApp.h:142
A provider of services to a DSM.
Definition: DSMServer.h:50
bool _optionalProcessing
Definition: DSMServerApp.h:140
void killXmlRpcThread()
Definition: DSMServerApp.cc:323
static int timeoutSecs
Definition: sing.cc:62
void killStatusThread()
Definition: DSMServerApp.cc:349
std::string _configsXMLName
The xml file that contains all the project configurations, by date.
Definition: DSMServerApp.h:129
NidasApp _app
Definition: DSMServerApp.h:148
bool _debug
-d option.
Definition: DSMServerApp.h:119