]> git.uio.no Git - u/mrichter/AliRoot.git/blob - HLT/BASE/AliHLTControlTask.cxx
changes for the GPU code
[u/mrichter/AliRoot.git] / HLT / BASE / AliHLTControlTask.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   AliHLTControlTask.cxx
20     @author Matthias Richter
21     @date   
22     @brief  Special task to produce the control events.
23 */
24
25 #include "AliHLTControlTask.h"
26 #include "AliHLTComponentHandler.h"
27 #include <cassert>
28
29 /** ROOT macro for the implementation of ROOT specific class methods */
30 ClassImp(AliHLTControlTask)
31
32 AliHLTControlTask::AliHLTControlTask()
33   :
34   fEvent(kAliHLTVoidDataType),
35   fSpecification(kAliHLTVoidDataSpec),
36   fpData(NULL),
37   fSize(0)
38 {
39   // see header file for class documentation
40   // or
41   // refer to README to build package
42   // or
43   // visit http://web.ift.uib.no/~kjeks/doc/alice-hlt
44 }
45
46 AliHLTControlTask::~AliHLTControlTask()
47 {
48   // see header file for class documentation
49 }
50
51 int AliHLTControlTask::CreateComponent(AliHLTConfiguration* /*pConf*/, AliHLTComponentHandler* pCH, AliHLTComponent*& pComponent) const
52 {
53   // see header file for class documentation
54   int iResult=0;
55   if ((pComponent=new AliHLTControlEventComponent(this))) {
56     const AliHLTAnalysisEnvironment* pEnv=pCH->GetEnvironment();
57     if ((iResult=pComponent->Init(pEnv, NULL, 0, NULL))>=0) {
58       //HLTDebug("component %s (%p) created", pComponent->GetComponentID(), pComponent); 
59     } else {
60       HLTError("Initialization of component \"%s\" failed with error %d", pComponent->GetComponentID(), iResult);
61     }
62     return iResult;
63   }
64   return -ENOMEM;
65 }
66
67 AliHLTControlTask::AliHLTControlEventComponent::AliHLTControlEventComponent(const AliHLTControlTask* pParent)
68   :
69   fpParent(pParent)
70 {
71   // see header file for class documentation
72   assert(pParent);
73 }
74
75 AliHLTControlTask::AliHLTControlEventComponent::~AliHLTControlEventComponent()
76 {
77   // see header file for class documentation
78 }
79
80 AliHLTComponentDataType AliHLTControlTask::AliHLTControlEventComponent::GetOutputDataType()
81 {
82   // see header file for class documentation
83   return kAliHLTMultipleDataType;
84 }
85
86 int AliHLTControlTask::AliHLTControlEventComponent::GetOutputDataTypes(AliHLTComponentDataTypeList& tgtList)
87 {
88   // see header file for class documentation
89   tgtList.clear();
90   tgtList.push_back(kAliHLTDataTypeSOR);
91   tgtList.push_back(kAliHLTDataTypeEOR);
92   return tgtList.size();
93 }
94
95 void AliHLTControlTask::AliHLTControlEventComponent::GetOutputDataSize( unsigned long& constBase, double& inputMultiplier )
96 {
97   // see header file for class documentation
98   if (fpParent && fpParent->fSize>0) constBase=fpParent->fSize;
99   else constBase=sizeof(AliHLTRunDesc);
100   inputMultiplier=0;
101 }
102
103 int AliHLTControlTask::AliHLTControlEventComponent::GetEvent(const AliHLTComponentEventData& /*evtData*/,
104                                                              AliHLTComponentTriggerData& /*trigData*/,
105                                                              AliHLTUInt8_t* outputPtr, 
106                                                              AliHLTUInt32_t& size,
107                                                              vector<AliHLTComponentBlockData>& outputBlocks )
108 {
109   // see header file for class documentation
110   if (!fpParent) return -ENODEV;
111   const AliHLTControlTask* pParent=fpParent;
112   if (size<pParent->fSize) {
113     return -ENOSPC;
114   }
115
116   if (pParent->fpData && pParent->fSize) {
117     memcpy(outputPtr, pParent->fpData, pParent->fSize);
118   }
119
120   // return if no event has been set
121   if (pParent->fEvent==kAliHLTVoidDataType) {
122     //HLTInfo("no control event to send");
123     return 0;
124   }
125
126   HLTDebug("publishing control event %s", DataType2Text(pParent->fEvent).c_str());
127   AliHLTComponentBlockData bd;
128   FillBlockData(bd);
129   bd.fOffset=0;
130   bd.fSize=pParent->fSize;
131   bd.fDataType=pParent->fEvent;
132   bd.fSpecification=pParent->fSpecification;
133   outputBlocks.push_back( bd );
134
135   return bd.fSize;
136 }