nidas v1.2.3
DSMService.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
28#ifndef NIDAS_CORE_DSMSERVICE_H
29#define NIDAS_CORE_DSMSERVICE_H
30
31#include <nidas/util/Thread.h>
32#include "DOMable.h"
33#include "NidsIterators.h"
34
35namespace nidas { namespace core {
36
37class Project;
38class DSMServer;
39class Site;
40class SampleInput;
41class SampleIOProcessor;
42class IOChannel;
43
47class DSMService: public DOMable
48{
49public:
50
54 DSMService(const std::string& name);
55
56 virtual ~DSMService();
57
58 const std::string& getName() const
59 {
60 return _name;
61 }
62
63 virtual void setDSMServer(DSMServer* val);
64
65 virtual DSMServer* getDSMServer() const { return _server; }
66
67 virtual void connect(SampleInput*) throw() = 0;
68
73 virtual void addProcessor(SampleIOProcessor* proc)
74 {
75 _processors.push_back(proc);
76 }
77
78 virtual const std::list<SampleIOProcessor*>& getProcessors() const
79 {
80 return _processors;
81 }
82
83 const std::list<SampleInput*>& getInputs() const
84 {
85 return _inputs;
86 }
87
89
95 virtual void schedule(bool optionalProcessing) = 0;
96
97 virtual int checkSubThreads() throw();
98
99 virtual void cancel() throw();
100
101 virtual void interrupt() throw();
102
103 virtual int join() throw();
104
108 static const std::string getClassName(const xercesc::DOMElement* node,
109 const Project*);
110
114 void fromDOMElement(const xercesc::DOMElement* node);
115
116 nidas::util::Thread::SchedPolicy getSchedPolicy() const
117 {
118 return _threadPolicy;
119 }
120
122 {
123 return _threadPriority;
124 }
125
126 virtual void printClock(std::ostream&) throw() {}
127
128 virtual void printStatus(std::ostream&,float) throw() {}
129
130protected:
131
132 void addSubThread(nidas::util::Thread*) throw();
133
134 std::string _name;
135
137
138 std::set<nidas::util::Thread*> _subThreads;
139
141
142 std::list<SampleInput*> _inputs;
143
144 std::list<SampleIOProcessor*> _processors;
145
146 std::list<IOChannel*> _ochans;
147
149
151
152private:
157
162
163};
164
165}} // namespace nidas namespace core
166
167#endif
Interface of an object that can be instantiated from a DOM element, via the fromDOMElement method,...
Definition DOMable.h:51
A provider of services to a DSM.
Definition DSMServer.h:50
Base class for a service, as built from a <service> XML tag.
Definition DSMService.h:48
virtual DSMServer * getDSMServer() const
Definition DSMService.h:65
DSMService(const std::string &name)
Constructor.
Definition DSMService.cc:43
std::set< nidas::util::Thread * > _subThreads
Definition DSMService.h:138
virtual ~DSMService()
Definition DSMService.cc:50
std::list< SampleIOProcessor * > _processors
Definition DSMService.h:144
ProcessorIterator getProcessorIterator() const
Definition DSMService.cc:76
DSMService(const DSMService &x)
Copying not supported.
virtual void connect(SampleInput *)=0
virtual void addProcessor(SampleIOProcessor *proc)
Add a processor to this RawSampleService.
Definition DSMService.h:73
nidas::util::Thread::SchedPolicy getSchedPolicy() const
Definition DSMService.h:116
void addSubThread(nidas::util::Thread *)
Definition DSMService.cc:86
const std::string & getName() const
Definition DSMService.h:58
virtual int join()
Definition DSMService.cc:128
virtual void printStatus(std::ostream &, float)
Definition DSMService.h:128
virtual const std::list< SampleIOProcessor * > & getProcessors() const
Definition DSMService.h:78
nidas::util::Thread::SchedPolicy _threadPolicy
Definition DSMService.h:148
virtual int checkSubThreads()
Definition DSMService.cc:149
DSMServer * _server
Definition DSMService.h:136
void fromDOMElement(const xercesc::DOMElement *node)
Definition DSMService.cc:204
virtual void schedule(bool optionalProcessing)=0
schedule this service to run.
virtual void cancel()
Definition DSMService.cc:110
static const std::string getClassName(const xercesc::DOMElement *node, const Project *)
Definition DSMService.cc:179
virtual void setDSMServer(DSMServer *val)
Definition DSMService.cc:81
const std::list< SampleInput * > & getInputs() const
Definition DSMService.h:83
int _threadPriority
Definition DSMService.h:150
virtual void printClock(std::ostream &)
Definition DSMService.h:126
std::list< SampleInput * > _inputs
Definition DSMService.h:142
std::list< IOChannel * > _ochans
Definition DSMService.h:146
std::string _name
Definition DSMService.h:134
int getSchedPriority() const
Definition DSMService.h:121
nidas::util::Mutex _subThreadMutex
Definition DSMService.h:140
DSMService & operator=(const DSMService &x)
Assignment not supported.
virtual void interrupt()
Definition DSMService.cc:92
Class for iterating over the Processors of a DSMServer or DSMConfig.
Definition NidsIterators.h:150
Definition Project.h:60
Interface of a processor of samples.
Definition SampleIOProcessor.h:50
Interface of an input SampleSource.
Definition SampleInput.h:48
A C++ wrapper for a POSIX mutex.
Definition ThreadSupport.h:161
Definition Thread.h:83
SchedPolicy
Definition Thread.h:321
Root namespace for the NCAR In-Situ Data Acquisition Software.
Definition A2DConverter.h:31