coding conventions (Alberto)
[u/mrichter/AliRoot.git] / SHUTTLE / AliShuttleTrigger.h
1 #ifndef ALI_SHUTTLE_TRIGGER_H
2 #define ALI_SHUTTLE_TRIGGER_H
3
4 /* Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
5  * See cxx source for full Copyright notice                               */
6
7 /* $Id$ */
8
9 //
10 // This class is to deal with DAQ LogBook and DAQ end run notification.
11 // It executes AliShuttle for retrieval of conditions data.
12 // For more info see AliShuttleTrigger.cxx
13 //
14
15 #include <TObject.h>
16 #include <TSysEvtHandler.h>
17 #include <TMutex.h>
18 #include <TCondition.h>
19
20
21 class AliCDBStorage;
22 class AliShuttle;
23 class AliShuttleConfig;
24
25 class AliShuttleTrigger;
26 class DATENotifier;
27
28 class TerminateSignalHandler: public TSignalHandler {
29         
30 public:
31         TerminateSignalHandler(): TSignalHandler((ESignals) 0,0), fTrigger(0) { }
32         TerminateSignalHandler(AliShuttleTrigger* trigger, ESignals signal):
33                 TSignalHandler(signal, kFALSE), fTrigger(trigger) {}
34
35         virtual ~TerminateSignalHandler() { }
36         virtual Bool_t Notify();
37
38 private:
39
40         TerminateSignalHandler(const TerminateSignalHandler& other);    
41         TerminateSignalHandler& operator= (const TerminateSignalHandler& other);        
42
43         AliShuttleTrigger* fTrigger;  // pointer to the current AliShuttleTrigger
44
45         ClassDef(TerminateSignalHandler, 0)
46 };
47
48 class AliShuttleTrigger: public TObject {
49 public:
50         AliShuttleTrigger(const AliShuttleConfig* config, UInt_t timeout = 5000, Int_t retries = 5);
51         ~AliShuttleTrigger();
52
53         AliShuttle* GetShuttle() {return fShuttle;}
54
55         Bool_t Collect(Int_t run);
56         Bool_t CollectNew();
57         Bool_t CollectAll();
58         
59         virtual Bool_t Notify();
60         void Terminate();
61
62         void Run();
63
64 private:
65
66         AliShuttleTrigger(const AliShuttleTrigger& other);
67         AliShuttleTrigger& operator= (const AliShuttleTrigger& other);
68
69         class AliShuttleTriggerDATEEntry: public TObject {
70         public:
71                 AliShuttleTriggerDATEEntry(Int_t run, UInt_t startTime, UInt_t endTime):
72                         fRun(run), fStartTime(startTime), fEndTime(endTime) {}
73
74                 Int_t GetRun() const {return fRun;}
75                 UInt_t GetStartTime() const  {return fStartTime;}
76                 UInt_t GetEndTime() const {return fEndTime;}
77
78         private:
79                 Int_t fRun;             // Run number
80                 UInt_t fStartTime;      // Run start time
81                 UInt_t fEndTime;        // Run end time
82                 ClassDef(AliShuttleTriggerDATEEntry, 0)
83         };
84
85         Bool_t RetrieveDATEEntries(const char* whereClause, TObjArray& entries,
86                         Int_t& lastRun);
87         Bool_t RetrieveConditionsData(const TObjArray& dateEntries);
88
89         const AliShuttleConfig* fConfig;
90         //AliCDBStorage* fLocalStorage;
91
92         AliShuttle* fShuttle;           // Pointer to the actual Shuttle instance
93
94         Bool_t fNotified;               // Notified flag
95         Bool_t fTerminate;              // Terminate flag
96
97         TMutex fMutex;                  // Mutex
98         TCondition fCondition;          // Condition 
99
100         TerminateSignalHandler fQuitSignalHandler;              // Quit signal 
101         TerminateSignalHandler fInterruptSignalHandler;         // Interrupt signal
102
103
104         ClassDef(AliShuttleTrigger, 0)
105 };
106
107 #endif