Download Pelican User Guide

Transcript
3.3 Importing Data II: The Server, Client and Data Adapters
15
Currently there is no easy way to assign adapters programmatically although this feature is likely to be available in
the next release.
3.3.4
Adapters
Adapters are the final components of the data-import chain, and provide a mechanism to convert chunks of raw
binary data into the data members of a Pelican data-blob (a specialised C++ container for holding data used by
the Pelican pipeline; see below). The most basic function of an adapter is to de-serialise chunks of data, although
re-ordering and re-factoring of the data to a form that is convenient for subsequent pipeline processing may also be
carried out. Pelican currently provides support for two categories of adapters, distinguished by the type of input data
chunks they are expected to process: these are stream data adapters and service data adapters, which operate on
the relevant data types.
Adapters can be configured, if required, using parameters specified in the XML configuration file. An adapter must
inherit either the AbstractStreamAdapter or the AbstractServiceAdapter class interface, depending on its type.
3.3.4.1
Data-Blobs
A Pelican data-blob is a well-structured representation of data that has been arranged for easy, optimal processing:
the output from an adapter is a well-structured representation of the data held in a chunk, which is ready to be
processed by a pipeline. Data-blobs may contain arrays, blocks of memory and/or other metadata, and should
provide methods to interact with that data. One of their main functions is to act as an interface between pipeline
modules.
3.3.4.2
Tutorial Data-Blob
For the purpose of our tutorial, we need a type of DataBlob that can hold the required time-series data in a chunk.
This is implemented in the SignalData data-blob, shown below, as a simple contiguous float array (a standard C++
vector). Public methods allow this array to be resized, and should be used to obtain a pointer to the start of the data
so that elements can be accessed efficiently.
#ifndef SIGNALDATA_H
#define SIGNALDATA_H
#include "data/DataBlob.h"
#include <vector>
using namespace pelican;
/*
* This data blob holds an array of floating-point time-stream data.
*/
class SignalData : public DataBlob
{
public:
// Constructs a signal data blob.
SignalData() : DataBlob("SignalData") {}
// Returns a const pointer to the start of the data.
const float* ptr() const {return (_data.size() > 0 ? &_data[0] : NULL);
}
// Returns a pointer to the start of the data.
float* ptr() { return (_data.size() > 0 ? &_data[0] : NULL); }
// Resizes the data store provided by the data blob.
void resize(unsigned length) { _data.resize(length); }
// Returns the size of the data.
unsigned size() const { return _data.size(); }
private:
std::vector<float> _data; // The actual data array.
};
PELICAN_DECLARE_DATABLOB(SignalData)
#endif // SIGNALDATA_H
Generated on Tue Jan 22 2013 11:07:31 for Pelican User Guide by Doxygen