]> git.uio.no Git - u/mrichter/AliRoot.git/blob - HLT/trigger/AliHLTGlobalTrigger.cxx
Adding the trigger menu for the HLT global trigger.
[u/mrichter/AliRoot.git] / HLT / trigger / AliHLTGlobalTrigger.cxx
1 /**************************************************************************
2  * This file is property of and copyright by the ALICE HLT Project        *
3  * ALICE Experiment at CERN, All rights reserved.                         *
4  *                                                                        *
5  * Primary Authors: Artur Szostak <artursz@iafrica.com>                   *
6  *                  for The ALICE HLT Project.                            *
7  *                                                                        *
8  * Permission to use, copy, modify and distribute this software and its   *
9  * documentation strictly for non-commercial purposes is hereby granted   *
10  * without fee, provided that the above copyright notice appears in all   *
11  * copies and that both the copyright notice and this permission notice   *
12  * appear in the supporting documentation. The authors make no claims     *
13  * about the suitability of this software for any purpose. It is          *
14  * provided "as is" without express or implied warranty.                  *
15  **************************************************************************/
16
17 /// @file   AliHLTGlobalTrigger.cxx
18 /// @author Artur Szostak <artursz@iafrica.com>
19 /// @date   19 Dec 2008
20 /// @brief  Implementation of the AliHLTGlobalTrigger base class.
21 ///
22 /// The AliHLTGlobalTriggerComponent class is an abstract class from which a
23 /// derived class is constructed by AliHLTTriggerMenu on the fly. The derived
24 /// class then implements triggering based on the particular trigger menu.
25
26 #include "AliHLTGlobalTrigger.h"
27 #include "AliHLTGlobalTriggerDecision.h"
28 #include <cstring>
29
30 ClassImp(AliHLTGlobalTrigger)
31
32 // Static factory array.
33 AliHLTGlobalTrigger::Factory*
34 AliHLTGlobalTrigger::Factory::fFactory[AliHLTGlobalTrigger::Factory::kMaxFactories]
35   = {NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL};
36
37
38 AliHLTGlobalTrigger::AliHLTGlobalTrigger() :
39   fCounters()
40 {
41   // Default constructor.
42 }
43
44
45 AliHLTGlobalTrigger::~AliHLTGlobalTrigger()
46 {
47   // Default destructor.
48 }
49
50
51 AliHLTGlobalTrigger* AliHLTGlobalTrigger::Factory::CreateNew(const char* name)
52 {
53   // Creates a new instance of the named trigger class.
54   
55   for (int i = 0; i < kMaxFactories; i++)
56   {
57     if (fFactory[i] != NULL)
58     {
59       if (strcmp(fFactory[i]->ClassName(), name) == 0)
60       {
61         return fFactory[i]->New();
62       }
63     }
64   }
65   return NULL;
66 }
67
68
69 AliHLTGlobalTrigger::Factory::Factory()
70 {
71   // Default constructor resisters the class factory.
72   
73   for (int i = 0; i < kMaxFactories; i++)
74   {
75     if (fFactory[i] == NULL)
76     {
77       fFactory[i] = this;
78       return;
79     }
80   }
81   
82   HLTFatal("Trying to register too many global trigger factories.");
83 }
84
85
86 AliHLTGlobalTrigger::Factory::~Factory()
87 {
88   // The default destructor deregisters the factory.
89   
90   for (int i = 0; i < kMaxFactories; i++)
91   {
92     if (fFactory[i] == this)
93     {
94       fFactory[i] = NULL;
95       return;
96     }
97   }
98   
99   HLTFatal("Could not find factory to deregister.");
100 }
101