Commit f33edf8c authored by legoc's avatar legoc

Readded SimpleReader.cpp for doc.

parent a7a8a8ed
......@@ -6,6 +6,9 @@ bin_PROGRAMS = \
lstheader128 \
lstboardinfo128
noinst_LIBRARIES = \
liblstsimplereader128.a
libs = ../../liblstdpp128.la
lstcalibrateinsert128_SOURCES = \
......@@ -54,3 +57,10 @@ lstboardinfo128_SOURCES = \
lstboardinfo128_CPPFLAGS = $(LST_CXXFLAGS)
lstboardinfo128_LDFLAGS = $(LST_LDFLAGS)
lstboardinfo128_LDADD = $(libs) $(LST_LIBS)
liblstsimplereader128_a_SOURCES = \
SimpleReader.cpp
liblstsimplereader128_a_CPPFLAGS = $(LST_CXXFLAGS)
/*
* Nomad Instrument Control Software
*
* Copyright 2011 Institut Laue-Langevin
*
* Licensed under the EUPL, Version 1.1 only (the "License");
* You may not use this work except in compliance with the Licence.
* You may obtain a copy of the Licence at:
*
* http://www.osor.eu/eupl
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the Licence is distributed on an "AS IS" basis,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the Licence for the specific language governing permissions and
* limitations under the Licence.
*/
#include <iostream>
#include <cstdlib>
#include "../../Event.h"
#include "../../Reader.h"
using namespace std;
using namespace lstdpp128;
void process(int32_t * buffer, int32_t size) {
// The argument size is in words of 32bits.
// Iterate the buffer by 4 words of 32bits.
int32_t index = 0;
int32_t nbIndex = size;
int32_t * bufferPtr = buffer;
// Loop until all the words are read.
while (index < nbIndex) {
// Read an event.
Event event;
if (readEvent(event, bufferPtr + index)) {
// Print the event.
cout << event << endl;
}
// Advance by 4 because the words are 32bits (4 x 32 = 128bits, the size of an event).
index += 4;
}
}
int main(int argc, char * argv[]) {
if (argc < 2) {
cerr << "usage : lstsimplereader128 <file>" << endl;
return EXIT_FAILURE;
}
// Initialize a reader with a buffer of size 1024.
Reader reader(1024);
// Open the file.
bool success = reader.open(argv[1]);
// Exit in case of error.
if (!success) {
return EXIT_FAILURE;
}
// Print the context.
cout << listModeContext << endl;
// Read the blocks until we read nothing.
while (true) {
// Read the next block.
int32_t size = reader.read();
// Exit if the block is empty.
if (size == 0) {
break;
}
// Process the buffer.
process(reader.buffer(), size);
}
return EXIT_SUCCESS;
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment