ROOT logo
//-*- Mode: C++ -*-
// $Id$

#ifndef ALIHLTMODULEPREPROCESSOR_H
#define ALIHLTMODULEPREPROCESSOR_H
//* This file is property of and copyright by the ALICE HLT Project        * 
//* ALICE Experiment at CERN, All rights reserved.                         *
//* See cxx source for full Copyright notice                               *

// @file   AliHLTModulePreprocessor.h
// @author Matthias Richter
// @date   2008-01-22
// @brief  Base class for HLT module preprocessors
// 

// see below for class documentation
// or
// refer to README to build package
// or
// visit http://web.ift.uib.no/~kjeks/doc/alice-hlt

#include "TObject.h"

class AliHLTPreprocessor;
class TMap;
class AliCDBMetaData;
class AliCDBEntry;
class AliHLTShuttleInterface;

/**
 * @class AliHLTModulePreprocessor
 * Implementation of the HLT version for the Shuttle Preprocessor.
 * This class implements the same interface as the AliPreprocessor and
 * allows multiple preprocessors for the HLT. All methods are redirected
 * to the AliHLTPreprocessor, which acts as the HLT preprocessor
 * to the outside, and a container for all module preprocessors to the
 * inside.
 *
 * @author Matthias Richter
 */
class AliHLTModulePreprocessor : public TObject
{
public:
  /** Constructor*/
  AliHLTModulePreprocessor();
  /** Destructor */
  virtual ~AliHLTModulePreprocessor();

  /**
   * Set the container class which is the gateway to the shuttle.
   */
  void SetShuttleInterface(AliHLTShuttleInterface* pInterface);

  /**
   * Initialize the Preprocessor.
   *
   * @param run run number
   * @param startTime start time of data
   * @param endTime end time of data
   */
  virtual void Initialize(Int_t run, UInt_t startTime, UInt_t endTime) = 0;

  /**
   * Function to process data. Inside the preparation and storing to OCDB
   * should be handled.
   *
   * @param dcsAliasMap the map containing aliases and corresponding DCS
   * 			values and timestamps
   *
   * @return 0 on success; error code otherwise
   */
  virtual UInt_t Process(TMap* dcsAliasMap) = 0;

  /** Get the run no */
  Int_t GetRun() const;

  /** Get the start time */
  UInt_t GetStartTime() const;

  /** Get the end time */
  UInt_t GetEndTime() const;

 /**
   * Get the id of the module
   * Each module preprocessor is identified by a unique id.
   * The function is pure virtual and must be implemented by the child class.
   * @return module id (string)
   */
  virtual const char* GetModuleID() {return ClassName();}

 /**
   * Get all detectors the module process
   * Detectors are determined in the bit mask as provided by "detectorMask"
   * implement: GetModuleNumber() {return AliHLTModulePreprocessor::DetetorID("detectorname");}
   * The function is pure virtual and must be implemented by the child class.
   * @return bit mask for active detectors (Int_t)
   */
  virtual Int_t GetModuleNumber() = 0;

  /** Get detector bit mask (bit mask comparable to the detectorMask but for the respective detector only)
   *  out of detector name
   *@param detectorName const char* of the detector
   *@return Int_t for the detector bit mask
   */
  Int_t DetectorBitMask(const char *detectorName);

 /** Get the information whether detector was active (return value: 1 = active, 0 = inactive) 
      @param detectorbitmask bitmask of the detector to be checked (s. DetectorBitMask)
      @return 1 if active 0 if inactive
 */
  Bool_t GetDetectorStatus(Int_t detectorbitmask);

  /** Get detector name out of detector id (bit position in detectorMask of the resp. detector)
   *@param detectorID integer ID of the detector
   *@return const char* name of the detector corresponding to the ID
   */
  const char *DetectorName(Int_t detectorID);

  /// extract object from the alias map
  /// return the last object from the value set
  TObject* GetFromMap(TMap* dcsAliasMap, const char* stringId) const;

  /** number of detectors */
  static const Int_t kNDetectors;    // Number of detectors

protected:
  // the AliPreprocessor interface, all functions redirected via the
  // AliHLTShuttleInterface to the AliHLTPreprocessor
  Bool_t Store(const char* pathLevel2, const char* pathLevel3, TObject* object,
	       AliCDBMetaData* metaData, Int_t validityStart = 0, Bool_t validityInfinite = kFALSE);
  Bool_t StoreReferenceData(const char* pathLevel2, const char* pathLevel3, TObject* object,
			    AliCDBMetaData* metaData);
  Bool_t StoreReferenceFile(const char* localFile, const char* gridFileName);

  Bool_t StoreRunMetadataFile(const char* localFile, const char* gridFileName);

  const char* GetFile(Int_t system, const char* id, const char* source);

  TList* GetFileSources(Int_t system, const char* id = 0);

  TList* GetFileIDs(Int_t system, const char* source);

  const char* GetRunParameter(const char* param);

  AliCDBEntry* GetFromOCDB(const char* pathLevel2, const char* pathLevel3);

  const char* GetRunType();

  void Log(const char* message);

private:
  /** copy constructor prohibited */
  AliHLTModulePreprocessor(const AliHLTModulePreprocessor& preproc);
  /** assignment operator prohibited */
  AliHLTModulePreprocessor& operator=(const AliHLTModulePreprocessor& rhs);

  /** the interface class which is the gateway to the shuttle */
  AliHLTShuttleInterface* fpInterface;                             //! transient

 /** determine which which detectors were active */
  Int_t fActiveDetectors; // bit array of active detectors

  /** array of detector names */
  static const char *fgkDetectorName[]; // Detector names

  ClassDef(AliHLTModulePreprocessor, 1);
};
#endif
 AliHLTModulePreprocessor.h:1
 AliHLTModulePreprocessor.h:2
 AliHLTModulePreprocessor.h:3
 AliHLTModulePreprocessor.h:4
 AliHLTModulePreprocessor.h:5
 AliHLTModulePreprocessor.h:6
 AliHLTModulePreprocessor.h:7
 AliHLTModulePreprocessor.h:8
 AliHLTModulePreprocessor.h:9
 AliHLTModulePreprocessor.h:10
 AliHLTModulePreprocessor.h:11
 AliHLTModulePreprocessor.h:12
 AliHLTModulePreprocessor.h:13
 AliHLTModulePreprocessor.h:14
 AliHLTModulePreprocessor.h:15
 AliHLTModulePreprocessor.h:16
 AliHLTModulePreprocessor.h:17
 AliHLTModulePreprocessor.h:18
 AliHLTModulePreprocessor.h:19
 AliHLTModulePreprocessor.h:20
 AliHLTModulePreprocessor.h:21
 AliHLTModulePreprocessor.h:22
 AliHLTModulePreprocessor.h:23
 AliHLTModulePreprocessor.h:24
 AliHLTModulePreprocessor.h:25
 AliHLTModulePreprocessor.h:26
 AliHLTModulePreprocessor.h:27
 AliHLTModulePreprocessor.h:28
 AliHLTModulePreprocessor.h:29
 AliHLTModulePreprocessor.h:30
 AliHLTModulePreprocessor.h:31
 AliHLTModulePreprocessor.h:32
 AliHLTModulePreprocessor.h:33
 AliHLTModulePreprocessor.h:34
 AliHLTModulePreprocessor.h:35
 AliHLTModulePreprocessor.h:36
 AliHLTModulePreprocessor.h:37
 AliHLTModulePreprocessor.h:38
 AliHLTModulePreprocessor.h:39
 AliHLTModulePreprocessor.h:40
 AliHLTModulePreprocessor.h:41
 AliHLTModulePreprocessor.h:42
 AliHLTModulePreprocessor.h:43
 AliHLTModulePreprocessor.h:44
 AliHLTModulePreprocessor.h:45
 AliHLTModulePreprocessor.h:46
 AliHLTModulePreprocessor.h:47
 AliHLTModulePreprocessor.h:48
 AliHLTModulePreprocessor.h:49
 AliHLTModulePreprocessor.h:50
 AliHLTModulePreprocessor.h:51
 AliHLTModulePreprocessor.h:52
 AliHLTModulePreprocessor.h:53
 AliHLTModulePreprocessor.h:54
 AliHLTModulePreprocessor.h:55
 AliHLTModulePreprocessor.h:56
 AliHLTModulePreprocessor.h:57
 AliHLTModulePreprocessor.h:58
 AliHLTModulePreprocessor.h:59
 AliHLTModulePreprocessor.h:60
 AliHLTModulePreprocessor.h:61
 AliHLTModulePreprocessor.h:62
 AliHLTModulePreprocessor.h:63
 AliHLTModulePreprocessor.h:64
 AliHLTModulePreprocessor.h:65
 AliHLTModulePreprocessor.h:66
 AliHLTModulePreprocessor.h:67
 AliHLTModulePreprocessor.h:68
 AliHLTModulePreprocessor.h:69
 AliHLTModulePreprocessor.h:70
 AliHLTModulePreprocessor.h:71
 AliHLTModulePreprocessor.h:72
 AliHLTModulePreprocessor.h:73
 AliHLTModulePreprocessor.h:74
 AliHLTModulePreprocessor.h:75
 AliHLTModulePreprocessor.h:76
 AliHLTModulePreprocessor.h:77
 AliHLTModulePreprocessor.h:78
 AliHLTModulePreprocessor.h:79
 AliHLTModulePreprocessor.h:80
 AliHLTModulePreprocessor.h:81
 AliHLTModulePreprocessor.h:82
 AliHLTModulePreprocessor.h:83
 AliHLTModulePreprocessor.h:84
 AliHLTModulePreprocessor.h:85
 AliHLTModulePreprocessor.h:86
 AliHLTModulePreprocessor.h:87
 AliHLTModulePreprocessor.h:88
 AliHLTModulePreprocessor.h:89
 AliHLTModulePreprocessor.h:90
 AliHLTModulePreprocessor.h:91
 AliHLTModulePreprocessor.h:92
 AliHLTModulePreprocessor.h:93
 AliHLTModulePreprocessor.h:94
 AliHLTModulePreprocessor.h:95
 AliHLTModulePreprocessor.h:96
 AliHLTModulePreprocessor.h:97
 AliHLTModulePreprocessor.h:98
 AliHLTModulePreprocessor.h:99
 AliHLTModulePreprocessor.h:100
 AliHLTModulePreprocessor.h:101
 AliHLTModulePreprocessor.h:102
 AliHLTModulePreprocessor.h:103
 AliHLTModulePreprocessor.h:104
 AliHLTModulePreprocessor.h:105
 AliHLTModulePreprocessor.h:106
 AliHLTModulePreprocessor.h:107
 AliHLTModulePreprocessor.h:108
 AliHLTModulePreprocessor.h:109
 AliHLTModulePreprocessor.h:110
 AliHLTModulePreprocessor.h:111
 AliHLTModulePreprocessor.h:112
 AliHLTModulePreprocessor.h:113
 AliHLTModulePreprocessor.h:114
 AliHLTModulePreprocessor.h:115
 AliHLTModulePreprocessor.h:116
 AliHLTModulePreprocessor.h:117
 AliHLTModulePreprocessor.h:118
 AliHLTModulePreprocessor.h:119
 AliHLTModulePreprocessor.h:120
 AliHLTModulePreprocessor.h:121
 AliHLTModulePreprocessor.h:122
 AliHLTModulePreprocessor.h:123
 AliHLTModulePreprocessor.h:124
 AliHLTModulePreprocessor.h:125
 AliHLTModulePreprocessor.h:126
 AliHLTModulePreprocessor.h:127
 AliHLTModulePreprocessor.h:128
 AliHLTModulePreprocessor.h:129
 AliHLTModulePreprocessor.h:130
 AliHLTModulePreprocessor.h:131
 AliHLTModulePreprocessor.h:132
 AliHLTModulePreprocessor.h:133
 AliHLTModulePreprocessor.h:134
 AliHLTModulePreprocessor.h:135
 AliHLTModulePreprocessor.h:136
 AliHLTModulePreprocessor.h:137
 AliHLTModulePreprocessor.h:138
 AliHLTModulePreprocessor.h:139
 AliHLTModulePreprocessor.h:140
 AliHLTModulePreprocessor.h:141
 AliHLTModulePreprocessor.h:142
 AliHLTModulePreprocessor.h:143
 AliHLTModulePreprocessor.h:144
 AliHLTModulePreprocessor.h:145
 AliHLTModulePreprocessor.h:146
 AliHLTModulePreprocessor.h:147
 AliHLTModulePreprocessor.h:148
 AliHLTModulePreprocessor.h:149
 AliHLTModulePreprocessor.h:150
 AliHLTModulePreprocessor.h:151
 AliHLTModulePreprocessor.h:152
 AliHLTModulePreprocessor.h:153
 AliHLTModulePreprocessor.h:154
 AliHLTModulePreprocessor.h:155
 AliHLTModulePreprocessor.h:156
 AliHLTModulePreprocessor.h:157
 AliHLTModulePreprocessor.h:158
 AliHLTModulePreprocessor.h:159
 AliHLTModulePreprocessor.h:160
 AliHLTModulePreprocessor.h:161
 AliHLTModulePreprocessor.h:162
 AliHLTModulePreprocessor.h:163
 AliHLTModulePreprocessor.h:164
 AliHLTModulePreprocessor.h:165
 AliHLTModulePreprocessor.h:166
 AliHLTModulePreprocessor.h:167
 AliHLTModulePreprocessor.h:168