major change in the external component interface: redesigned and moved to libHLTinter...
[u/mrichter/AliRoot.git] / HLT / BASE / util / AliHLTDataGenerator.h
1 // -*- Mode: C++ -*-
2 // $Id$
3
4 #ifndef ALIHLTDATAGENERATOR_H
5 #define ALIHLTDATAGENERATOR_H
6 //* This file is property of and copyright by the ALICE HLT Project        * 
7 //* ALICE Experiment at CERN, All rights reserved.                         *
8 //* See cxx source for full Copyright notice                               *
9
10 /** @file   AliHLTDataGenerator.h
11     @author Matthias Richter
12     @date   
13     @brief  An HLT file publishing (data source) component.
14     @note   The class is used in Offline (AliRoot) context
15 */
16
17 #include "AliHLTProcessor.h"
18
19 /**
20  * @class AliHLTDataGenerator
21  * An HLT data source component to produce random data.
22  *
23  * Component ID: \b DataGenerator <br>
24  * Library: \b libAliHLTUtil.
25  *
26  * Mandatory arguments: <br>
27  * <!-- NOTE: ignore the \li. <i> and </i>: it's just doxygen formatting -->
28  * \li -datatype     <i> datatype   dataorigin </i> <br>
29  *      data type ID and origin, e.g. <tt>-datatype 'CLUSTERS' 'TPC ' </tt>
30  * \li -dataspec     <i> specification </i> <br>
31  *      data specification treated as decimal number or hex number if
32  *      prepended by '0x'
33  * \li -minsize      <i> size </i> <br>
34  *      the minimum size of the data to be produced
35  * \li -maxsize      <i> size </i> <br>
36  *      the maximum size of the data to be produced, default = minsize
37  *
38  * Optional arguments:<br>
39  * \li -divisor <i> m </i> <br>
40  *      a divisor to shrink the size after \em modulo events
41  * \li -offset <i> m </i> <br>
42  *      an offset to subtract from the size after \em modulo events
43  * \li -modulo <i> n </i> <br>
44  *      size manipulated by the disisor or subtractor after \em n events
45  *
46  * The component produces data blocks of random content and random size in the
47  * range of [\em minsize , \em maxsize ]. The size arguments can contain 'k' or
48  * 'M' to indicate kByte or MByte.
49  *
50  * @ingroup alihlt_util_components
51  */
52 class AliHLTDataGenerator : public AliHLTProcessor  {
53  public:
54   /** standard constructor */
55   AliHLTDataGenerator();
56   /** destructor */
57   virtual ~AliHLTDataGenerator();
58
59   const char* GetComponentID();
60   void GetInputDataTypes( AliHLTComponentDataTypeList& list);
61   AliHLTComponentDataType GetOutputDataType();
62   int GetOutputDataTypes(vector<AliHLTComponentDataType>& tgtList);
63   void GetOutputDataSize( unsigned long& constBase, double& inputMultiplier );
64   AliHLTComponent* Spawn();
65
66  protected:
67   int DoInit( int argc, const char** argv );
68   int DoDeinit();
69   int DoEvent( const AliHLTComponentEventData& evtData,
70                const AliHLTComponentBlockData* blocks, 
71                AliHLTComponentTriggerData& trigData,
72                AliHLTUInt8_t* outputPtr, 
73                AliHLTUInt32_t& size,
74                AliHLTComponentBlockDataList& outputBlocks );
75
76   using AliHLTProcessor::DoEvent;
77
78   /**
79    * Scan one argument and adjacent parameters.
80    * Can be overloaded by child classes in order to add additional arguments
81    * beyond the standard arguments of the file publisher. The method is called
82    * whenever a non-standard argument is recognized.
83    * @param argc           size of the argument array
84    * @param argv           agument array for component initialization
85    * @return number of processed members of the argv <br>
86    *         -EINVAL unknown argument <br>
87    *         -EPROTO parameter for argument missing <br>
88    */
89   virtual int ScanArgument(int argc, const char** argv);
90
91  protected:
92   /**
93    * Scan a size argument.
94    * The argument is expected to be an integer, which can be suffixed by 'k'
95    * or 'M' in order to indicate the base, kByte or MByte.
96    * @param size      target to store the size
97    * @param arg       the argument to scan
98    */
99   int ScanSizeArgument(AliHLTUInt32_t &size, const char* arg);
100
101   /**
102    * Scan a float argument.
103    * @param value     target to store the size
104    * @param arg       the argument to scan
105    */
106   int ScanFloatArgument(float &value, const char* arg);
107
108  private:
109   /** prohibit copy constructor */
110   AliHLTDataGenerator(const AliHLTDataGenerator&);
111   /** prohibit assignment operator */
112   AliHLTDataGenerator& operator=(const AliHLTDataGenerator&);
113
114   /** data type */
115   AliHLTComponentDataType fDataType;                                //! transient
116
117   /** specification */
118   AliHLTUInt32_t fSpecification;                                    //! transient
119
120   // mode 1: just fake data independent of the input data
121
122   /** the original size size */
123   AliHLTUInt32_t fSize;                                             //! transient
124   /** the manipulated size */
125   AliHLTUInt32_t fCurrSize;                                         //! transient
126   /** divisor: each modulo event ignoring the input data size) */
127   AliHLTUInt32_t fDivisor;                                          //! transient
128   /** decrement: each modulo event ignoring the input data size */
129   AliHLTUInt32_t fDecrement;                                        //! transient
130   /** modulo for size manipulation */
131   AliHLTUInt32_t fModulo;                                           //! transient
132
133   // mode 2: generate data depending on input data size
134
135   /** offset (generation of data from input data size) */
136   AliHLTUInt32_t fOffset;                                           //! transient
137   /** multiplier (generation of data from input data size) */
138   float fMultiplier;                                                //! transient
139
140   /** range: +/- *size */
141   float fRange;                                                     //! transient
142
143   ClassDef(AliHLTDataGenerator, 0)
144 };
145 #endif