]> git.uio.no Git - u/mrichter/AliRoot.git/blob - HLT/SampleLib/AliHLTAgentSample.cxx
- introduced module Ids for agents
[u/mrichter/AliRoot.git] / HLT / SampleLib / AliHLTAgentSample.cxx
1 // @(#) $Id$
2
3 /**************************************************************************
4  * This file is property of and copyright by the ALICE HLT Project        * 
5  * ALICE Experiment at CERN, All rights reserved.                         *
6  *                                                                        *
7  * Primary Authors: Matthias Richter <Matthias.Richter@ift.uib.no>        *
8  *                  for The ALICE HLT Project.                            *
9  *                                                                        *
10  * Permission to use, copy, modify and distribute this software and its   *
11  * documentation strictly for non-commercial purposes is hereby granted   *
12  * without fee, provided that the above copyright notice appears in all   *
13  * copies and that both the copyright notice and this permission notice   *
14  * appear in the supporting documentation. The authors make no claims     *
15  * about the suitability of this software for any purpose. It is          *
16  * provided "as is" without express or implied warranty.                  *
17  **************************************************************************/
18
19 /** @file   AliHLTAgentSample.cxx
20     @author Matthias Richter
21     @date   
22     @brief  Agent of the libAliHLTSample library
23 */
24
25 #include <cassert>
26 #include "AliHLTAgentSample.h"
27 #include "AliHLTConfiguration.h"
28 #include "TSystem.h"
29
30 // header files of library components
31 #include "AliHLTDummyComponent.h"
32 #include "AliHLTSampleComponent1.h"
33 #include "AliHLTSampleComponent2.h"
34
35 // header file of the module preprocessor
36 #include "AliHLTSamplePreprocessor.h"
37
38 /** global instance for agent registration */
39 AliHLTAgentSample gAliHLTAgentSample;
40
41 const char* AliHLTAgentSample::fgkAliHLTAgentSampleData="/tmp/testdata";
42 const char* AliHLTAgentSample::fgkAliHLTAgentSampleOut="/tmp/hltout";
43
44 /** ROOT macro for the implementation of ROOT specific class methods */
45 ClassImp(AliHLTAgentSample)
46
47 AliHLTAgentSample::AliHLTAgentSample()
48   :
49   AliHLTModuleAgent("Sample")
50 {
51   // see header file for class documentation
52   // or
53   // refer to README to build package
54   // or
55   // visit http://web.ift.uib.no/~kjeks/doc/alice-hlt
56 }
57
58 AliHLTAgentSample::~AliHLTAgentSample()
59 {
60   // see header file for class documentation
61
62   // delete the test data
63   ofstream dump(fgkAliHLTAgentSampleData, ios::in);
64   if (dump.good()) {
65     TString arg("rm -f ");
66     arg+=fgkAliHLTAgentSampleData;
67     gSystem->Exec(arg.Data());
68   }
69 }
70
71 int AliHLTAgentSample::CreateConfigurations(AliHLTConfigurationHandler* handler,
72                                             AliRawReader* /*rawReader*/,
73                                             AliRunLoader* /*runloader*/) const
74 {
75   // see header file for class documentation
76
77   // create some test data
78   ofstream dump(fgkAliHLTAgentSampleData, (ios::openmode)0);
79   dump << "This is just some test data for the ALICE HLT analysis example";
80   dump << "---- not copied" << endl;
81   dump.close();
82
83   if (handler) {
84     // the publisher configuration for the test data
85     TString arg("-datatype DUMMYDAT TEST -datafile ");
86     arg+=fgkAliHLTAgentSampleData;
87     HLTDebug(arg.Data());
88     handler->CreateConfiguration("sample-fp1"  , "FilePublisher", NULL , arg.Data());
89
90     // the configuration for the dummy component
91     handler->CreateConfiguration("sample-cp"   , "Dummy"        , "sample-fp1", "output_percentage 80");
92
93     // the writer configuration
94     arg="-datafile "; arg+=fgkAliHLTAgentSampleOut;
95     handler->CreateConfiguration("sample-sink1", "FileWriter"   , "sample-cp" , arg.Data());
96
97     // sample offline source
98     handler->CreateConfiguration("sample-offsrc", "AliLoaderPublisher"   , NULL , "-loader TPCLoader -tree digits -verbose");
99
100     // sample offline sink
101     handler->CreateConfiguration("sample-offsnk", "SampleOfflineDataSink"   , "sample-offsrc" , NULL);
102   }
103   return 0;
104 }
105
106 const char* AliHLTAgentSample::GetReconstructionChains(AliRawReader* /*rawReader*/,
107                                                        AliRunLoader* /*runloader*/) const
108 {
109   // see header file for class documentation
110   return "sample-sink1 sample-offsnk";
111 }
112
113 const char* AliHLTAgentSample::GetRequiredComponentLibraries() const
114 {
115   // see header file for class documentation
116   return "libAliHLTUtil.so libAliHLTSample.so";
117 }
118
119 int AliHLTAgentSample::RegisterComponents(AliHLTComponentHandler* pHandler) const
120 {
121   // see header file for class documentation
122   assert(pHandler);
123   if (!pHandler) return -EINVAL;
124   pHandler->AddComponent(new AliHLTDummyComponent);
125   pHandler->AddComponent(new AliHLTSampleComponent1);
126   pHandler->AddComponent(new AliHLTSampleComponent2);
127
128   return 0;
129 }
130
131 AliHLTModulePreprocessor* AliHLTAgentSample::GetPreprocessor()
132 {
133   // see header file for class documentation
134   return new AliHLTSamplePreprocessor;
135 }