15 #include <tr1/functional>
17 #include <QStringList>
18 #include <QtCore/QFileInfo>
34 void MultiFileInput::instance(
const string& filelistname,
41 throw logic_error(
"MultiFileInput::instance(): The instance of the base class is already initialized");
45 MultiFileInput::MultiFileInput(
const string& filelistname,
50 :
InputBase(ringbuffer,ratemeter,loadmeter,parent),
51 _quitWhenDone(quitWhenDone),
52 _filelistname(filelistname),
66 _new = s.
value(
"UseNewContainer",
false).toBool()?
"_new" :
"";
75 rbItem->element->id() = eventIt->first;
78 positionreaders_t::iterator fileposread(posreaders.begin());
79 positionreaders_t::const_iterator posreadEnd(posreaders.end());
80 for (; (!
shouldQuit()) && (fileposread != posreadEnd); ++fileposread)
84 ifstream &filestream(filepointer.
getStream());
85 isGood =
read(filestream,*rbItem->element) && isGood;
104 vector<FileParser::shared_pointer> parsercontainer;
115 if (!filelistfile.is_open())
116 throw invalid_argument(
"MultiFileInput::run(): filelist '"+
_filelistname +
117 "' could not be opened");
119 vector<string> filelist(tokenize(filelistfile));
120 vector<string>::const_iterator filelistIt(filelist.begin());
121 vector<string>::const_iterator filelistEnd(filelist.end());
122 while ((!
shouldQuit()) && (filelistIt != filelistEnd))
124 string filename(*filelistIt++);
135 readerpointer.first->loadSettings();
136 readerpointer.first->readHeaderInfo(*fp.
_filestream);
141 readerpointer,event2posreaders,
lock));
143 parsercontainer.push_back(fileparser);
151 vector<FileParser::shared_pointer>::iterator fileparseIt(parsercontainer.begin());
152 vector<FileParser::shared_pointer>::const_iterator fileparseEnd(parsercontainer.end());
153 for (;fileparseIt!=fileparseEnd;++fileparseIt)
155 (*fileparseIt)->wait();
156 (*fileparseIt)->rethrowException();
166 event2positionreaders_t::iterator eventIt(event2posreaders.begin());
167 event2positionreaders_t::const_iterator eventEnd(event2posreaders.end());
168 while ((!
shouldQuit()) && (eventIt != eventEnd))
173 eventIt = event2posreaders.begin();
181 toString(eventIt->first) +
"' is incomplete; skipping event.");
filestream_t _filestream
the stream to the file
class calculating a rate in Hz.
sleep(unsigned long secs)
status_t _status
the internal status of the thread
file contains declaration of the CASSEvent
static shared_pointer instance(const std::string type, const filereaderpointerpair_t readerpointerpair, event2positionreaders_t &event2posreader, QReadWriteLock &lock)
create an instance of the requested type
A resource that will point at a specific location within a file.
contains base class for all file parsers
base class for all file readers
std::ifstream & getStream()
static void add(Level level, const std::string &line)
add a string to the log
fromStdString(const std::string &str)
std::tr1::shared_ptr< FileParser > shared_pointer
typedef the shared pointer of this
std::vector< filereaderpointerpair_t > positionreaders_t
map file name to the filepointer
A Ringbuffer, handles communication between Input and Worker Threads.
void read(const std::string &filename, std::string &headerstring, std::vector< float > &matrix, std::pair< int, int > &shape)
read the cbf data into a linearized 2d array
bool shouldQuit() const
query whether this thread is told to quit
std::streampos _pos
the position with the file
control_t _control
the internal control status of the thread
tokenize to return all lines of an ascii file in a vector
std::string toString(const Type &t)
convert any type to a string
std::pair< std::tr1::shared_ptr< FileReader >, FilePointer > filereaderpointerpair_t
pair of a file pointer with the associated file reader
std::tr1::shared_ptr< std::ifstream > filestream_t
defining a shared pointer to the stream
value(const QString &key, const QVariant &defaultValue=QVariant()
file contains specialized class that do the settings for cass
std::map< uint64_t, positionreaders_t > event2positionreaders_t
the list of events contained in a file with the associated position and reader
static shared_pointer instance(const std::string &filename)
create an instance of the requested type
void pausePoint()
point where the thread will be paused
contains a logger for cass
beginGroup(const QString &prefix)