Line data Source code
1 : #ifndef AliHLTObjectRenamer_h
2 : #define AliHLTObjectRenamer_h
3 :
4 : #include "AliHLTProcessor.h"
5 : #include <string>
6 : #include "TCollection.h"
7 :
8 : class AliHLTObjectRenamer : public AliHLTProcessor
9 : {
10 : public:
11 0 : AliHLTObjectRenamer() : AliHLTProcessor(), fSuffix("") {}
12 0 : virtual ~AliHLTObjectRenamer() {}
13 :
14 0 : virtual const char* GetComponentID() { return "ObjectRenamer"; }
15 0 : virtual void GetInputDataTypes( vector<AliHLTComponentDataType>& list) { list.push_back(kAliHLTAnyDataType); }
16 0 : virtual AliHLTComponentDataType GetOutputDataType() { return kAliHLTAnyDataType; }
17 :
18 : virtual void GetOutputDataSize(unsigned long& constBase, double& inputMultiplier)
19 : {
20 0 : constBase = 1024*1024;
21 0 : inputMultiplier = 1;
22 0 : }
23 :
24 0 : virtual AliHLTComponent* Spawn() { return new AliHLTObjectRenamer; }
25 :
26 : protected:
27 :
28 : virtual int DoInit(int argc, const char** argv);
29 0 : virtual int DoDeinit() { return 0; }
30 :
31 : virtual int DoEvent(const AliHLTComponentEventData& evtData, AliHLTComponentTriggerData& trigData);
32 :
33 : using AliHLTProcessor::DoEvent;
34 :
35 : private:
36 : // Do not allow copying of this class.
37 : AliHLTObjectRenamer(const AliHLTObjectRenamer&);
38 : AliHLTObjectRenamer& operator=(const AliHLTObjectRenamer&);
39 :
40 : TString fSuffix; /// Suffix to appent to object names.
41 :
42 : template <typename ListType>
43 : TObject* CloneList(const TObject* obj, const TString& suffix)
44 : {
45 0 : if (obj->IsA() == ListType::Class())
46 : {
47 0 : const ListType* oldArray = static_cast<const ListType*>(obj);
48 0 : ListType* newArray = new ListType;
49 0 : newArray->SetOwner(kTRUE);
50 0 : TIter next(oldArray);
51 : const TObject* tmpObj = NULL;
52 0 : while ((tmpObj = next()) != NULL)
53 : {
54 0 : TString name = tmpObj->GetName();
55 0 : name += suffix;
56 0 : TObject* newObj = tmpObj->Clone(name);
57 0 : newArray->Add(newObj);
58 0 : }
59 0 : return newArray;
60 0 : }
61 0 : return NULL;
62 0 : }
63 :
64 8 : ClassDef(AliHLTObjectRenamer, 0)
65 : };
66 : #endif
|