nidas v1.2.3
FileSet.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_FILESET_H
28#define NIDAS_CORE_FILESET_H
29
30#include "IOChannel.h"
31#include "FsMount.h"
32
33#include <nidas/util/FileSet.h>
34
35#include <iostream>
36
37namespace nidas { namespace core {
38
42class FileSet: public IOChannel {
43
44public:
45
46 FileSet();
47
53
54 ~FileSet();
55
57 {
58 return 30;
59 }
60
61 // virtual nidas::util::FileSet& getNUFileSet() { return *_fset; }
62
63 bool isNewInput() const { return _fset->isNewFile(); }
64
65 const std::string& getName() const;
66
72 void setDir(const std::string& val);
73
79 void setFileName(const std::string& val);
80
85
90
94 void setNonBlocking(bool val)
95 {
96 if (val) PLOG(("%s: setNonBlocking(true) not implemented",
97 getName().c_str()));
98 }
99
103 bool isNonBlocking() const
104 {
105 return false;
106 }
107
111 void setMount(FsMount* val) { _mount = val; }
112
116 void mounted();
117
121 FileSet* clone() const
122 {
123 return new FileSet(*this);
124 }
125
129 dsm_time_t createFile(dsm_time_t t, bool exact);
130
134 size_t read(void* buf, size_t len)
135 {
136 return _fset->read(buf,len);
137 }
138
142 size_t write(const void* buf, size_t len)
143 {
144#ifdef DEBUG
145 std::cerr << getName() << " write, len=" << len << std::endl;
146#endif
147 return _fset->write(buf,len);
148 }
149
153 size_t write(const struct iovec* iov, int iovcnt)
154 {
155 return _fset->write(iov,iovcnt);
156 }
157
161 void close();
162
163 int getFd() const {
164 return _fset->getFd();
165 }
166
170 void fromDOMElement(const xercesc::DOMElement* node);
171
175 const std::string& getCurrentName() const
176 {
177 return _fset->getCurrentName();
178 }
179
181 {
182 _fset->setStartTime(val);
183 }
184
186 {
187 return _fset->getStartTime();
188 }
189
191 {
192 _fset->setEndTime(val);
193 }
194
196 {
197 return _fset->getStartTime();
198 }
199
203 void setFileLengthSecs(int val)
204 {
206 }
207
209 {
210 return _fset->getFileLengthSecs();
211 }
212
213 void addFileName(const std::string& val)
214 {
215 _fset->addFileName(val);
216 }
217
221 long long getFileSize() const
222 {
223 return _fset->getFileSize();
224 }
225
230 int getLastErrno() const
231 {
232 return _fset->getLastErrno();
233 }
234
239 void
240 setKeepOpening(bool keepopening)
241 {
242 _fset->setKeepOpening(keepopening);
243 }
244
245 bool
247 {
248 return _fset->keepOpening();
249 }
250
260 static FileSet* getFileSet(const std::list<std::string>& filenames);
261
262protected:
263
267 FileSet(const FileSet& x);
268
270
275 void setName(const std::string& val);
276
277 std::string _name;
278
280
282
283private:
288};
289
290}} // namespace nidas namespace core
291
292#endif
Implementation of an IOChannel using an nidas::util::FileSet.
Definition FileSet.h:42
FsMount * _mount
Definition FileSet.h:281
nidas::util::UTime getEndTime() const
Definition FileSet.h:195
const std::string & getName() const
Definition FileSet.cc:64
void setStartTime(const nidas::util::UTime &val)
Definition FileSet.h:180
void requestConnection(IOChannelRequester *requester)
Definition FileSet.cc:102
FileSet()
Definition FileSet.cc:41
int getFileLengthSecs() const
Definition FileSet.h:208
~FileSet()
Definition FileSet.cc:58
FileSet & operator=(const FileSet &)
No assignment.
const std::string & getCurrentName() const
Get name of current file.
Definition FileSet.h:175
dsm_time_t createFile(dsm_time_t t, bool exact)
Definition FileSet.cc:127
void fromDOMElement(const xercesc::DOMElement *node)
Definition FileSet.cc:134
size_t write(const struct iovec *iov, int iovcnt)
Definition FileSet.h:153
std::string _name
Definition FileSet.h:277
void setMount(FsMount *val)
FileSet will own the FsMount.
Definition FileSet.h:111
long long getFileSize() const
Definition FileSet.h:221
void setEndTime(const nidas::util::UTime &val)
Definition FileSet.h:190
void setDir(const std::string &val)
Set the directory portion of the file search path.
Definition FileSet.cc:85
size_t read(void *buf, size_t len)
Definition FileSet.h:134
IOChannel * connect()
Definition FileSet.cc:95
void setFileName(const std::string &val)
Set the file portion of the file search path.
Definition FileSet.cc:75
void setName(const std::string &val)
Recognizeable name of this IOChannel - used for informative messages.
Definition FileSet.cc:70
void mounted()
This method is called by FsMount when it is done.
Definition FileSet.cc:113
void addFileName(const std::string &val)
Definition FileSet.h:213
bool isNewInput() const
Some IOChannels, namely FileSet, which opens successive files, need to indicate when a read is from t...
Definition FileSet.h:63
int getFd() const
Definition FileSet.h:163
IOChannelRequester * _requester
Definition FileSet.h:279
nidas::util::UTime getStartTime() const
Definition FileSet.h:185
int getLastErrno() const
Get last error value.
Definition FileSet.h:230
FileSet * clone() const
Clone myself.
Definition FileSet.h:121
void close()
Definition FileSet.cc:118
void setFileLengthSecs(int val)
Set/get the file length in seconds.
Definition FileSet.h:203
bool isNonBlocking() const
Definition FileSet.h:103
void setKeepOpening(bool keepopening)
Set whether the FileSet should keep going to the next file when an error happens opening a file.
Definition FileSet.h:240
size_t write(const void *buf, size_t len)
Definition FileSet.h:142
void setNonBlocking(bool val)
Definition FileSet.h:94
static FileSet * getFileSet(const std::list< std::string > &filenames)
Convienence function to return a pointer to a nidas::core::FileSet, given a list of files.
Definition FileSet.cc:182
nidas::util::FileSet * _fset
Definition FileSet.h:269
bool keepOpening()
Definition FileSet.h:246
int getReconnectDelaySecs() const
Definition FileSet.h:56
Filesystem mounter/unmounter.
Definition FsMount.h:51
Interface for an object that requests connections to Inputs or Outputs.
Definition IOChannel.h:56
A channel for Input or Output of data.
Definition IOChannel.h:65
A description of a set of output files, consisting of a directory name and a file name format contain...
Definition FileSet.h:52
virtual size_t read(void *buf, size_t count)
Read from current file.
Definition FileSet.cc:290
void setFileLengthSecs(int val)
Set/get the file length in seconds.
Definition FileSet.h:115
long long getFileSize() const
Definition FileSet.cc:155
void setEndTime(const UTime &val)
Definition FileSet.h:144
bool isNewFile() const
Definition FileSet.h:92
int getFileLengthSecs() const
Definition FileSet.h:123
virtual size_t write(const void *buf, size_t count)
Write to current file.
Definition FileSet.cc:305
const std::string & getCurrentName() const
Get name of current file.
Definition FileSet.h:151
int getFd() const
Definition FileSet.h:90
int getLastErrno() const
Get last error value.
Definition FileSet.h:252
void setKeepOpening(bool keepopening)
Set whether the FileSet should keep going to the next file when an error happens opening a file.
Definition FileSet.h:262
bool keepOpening()
Definition FileSet.h:268
UTime getStartTime() const
Definition FileSet.h:142
virtual void addFileName(const std::string &val)
Definition FileSet.h:110
void setStartTime(const UTime &val)
Definition FileSet.h:140
A class for parsing, formatting and doing operations on time, based on Unix time conventions,...
Definition UTime.h:95
#define PLOG(MSG)
Definition Logger.h:312
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
Root namespace for the NCAR In-Situ Data Acquisition Software.
Definition A2DConverter.h:31
int len
Definition sing.cc:948