nidas  v1.2-1520
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 
37 namespace nidas { namespace core {
38 
39 class DSMService;
40 class SampleOutput;
41 class SampleTag;
42 class Parameter;
43 
50 {
51 public:
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 
102  dsm_sample_id_t getId() const { return GET_FULL_ID(_id); }
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 
134  virtual void addRequestedSampleTag(SampleTag* tag)
136 
137  virtual std::list<const SampleTag*> getRequestedSampleTags() const;
138 
142  void addSampleTag(const SampleTag* tag) throw();
143 
144  void removeSampleTag(const SampleTag* tag) throw();
145 
149  std::list<const SampleTag*> getSampleTags() const
150  {
151  return _source.getSampleTags();
152  }
153 
158  {
159  return _source.getSampleTagIterator();
160  }
161 
165  void addSampleClient(SampleClient* client) throw()
166  {
167  _source.addSampleClient(client);
168  }
169 
170  void removeSampleClient(SampleClient* client) throw()
171  {
172  _source.removeSampleClient(client);
173  }
174 
179  void addSampleClientForTag(SampleClient* client,const SampleTag* tag) throw()
180  {
181  _source.addSampleClientForTag(client,tag);
182  }
183 
184  void removeSampleClientForTag(SampleClient* client,const SampleTag* tag) throw()
185  {
186  _source.removeSampleClientForTag(client,tag);
187  }
188 
189  int getClientCount() const throw()
190  {
191  return _source.getClientCount();
192  }
193 
195  {
196  return _source.getSampleStats();
197  }
198 
208  virtual void addOutput(SampleOutput* val)
209  {
210  _origOutputs.push_back(val);
211  }
212 
213  virtual const std::list<SampleOutput*>& getOutputs() const
214  {
215  return _origOutputs;
216  }
217 
224  void addParameter(Parameter* val)
226 
230  const std::list<const Parameter*>& getParameters() const
231  {
232  return _constParameters;
233  }
234 
235  void fromDOMElement(const xercesc::DOMElement* node)
237 
238  virtual void printStatus(std::ostream&,float,int&) throw() {}
239 
240  virtual void init(dsm_time_t) throw()
241  {
242  }
243 
244 protected:
245 
251 
253 
255 
256  std::list<SampleTag*> _requestedTags;
257 
258 private:
259 
260  std::string _name;
261 
263 
264 
265  std::list<const SampleTag*> _constRequestedTags;
266 
267  std::list<SampleOutput*> _origOutputs;
268 
269  bool _optional;
270 
275 
279  const DSMConfig* _dsm;
280 
281  std::list<Parameter*> _parameters;
282 
283  std::list<const Parameter*> _constParameters;
284 
285 
290 
295 
296 };
297 
298 }} // namespace nidas namespace core
299 
300 #endif
bool _optional
Definition: SampleIOProcessor.h:269
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:184
Interface for an object that requests connections SampleOutputs.
Definition: ConnectionRequester.h:42
nidas::util::Mutex _tagsMutex
Definition: SampleIOProcessor.h:254
dsm_sample_id_t getId() const
Definition: SampleIOProcessor.h:102
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:122
unsigned int dsm_sample_id_t
Definition: Sample.h:63
virtual void setDSMConfig(const DSMConfig *val)
Definition: SampleIOProcessor.h:97
#define GET_FULL_ID(tid)
Definition: Sample.h:78
void removeRequestedSampleTag(SampleTag *tag)
Allow subclasses to remove requested SampleTags.
Definition: SampleIOProcessor.cc:86
SampleTagIterator getSampleTagIterator() const
Implementation of SampleSource::getSampleTagIterator().
Definition: SampleIOProcessor.h:157
Interface of an output stream of samples.
Definition: SampleOutput.h:47
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:61
SampleSource * getRawSampleSource()
Several objects in NIDAS can be both a SampleSource of raw Samples and processed Samples.
Definition: SampleIOProcessor.h:120
Class that should include all that is configurable about a DSM.
Definition: DSMConfig.h:55
Pure virtual interface for a source of Samples.
Definition: SampleSource.h:48
SampleIOProcessor(bool raw)
Does this processor generate raw or processed samples.
Definition: SampleIOProcessor.cc:40
virtual void connectSource(SampleSource *)=0
Connect a SampleSource to this SampleIOProcessor.
SampleTagIterator getSampleTagIterator() const
Definition: SampleSourceSupport.cc:75
std::list< SampleTag * > _requestedTags
Definition: SampleIOProcessor.h:256
virtual void disconnectSource(SampleSource *)=0
Disconnect a SampleSource from this SampleIOProcessor.
unsigned int getSampleId() const
Definition: SampleIOProcessor.h:106
std::string _name
Definition: SampleIOProcessor.h:260
const DSMConfig * _dsm
Or, what DSM am I a part of?
Definition: SampleIOProcessor.h:279
std::list< const SampleTag * > getSampleTags() const
Implementation of SampleSource::getSampleTags().
Definition: SampleIOProcessor.h:149
virtual const std::string & getName() const
Definition: SampleIOProcessor.cc:129
Interface of an object that can be instantiated from a DOM element, via the fromDOMElement method...
Definition: DOMable.h:51
virtual const std::list< SampleOutput * > & getOutputs() const
Definition: SampleIOProcessor.h:213
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 addSampleClient(SampleClient *c)
Add a SampleClient to this SampleSource.
Definition: SampleSourceSupport.cc:80
std::list< const Parameter * > _constParameters
Definition: SampleIOProcessor.h:283
void setSampleId(int val)
Definition: SampleIOProcessor.h:104
Pure virtual interface of a client of Samples.
Definition: SampleClient.h:38
virtual void printStatus(std::ostream &, float, int &)
Definition: SampleIOProcessor.h:238
void removeSampleClient(SampleClient *client)
Remove a SampleClient from this SampleSource.
Definition: SampleIOProcessor.h:170
const SampleStats & getSampleStats() const
Definition: SampleSourceSupport.h:149
const SampleStats & getSampleStats() const
Definition: SampleIOProcessor.h:194
std::list< const SampleTag * > _constRequestedTags
Definition: SampleIOProcessor.h:265
virtual void setOptional(bool val)
Definition: SampleIOProcessor.h:66
std::list< Parameter * > _parameters
Definition: SampleIOProcessor.h:281
void removeSampleTag(const SampleTag *tag)
Definition: SampleIOProcessor.cc:117
virtual void init(dsm_time_t)
Definition: SampleIOProcessor.h:240
const std::list< const Parameter * > & getParameters() const
Get list of parameters.
Definition: SampleIOProcessor.h:230
virtual void setService(const DSMService *val)
Definition: SampleIOProcessor.h:84
const DSMService * _service
What service am I a part of?
Definition: SampleIOProcessor.h:274
Definition: Parameter.h:46
virtual const DSMConfig * getDSMConfig() const
What DSM am I associated with?
Definition: SampleIOProcessor.h:92
virtual bool isOptional() const
Definition: SampleIOProcessor.h:71
Class for iterating over the SampleTags of a Project, Site, DSMConfig, or a SampleSource.
Definition: NidsIterators.h:217
virtual void addOutput(SampleOutput *val)
Add an SampleOutput to this SampleIOProcessor.
Definition: SampleIOProcessor.h:208
void addSampleClientForTag(SampleClient *client, const SampleTag *tag)
Add a Client for a given SampleTag.
Definition: SampleIOProcessor.h:179
Class describing a group of variables that are sampled and handled together.
Definition: SampleTag.h:87
virtual ~SampleIOProcessor()
Definition: SampleIOProcessor.cc:48
void addSampleClientForTag(SampleClient *c, const SampleTag *)
Add a SampleClient to this SampleSource.
Definition: SampleSourceSupport.cc:101
Interface of a processor of samples.
Definition: SampleIOProcessor.h:49
virtual void setName(const std::string &val)
Definition: SampleIOProcessor.cc:131
A source of samples.
Definition: SampleStats.h:41
virtual const DSMService * getService() const
What DSMService am I associated with?
Definition: SampleIOProcessor.h:79
void fromDOMElement(const xercesc::DOMElement *node)
Initialize myself from a xercesc::DOMElement.
Definition: SampleIOProcessor.cc:136
SampleIOProcessor & operator=(const SampleIOProcessor &)
Assignment not supported.
int getClientCount() const
How many SampleClients are currently in my list.
Definition: SampleIOProcessor.h:189
int getClientCount() const
How many SampleClients are currently in my list.
Definition: SampleSourceSupport.cc:136
#define GET_SPS_ID(tid)
Definition: Sample.h:84
std::list< const SampleTag * > getSampleTags() const
What SampleTags am I a SampleSource for?
Definition: SampleSourceSupport.cc:54
SampleSource * getProcessedSampleSource()
Several objects in NIDAS can be both a SampleSource of raw Samples and processed Samples.
Definition: SampleIOProcessor.h:125
A C++ wrapper for a POSIX mutex.
Definition: ThreadSupport.h:154
#define SET_SPS_ID(tid, val)
Definition: Sample.h:87
void addSampleClient(SampleClient *client)
Implementation of SampleSource::addSampleClient().
Definition: SampleIOProcessor.h:165
Base class for a service, as built from a &lt;service&gt; XML tag.
Definition: DSMService.h:47
dsm_sample_id_t _id
Definition: SampleIOProcessor.h:262
void addSampleTag(const SampleTag *tag)
Implementation of SampleSource::addSampleTag().
Definition: SampleIOProcessor.cc:112
std::list< SampleOutput * > _origOutputs
Definition: SampleIOProcessor.h:267
Definition: InvalidParameterException.h:35
SampleSourceSupport _source
Definition: SampleIOProcessor.h:252
virtual std::list< const SampleTag * > getRequestedSampleTags() const
Definition: SampleIOProcessor.cc:106