81929b85 |
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 "AliHLTDataSource.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 formating --> |
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 -disisor <i> m </i> <br> |
40 | * a disisor 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 | * @ingroup alihlt_component |
50 | */ |
51 | class AliHLTDataGenerator : public AliHLTDataSource { |
52 | public: |
53 | /** standard constructor */ |
54 | AliHLTDataGenerator(); |
55 | /** destructor */ |
56 | virtual ~AliHLTDataGenerator(); |
57 | |
58 | const char* GetComponentID(); |
59 | AliHLTComponentDataType GetOutputDataType(); |
60 | int GetOutputDataTypes(vector<AliHLTComponentDataType>& /*tgtList*/); |
61 | void GetOutputDataSize( unsigned long& constBase, double& inputMultiplier ); |
62 | AliHLTComponent* Spawn(); |
63 | |
64 | protected: |
65 | /** |
66 | * Init method. |
67 | */ |
68 | int DoInit( int argc, const char** argv ); |
69 | |
70 | /** |
71 | * Deinit method. |
72 | */ |
73 | int DoDeinit(); |
74 | |
75 | /** |
76 | * Data processing method for the component. |
77 | * @param evtData event data structure |
78 | * @param trigData trigger data structure |
79 | * @param outputPtr pointer to target buffer |
80 | * @param size <i>input</i>: size of target buffer |
81 | * <i>output</i>:size of produced data |
82 | * @param outputBlocks list to receive output block descriptors |
83 | * @return |
84 | */ |
85 | int GetEvent( const AliHLTComponentEventData& evtData, |
86 | AliHLTComponentTriggerData& trigData, |
87 | AliHLTUInt8_t* outputPtr, |
88 | AliHLTUInt32_t& size, |
89 | vector<AliHLTComponentBlockData>& outputBlocks ); |
90 | |
91 | /** |
92 | * Scan one argument and adjacent parameters. |
93 | * Can be overloaded by child classes in order to add additional arguments |
94 | * beyond the standard arguments of the file publisher. The method is called |
95 | * whenever a non-standard argument is recognized. |
96 | * @param argc size of the argument array |
97 | * @param argv agument array for component initialization |
98 | * @return number of processed members of the argv <br> |
99 | * -EINVAL unknown argument <br> |
100 | * -EPROTO parameter for argument missing <br> |
101 | */ |
102 | virtual int ScanArgument(int argc, const char** argv); |
103 | |
104 | protected: |
105 | /** |
106 | * Scan a size argument. |
107 | * The argument is expected to be an integer, which can be suffixed by 'k' |
108 | * or 'M' in order to indicate the base, kByte or MByte. |
109 | * @param size target to store the size |
110 | * @param arg the argument to scan |
111 | */ |
112 | int ScanSizeArgument(AliHLTUInt32_t &size, const char* arg); |
113 | |
114 | private: |
115 | /** prohibit copy constructor */ |
116 | AliHLTDataGenerator(const AliHLTDataGenerator&); |
117 | /** prohibit assignment operator */ |
118 | AliHLTDataGenerator& operator=(const AliHLTDataGenerator&); |
119 | |
120 | /** data type */ |
121 | AliHLTComponentDataType fDataType; //! transient |
122 | |
123 | /** specification */ |
124 | AliHLTUInt32_t fSpecification; //! transient |
125 | |
126 | /** the original size size */ |
127 | AliHLTUInt32_t fSize; //! transient |
128 | |
129 | /** the manipulated size */ |
130 | AliHLTUInt32_t fCurrSize; //! transient |
131 | |
132 | /** range */ |
133 | AliHLTUInt32_t fRange; //! transient |
134 | |
135 | /** divisor */ |
136 | AliHLTUInt32_t fDivisor; //! transient |
137 | |
138 | /** subtractor */ |
139 | AliHLTUInt32_t fSubtractor; //! transient |
140 | |
141 | /** modulo for size manipulation */ |
142 | AliHLTUInt32_t fModulo; //! transient |
143 | |
144 | ClassDef(AliHLTDataGenerator, 0) |
145 | }; |
146 | #endif |