nidas  v1.2-1520
SampleOutputRequestThread.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_SAMPLEOUTPUTREQUESTTHREAD_H
28 #define NIDAS_CORE_SAMPLEOUTPUTREQUESTTHREAD_H
29 
30 #include <list>
31 
32 #include "SampleOutput.h"
33 #include <nidas/util/Thread.h>
34 
35 namespace nidas { namespace core {
36 
41 {
42 public:
43 
49 
53  static void destroyInstance();
54 
55  int run() throw(nidas::util::Exception);
56 
60  void interrupt();
61 
65  void clear();
66 
71 
77 
79  public:
81  _output(o),_requester(r),_when(when)
82  {
83  }
86  time_t _when;
87  };
88 
89 private:
90 
92 
94 
96 
98 
99  std::list<ConnectRequest> _connectRequests;
100 
101  std::list<SampleOutput*> _disconnectRequests;
102 
104 
105 };
106 
107 }} // namespace nidas namespace core
108 
109 #endif
110 
Interface for an object that requests connections SampleOutputs.
Definition: ConnectionRequester.h:42
~SampleOutputRequestThread()
Definition: SampleOutputRequestThread.h:93
Interface of an output stream of samples.
Definition: SampleOutput.h:47
static void destroyInstance()
Singleton destructor.
Definition: SampleOutputRequestThread.cc:54
Definition: SampleOutputRequestThread.h:78
int run()
The method which will run in its own thread.
Definition: SampleOutputRequestThread.cc:127
SampleOutputRequestThread()
Definition: SampleOutputRequestThread.cc:74
static nidas::util::Mutex _instanceLock
Definition: SampleOutputRequestThread.h:97
SampleConnectionRequester * _requester
Definition: SampleOutputRequestThread.h:85
Interface of an output stream of samples.
Definition: SampleOutputRequestThread.h:40
static SampleOutputRequestThread * getInstance()
Return pointer to instance of singleton, creating instance if necessary.
Definition: SampleOutputRequestThread.cc:44
void addDeleteRequest(SampleOutput *)
Request that SampleOutputRequestThread delete the output when it can.
Definition: SampleOutputRequestThread.cc:95
Definition: Exception.h:35
std::list< ConnectRequest > _connectRequests
Definition: SampleOutputRequestThread.h:99
Definition: Thread.h:80
void addConnectRequest(SampleOutput *, SampleConnectionRequester *, int delaySecs)
Add an connect request of a SampleOutput.
Definition: SampleOutputRequestThread.cc:80
nidas::util::Cond _requestCond
Definition: SampleOutputRequestThread.h:103
std::list< SampleOutput * > _disconnectRequests
Definition: SampleOutputRequestThread.h:101
void interrupt()
Interrupt the thread.
Definition: SampleOutputRequestThread.cc:120
A wrapper class for a Posix condition variable.
Definition: ThreadSupport.h:245
ConnectRequest(SampleOutput *o, SampleConnectionRequester *r, time_t when)
Definition: SampleOutputRequestThread.h:80
void clear()
Clear all current requests.
Definition: SampleOutputRequestThread.cc:103
SampleOutput * _output
Definition: SampleOutputRequestThread.h:84
static SampleOutputRequestThread * _instance
Definition: SampleOutputRequestThread.h:95
A C++ wrapper for a POSIX mutex.
Definition: ThreadSupport.h:154
time_t _when
Definition: SampleOutputRequestThread.h:86