nidas  v1.2-1520
SampleSourceSupport.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_SAMPLESOURCESUPPORT_H
28 #define NIDAS_CORE_SAMPLESOURCESUPPORT_H
29 
30 #include "SampleSource.h"
31 #include "SampleClientList.h"
32 
33 #include <set>
34 #include <map>
35 
36 namespace nidas { namespace core {
37 
38 class SampleTag;
39 
48 public:
49 
50  SampleSourceSupport(bool raw);
51 
57 
58  virtual ~SampleSourceSupport() {}
59 
61  {
62  if (!_raw) return 0;
63  return this;
64  }
65 
67  {
68  if (_raw) return 0;
69  return this;
70  }
71 
72  void addSampleTag(const SampleTag* tag) throw();
73 
74  void removeSampleTag(const SampleTag* tag) throw();
75 
76  std::list<const SampleTag*> getSampleTags() const;
77 
79 
85  void addSampleClient(SampleClient* c) throw();
86 
92  void removeSampleClient(SampleClient* c) throw();
93 
99  void addSampleClientForTag(SampleClient* c,const SampleTag*) throw();
100 
106  void removeSampleClientForTag(SampleClient* c,const SampleTag*) throw();
107 
111  int getClientCount() const throw();
112 
116  void removeAllSampleClients() throw()
117  {
120  _clientSet.clear();
122  }
123 
135  void distribute(const Sample* s) throw();
136 
142  void distribute(const std::list<const Sample*>& samps) throw();
143 
147  void flush() throw() {}
148 
150  {
151  return _stats;
152  }
153 
154  void setKeepStats(bool val)
155  {
156  _keepStats = val;
157  }
158 
159  bool getKeepStats() const
160  {
161  return _keepStats;
162  }
163 
164 private:
165 
167 
168  std::list<const SampleTag*> _sampleTags;
169 
174 
178  std::map<dsm_sample_id_t,SampleClientList> _clientsBySampleId;
179 
180  std::set<SampleClient*> _clientSet;
181 
183 
185 
186  bool _raw;
187 
189 
194 
195 };
196 
197 }} // namespace nidas namespace core
198 
199 
200 #endif
void setKeepStats(bool val)
Definition: SampleSourceSupport.h:154
SampleClientList _clients
Current clients of all samples.
Definition: SampleSourceSupport.h:173
void removeSampleTag(const SampleTag *tag)
Definition: SampleSourceSupport.cc:67
Pure virtual interface for a source of Samples.
Definition: SampleSource.h:48
SampleTagIterator getSampleTagIterator() const
Definition: SampleSourceSupport.cc:75
SampleStats _stats
Definition: SampleSourceSupport.h:184
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
bool getKeepStats() const
Definition: SampleSourceSupport.h:159
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
Pure virtual interface of a client of Samples.
Definition: SampleClient.h:38
const SampleStats & getSampleStats() const
Definition: SampleSourceSupport.h:149
std::map< dsm_sample_id_t, SampleClientList > _clientsBySampleId
Current clients of specific samples.
Definition: SampleSourceSupport.h:178
nidas::util::Mutex _clientMapLock
Definition: SampleSourceSupport.h:182
void removeAllSampleClients()
Big cleanup.
Definition: SampleSourceSupport.h:116
SampleSourceSupport & operator=(const SampleSourceSupport &x)
No assignment.
void lock()
Lock the Mutex.
Definition: ThreadSupport.h:206
Interface to a data sample.
Definition: Sample.h:189
A list of SampleClients.
Definition: SampleClientList.h:41
SampleSource * getRawSampleSource()
Several objects in NIDAS can be both a SampleSource of raw Samples and processed Samples.
Definition: SampleSourceSupport.h:60
Class for iterating over the SampleTags of a Project, Site, DSMConfig, or a SampleSource.
Definition: NidsIterators.h:217
nidas::util::Mutex _tagsMutex
Definition: SampleSourceSupport.h:166
Class describing a group of variables that are sampled and handled together.
Definition: SampleTag.h:87
void distribute(const Sample *s)
Distribute a sample to my clients, calling the receive() method of each client, passing the const poi...
Definition: SampleSourceSupport.cc:141
void addSampleClientForTag(SampleClient *c, const SampleTag *)
Add a SampleClient to this SampleSource.
Definition: SampleSourceSupport.cc:101
virtual void removeAll()
Big cleanup.
Definition: SampleClientList.cc:80
std::list< const SampleTag * > _sampleTags
Definition: SampleSourceSupport.h:168
A source of samples.
Definition: SampleStats.h:41
std::set< SampleClient * > _clientSet
Definition: SampleSourceSupport.h:180
virtual ~SampleSourceSupport()
Definition: SampleSourceSupport.h:58
bool _raw
Definition: SampleSourceSupport.h:186
SampleSourceSupport(bool raw)
Definition: SampleSourceSupport.cc:37
int getClientCount() const
How many SampleClients are currently in my list.
Definition: SampleSourceSupport.cc:136
std::list< const SampleTag * > getSampleTags() const
What SampleTags am I a SampleSource for?
Definition: SampleSourceSupport.cc:54
A C++ wrapper for a POSIX mutex.
Definition: ThreadSupport.h:154
SampleSource * getProcessedSampleSource()
Several objects in NIDAS can be both a SampleSource of raw Samples and processed Samples.
Definition: SampleSourceSupport.h:66
bool _keepStats
Definition: SampleSourceSupport.h:188
void unlock()
Unlock the Mutex.
Definition: ThreadSupport.h:218
void addSampleTag(const SampleTag *tag)
Add a SampleTag to this SampleSource.
Definition: SampleSourceSupport.cc:60
void flush()
This implementation of SampleSource::flush() does nothing.
Definition: SampleSourceSupport.h:147