nidas v1.2.3
SampleIOProcessor.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_SAMPLEIOPROCESSOR_H
28#define NIDAS_CORE_SAMPLEIOPROCESSOR_H
29
30
31#include "ConnectionRequester.h"
32#include "SampleSource.h"
33#include "SampleSourceSupport.h"
34#include "DOMable.h"
35#include "Sample.h" // dsm_sample_id_t
36
37namespace nidas { namespace core {
38
39class DSMService;
40class SampleOutput;
41class SampleTag;
42class Parameter;
43
50{
51public:
52
58 SampleIOProcessor(bool raw);
59
60 virtual ~SampleIOProcessor();
61
62 virtual const std::string& getName() const;
63
64 virtual void setName(const std::string& val);
65
66 virtual void setOptional(bool val)
67 {
68 _optional = val;
69 }
70
71 virtual bool isOptional() const
72 {
73 return _optional;
74 }
75
79 virtual const DSMService* getService() const
80 {
81 return _service;
82 }
83
84 virtual void setService(const DSMService* val)
85 {
86 _service = val;
87 }
88
92 virtual const DSMConfig* getDSMConfig() const
93 {
94 return _dsm;
95 }
96
97 virtual void setDSMConfig(const DSMConfig* val)
98 {
99 _dsm = val;
100 }
101
103
104 void setSampleId(int val) { _id = SET_SPS_ID(_id,val); }
105
106 unsigned int getSampleId() const { return GET_SPS_ID(_id); }
107
112 virtual void connectSource(SampleSource*) = 0;
113
117 virtual void disconnectSource(SampleSource*) throw() = 0;
118
119
121 {
122 return 0;
123 }
124
126 {
127 return &_source;
128 }
129
136 virtual void addRequestedSampleTag(SampleTag* tag);
137
138 virtual std::list<const SampleTag*> getRequestedSampleTags() const;
139
143 void addSampleTag(const SampleTag* tag) throw();
144
145 void removeSampleTag(const SampleTag* tag) throw();
146
150 std::list<const SampleTag*> getSampleTags() const
151 {
152 return _source.getSampleTags();
153 }
154
162
166 void addSampleClient(SampleClient* client) throw()
167 {
168 _source.addSampleClient(client);
169 }
170
171 void removeSampleClient(SampleClient* client) throw()
172 {
174 }
175
180 void addSampleClientForTag(SampleClient* client,const SampleTag* tag) throw()
181 {
182 _source.addSampleClientForTag(client,tag);
183 }
184
185 void removeSampleClientForTag(SampleClient* client,const SampleTag* tag) throw()
186 {
188 }
189
190 int getClientCount() const throw()
191 {
192 return _source.getClientCount();
193 }
194
196 {
197 return _source.getSampleStats();
198 }
199
209 virtual void addOutput(SampleOutput* val)
210 {
211 _origOutputs.push_back(val);
212 }
213
214 virtual const std::list<SampleOutput*>& getOutputs() const
215 {
216 return _origOutputs;
217 }
218
227 void addParameter(Parameter* val);
228
232 const std::list<const Parameter*>& getParameters() const
233 {
234 return _constParameters;
235 }
236
240 void fromDOMElement(const xercesc::DOMElement* node);
241
242 virtual void printStatus(std::ostream&,float,int&) throw() {}
243
244 virtual void init(dsm_time_t) throw()
245 {
246 }
247
248protected:
249
255
257
259
260 std::list<SampleTag*> _requestedTags;
261
262private:
263
264 std::string _name;
265
267
268
269 std::list<const SampleTag*> _constRequestedTags;
270
271 std::list<SampleOutput*> _origOutputs;
272
274
279
284
285 std::list<Parameter*> _parameters;
286
287 std::list<const Parameter*> _constParameters;
288
289
294
299
300};
301
302}} // namespace nidas namespace core
303
304#endif
#define GET_FULL_ID(tid)
Definition Sample.h:79
#define GET_SPS_ID(tid)
Definition Sample.h:85
#define SET_SPS_ID(tid, val)
Definition Sample.h:88
Interface of an object that can be instantiated from a DOM element, via the fromDOMElement method,...
Definition DOMable.h:51
Class that should include all that is configurable about a DSM.
Definition DSMConfig.h:55
Base class for a service, as built from a <service> XML tag.
Definition DSMService.h:48
Definition Parameter.h:47
Pure virtual interface of a client of Samples.
Definition SampleClient.h:38
Interface for an object that requests connections SampleOutputs.
Definition ConnectionRequester.h:43
Interface of a processor of samples.
Definition SampleIOProcessor.h:50
std::string _name
Definition SampleIOProcessor.h:264
int getClientCount() const
How many SampleClients are currently in my list.
Definition SampleIOProcessor.h:190
std::list< Parameter * > _parameters
Definition SampleIOProcessor.h:285
SampleSource * getProcessedSampleSource()
Several objects in NIDAS can be both a SampleSource of raw Samples and processed Samples.
Definition SampleIOProcessor.h:125
SampleSource * getRawSampleSource()
Several objects in NIDAS can be both a SampleSource of raw Samples and processed Samples.
Definition SampleIOProcessor.h:120
virtual void setService(const DSMService *val)
Definition SampleIOProcessor.h:84
virtual void printStatus(std::ostream &, float, int &)
Definition SampleIOProcessor.h:242
unsigned int getSampleId() const
Definition SampleIOProcessor.h:106
virtual void addRequestedSampleTag(SampleTag *tag)
Add a request for a SampleTag from this SampleIOProcessor.
Definition SampleIOProcessor.cc:75
void removeSampleClientForTag(SampleClient *client, const SampleTag *tag)
Remove a SampleClient for a given SampleTag from this SampleSource.
Definition SampleIOProcessor.h:185
virtual const std::list< SampleOutput * > & getOutputs() const
Definition SampleIOProcessor.h:214
virtual ~SampleIOProcessor()
Definition SampleIOProcessor.cc:48
dsm_sample_id_t _id
Definition SampleIOProcessor.h:266
void fromDOMElement(const xercesc::DOMElement *node)
Definition SampleIOProcessor.cc:134
void setSampleId(int val)
Definition SampleIOProcessor.h:104
void addSampleClient(SampleClient *client)
Implementation of SampleSource::addSampleClient().
Definition SampleIOProcessor.h:166
const DSMConfig * _dsm
Or, what DSM am I a part of?
Definition SampleIOProcessor.h:283
void addParameter(Parameter *val)
Add a parameter to this SampleIOProcessor, which will then own the pointer and will delete it in its ...
Definition SampleIOProcessor.cc:121
std::list< const SampleTag * > _constRequestedTags
Definition SampleIOProcessor.h:269
bool _optional
Definition SampleIOProcessor.h:273
const std::list< const Parameter * > & getParameters() const
Get list of parameters.
Definition SampleIOProcessor.h:232
virtual bool isOptional() const
Definition SampleIOProcessor.h:71
SampleTagIterator getSampleTagIterator() const
Implementation of SampleSource::getSampleTagIterator().
Definition SampleIOProcessor.h:158
virtual void setDSMConfig(const DSMConfig *val)
Definition SampleIOProcessor.h:97
std::list< const Parameter * > _constParameters
Definition SampleIOProcessor.h:287
virtual void connectSource(SampleSource *)=0
Connect a SampleSource to this SampleIOProcessor.
virtual void addOutput(SampleOutput *val)
Add an SampleOutput to this SampleIOProcessor.
Definition SampleIOProcessor.h:209
dsm_sample_id_t getId() const
Definition SampleIOProcessor.h:102
virtual const std::string & getName() const
Definition SampleIOProcessor.cc:127
void removeRequestedSampleTag(SampleTag *tag)
Allow subclasses to remove requested SampleTags.
Definition SampleIOProcessor.cc:85
std::list< const SampleTag * > getSampleTags() const
Implementation of SampleSource::getSampleTags().
Definition SampleIOProcessor.h:150
virtual const DSMService * getService() const
What DSMService am I associated with?
Definition SampleIOProcessor.h:79
void removeSampleClient(SampleClient *client)
Remove a SampleClient from this SampleSource.
Definition SampleIOProcessor.h:171
SampleIOProcessor(bool raw)
Does this processor generate raw or processed samples.
Definition SampleIOProcessor.cc:40
const SampleStats & getSampleStats() const
Definition SampleIOProcessor.h:195
void removeSampleTag(const SampleTag *tag)
Definition SampleIOProcessor.cc:116
virtual std::list< const SampleTag * > getRequestedSampleTags() const
Definition SampleIOProcessor.cc:105
SampleSourceSupport _source
Definition SampleIOProcessor.h:256
virtual void setName(const std::string &val)
Definition SampleIOProcessor.cc:129
const DSMService * _service
What service am I a part of?
Definition SampleIOProcessor.h:278
nidas::util::Mutex _tagsMutex
Definition SampleIOProcessor.h:258
SampleIOProcessor & operator=(const SampleIOProcessor &)
Assignment not supported.
void addSampleClientForTag(SampleClient *client, const SampleTag *tag)
Add a Client for a given SampleTag.
Definition SampleIOProcessor.h:180
virtual void disconnectSource(SampleSource *)=0
Disconnect a SampleSource from this SampleIOProcessor.
virtual const DSMConfig * getDSMConfig() const
What DSM am I associated with?
Definition SampleIOProcessor.h:92
void addSampleTag(const SampleTag *tag)
Implementation of SampleSource::addSampleTag().
Definition SampleIOProcessor.cc:111
virtual void setOptional(bool val)
Definition SampleIOProcessor.h:66
virtual void init(dsm_time_t)
Definition SampleIOProcessor.h:244
std::list< SampleOutput * > _origOutputs
Definition SampleIOProcessor.h:271
std::list< SampleTag * > _requestedTags
Definition SampleIOProcessor.h:260
SampleIOProcessor(const SampleIOProcessor &)
Copy not supported.
Interface of an output stream of samples.
Definition SampleOutput.h:49
A source of samples.
Definition SampleSourceSupport.h:47
void removeSampleClient(SampleClient *c)
Remove a SampleClient from this SampleSource This will also remove a SampleClient if it has been adde...
Definition SampleSourceSupport.cc:88
void removeSampleClientForTag(SampleClient *c, const SampleTag *)
Add a SampleClient to this SampleSource.
Definition SampleSourceSupport.cc:121
void addSampleClientForTag(SampleClient *c, const SampleTag *)
Add a SampleClient to this SampleSource.
Definition SampleSourceSupport.cc:101
void addSampleClient(SampleClient *c)
Add a SampleClient to this SampleSource.
Definition SampleSourceSupport.cc:80
SampleTagIterator getSampleTagIterator() const
Definition SampleSourceSupport.cc:75
int getClientCount() const
How many SampleClients are currently in my list.
Definition SampleSourceSupport.cc:136
const SampleStats & getSampleStats() const
Definition SampleSourceSupport.h:149
std::list< const SampleTag * > getSampleTags() const
What SampleTags am I a SampleSource for?
Definition SampleSourceSupport.cc:54
Pure virtual interface for a source of Samples.
Definition SampleSource.h:48
A source of samples.
Definition SampleStats.h:41
Class for iterating over the SampleTags of a Project, Site, DSMConfig, or a SampleSource.
Definition NidsIterators.h:218
Class describing a group of variables that are sampled and handled together.
Definition SampleTag.h:88
A C++ wrapper for a POSIX mutex.
Definition ThreadSupport.h:161
Sample * getSample(sampleType type, unsigned int len)
A convienence method for getting a sample of an enumerated type from a pool.
Definition Sample.cc:70
long long dsm_time_t
Posix time in microseconds, the number of non-leap microseconds since 1970 Jan 1 00:00 UTC.
Definition Sample.h:62
unsigned int dsm_sample_id_t
Definition Sample.h:64
Root namespace for the NCAR In-Situ Data Acquisition Software.
Definition A2DConverter.h:31