LCOV - code coverage report
Current view: top level - HLT/BASE/HOMER - AliHLTHOMERWriter.h (source / functions) Hit Total Coverage
Test: coverage.info Lines: 1 7 14.3 %
Date: 2016-06-14 17:26:59 Functions: 1 15 6.7 %

          Line data    Source code
       1             : // XEMacs -*-C++-*-
       2             : #ifndef ALIHLTHOMERWRITER_H
       3             : #define ALIHLTHOMERWRITER_H
       4             : /************************************************************************
       5             : **
       6             : **
       7             : ** This file is property of and copyright by the Technical Computer
       8             : ** Science Group, Kirchhoff Institute for Physics, Ruprecht-Karls-
       9             : ** University, Heidelberg, Germany, 2001
      10             : ** This file has been written by Timm Morten Steinbeck, 
      11             : ** timm@kip.uni-heidelberg.de
      12             : **
      13             : **
      14             : ** See the file license.txt for details regarding usage, modification,
      15             : ** distribution and warranty.
      16             : ** Important: This file is provided without any warranty, including
      17             : ** fitness for any particular purpose.
      18             : **
      19             : **
      20             : ** Newer versions of this file's package will be made available from 
      21             : ** http://web.kip.uni-heidelberg.de/Hardwinf/L3/ 
      22             : ** or the corresponding page of the Heidelberg Alice Level 3 group.
      23             : **
      24             : *************************************************************************/
      25             : 
      26             : /*
      27             : ***************************************************************************
      28             : **
      29             : ** $Author$ - Initial Version by Timm Morten Steinbeck
      30             : **
      31             : ** $Id$ 
      32             : **
      33             : ***************************************************************************
      34             : */
      35             : 
      36             : /** @file   AliHLTHOMERWriter.h
      37             :     @author Timm Steinbeck
      38             :     @date   Sep 14 2007
      39             :     @brief  HLT Online Monitoring Environment including ROOT - Writer   
      40             :     @note   migrated from PubSub HLT-stable-20070905.141318 (rev 2375)    */
      41             : 
      42             : // see below for class documentation
      43             : // or
      44             : // refer to README to build package
      45             : // or
      46             : // visit http://web.ift.uib.no/~kjeks/doc/alice-hlt
      47             : 
      48             : 
      49             : #include "AliHLTHOMERData.h"
      50             : #include <vector>
      51             : 
      52             : /**
      53             :  * @class AliHLTMonitoringWriter
      54             :  * A pure virtual interface definition for HLT monitoring writers.
      55             :  * 
      56             :  * @ingroup alihlt_homer
      57             :  */
      58           0 : class AliHLTMonitoringWriter
      59             :     {
      60             :     public:
      61           0 :         AliHLTMonitoringWriter() {}
      62           0 :         virtual ~AliHLTMonitoringWriter() {}
      63             : 
      64             :         virtual void Clear() = 0;
      65             : 
      66             :         virtual void AddBlock( const void* descriptor, const void* data ) = 0;
      67             : 
      68             :         virtual homer_uint32 GetTotalMemorySize( bool includeData = true ) = 0;
      69             :         virtual void Copy( void* destination, homer_uint64 eventType, homer_uint64 eventNr, homer_uint64 statusFlags, homer_uint64 nodeID, bool includeData = true ) = 0;
      70             :      };
      71             : 
      72             : /**
      73             :  * @class AliHLTHOMERWriter
      74             :  * The HOMER writer assembles several data blocks of different properties
      75             :  * into one big buffer and adds meta information to describe the data's
      76             :  * alignment and byte order.
      77             :  */
      78           0 : class AliHLTHOMERWriter : public AliHLTMonitoringWriter
      79             :     {
      80             :     public:
      81             : 
      82             :         AliHLTHOMERWriter();
      83             :         virtual ~AliHLTHOMERWriter();
      84             : 
      85             :         /**
      86             :          * Resets the writer and clears the block list.
      87             :          */
      88             :         void Clear();
      89             : 
      90             :         /**
      91             :          * Add a data block to the writer.
      92             :          * The HOMER header must contain all meta information including the
      93             :          * size of the data.
      94             :          * @param homerHeader    pointer to the header describing the block
      95             :          * @param data           pointer to data
      96             :          */
      97             :         void AddBlock( const void* homerHeader, const void* data );
      98             : 
      99             :         /**
     100             :          * Add a data block to the writer.
     101             :          * The function has certainly been introduced to make type
     102             :          * conversion easier. In fact it makes it worse. The presence of the
     103             :          * function with void* argument leads to a wrong interpretation when
     104             :          * passing a non const pointer to HOMERBlockDescriptor. Then the
     105             :          * other function is called directly, leading to pointer mess up.
     106             :          */
     107             :         void AddBlock( const HOMERBlockDescriptor* descriptor, const void* data )
     108             :                 {
     109             :                 AddBlock( descriptor->GetHeader(), data );
     110             :                 }
     111             : 
     112             :         /**
     113             :          * Add a data block to the writer.
     114             :          * Function added to avoid potential pointer mismatches
     115             :          */
     116             :         void AddBlock( HOMERBlockDescriptor* descriptor, const void* data )
     117             :                 {
     118           0 :                 AddBlock( descriptor->GetHeader(), data );
     119           0 :                 }
     120             : 
     121             :         /**
     122             :          * Get the total buffer size required to write all data into one buffer
     123             :          */
     124             :         homer_uint32 GetTotalMemorySize( bool includeData = true );
     125             : 
     126             :         /**
     127             :          * Copy the data into a buffer.
     128             :          * The buffer is supposed to be big enough, the capacity should be queried
     129             :          * by calling @ref GetTotalMemorySize.
     130             :          */
     131             :         void Copy( void* destination, homer_uint64 eventType, homer_uint64 eventNr, homer_uint64 statusFlags, homer_uint64 nodeID, bool includeData = true );
     132             : 
     133             :         /** determine alignment of 64 bit variables */
     134             :         static homer_uint8 DetermineUInt64Alignment();
     135             :         /** determine alignment of 32 bit variables */
     136             :         static homer_uint8 DetermineUInt32Alignment();
     137             :         /** determine alignment of 16 bit variables */
     138             :         static homer_uint8 DetermineUInt16Alignment();
     139             :         /** determine alignment of 8 bit variables */
     140             :         static homer_uint8 DetermineUInt8Alignment();
     141             :         /** determine alignment of double type variables */
     142             :         static homer_uint8 DetermineDoubleAlignment();
     143             :         /** determine alignment of float type bit variables */
     144             :         static homer_uint8 DetermineFloatAlignment();
     145             : 
     146             : 
     147             :         /** test structure for the alignment determination of 64 bit variables */
     148             :         struct AliHLTHOMERWriterAlignment64TestStructure
     149             :         {
     150             :                 homer_uint64 f64Fill;   // !
     151             :                 homer_uint64 f64Test64; // !
     152             :                 homer_uint32 f32Fill;   // !
     153             :                 homer_uint64 f64Test32; // !
     154             :                 homer_uint16 f16Fill;   // !
     155             :                 homer_uint64 f64Test16; // !
     156             :                 homer_uint8  f8Fill;    // !
     157             :                 homer_uint64 f64Test8;  // !
     158             :         };
     159             :         /** test structure for the alignment determination of 32 bit variables */
     160             :         struct AliHLTHOMERWriterAlignment32TestStructure
     161             :         {
     162             :                 homer_uint64 f64Fill;   // !
     163             :                 homer_uint32 f32Test64; // !
     164             :                 homer_uint32 f32Fill;   // !
     165             :                 homer_uint32 f32Test32; // !
     166             :                 homer_uint16 f16Fill;   // !
     167             :                 homer_uint32 f32Test16; // !
     168             :                 homer_uint8  f8Fill;    // !
     169             :                 homer_uint32 f32Test8;  // !
     170             :         };
     171             :         /** test structure for the alignment determination of 16 bit variables */
     172             :         struct AliHLTHOMERWriterAlignment16TestStructure
     173             :         {
     174             :                 homer_uint64 f64Fill;   // !
     175             :                 homer_uint16 f16Test64; // !
     176             :                 homer_uint32 f32Fill;   // !
     177             :                 homer_uint16 f16Test32; // !
     178             :                 homer_uint16 f16Fill;   // !
     179             :                 homer_uint16 f16Test16; // !
     180             :                 homer_uint8  f8Fill;    // !
     181             :                 homer_uint16 f16Test8;  // !
     182             :         };
     183             :         /** test structure for the alignment determination of 8 bit variables */
     184             :         struct AliHLTHOMERWriterAlignment8TestStructure
     185             :         {
     186             :                 homer_uint64 f64Fill; // !
     187             :                 homer_uint8 f8Test64; // !
     188             :                 homer_uint32 f32Fill; // !
     189             :                 homer_uint8 f8Test32; // !
     190             :                 homer_uint16 f16Fill; // !
     191             :                 homer_uint8 f8Test16; // !
     192             :                 homer_uint8  f8Fill;  // !
     193             :                 homer_uint8 f8Test8;  // !
     194             :         };
     195             :         /** test structure for the alignment determination of double type variables */
     196             :         struct AliHLTHOMERWriterAlignmentDoubleTestStructure
     197             :         {
     198             :                 homer_uint64 f64Fill; // !
     199             :                 double fDoubleTest64; // !
     200             :                 homer_uint32 f32Fill; // !
     201             :                 double fDoubleTest32; // !
     202             :                 homer_uint16 f16Fill; // !
     203             :                 double fDoubleTest16; // !
     204             :                 homer_uint8  f8Fill;  // !
     205             :                 double fDoubleTest8;  // !
     206             :         };
     207             :         /** test structure for the alignment determination of float type variables */
     208             :         struct AliHLTHOMERWriterAlignmentFloatTestStructure
     209             :         {
     210             :                 homer_uint64 f64Fill; // !
     211             :                 float fFloatTest64;   // !
     212             :                 homer_uint32 f32Fill; // !
     213             :                 float fFloatTest32;   // !
     214             :                 homer_uint16 f16Fill; // !
     215             :                 float fFloatTest16;   // !
     216             :                 homer_uint8  f8Fill;  // !
     217             :                 float fFloatTest8;    // !
     218             :         };
     219             :     protected:
     220             : 
     221             :         /**
     222             :          * Block descriptor structure.
     223             :          * The descriptor contains a header for meta information and position
     224             :          * and a pointer to the data.
     225             :          */
     226             :         struct TBlockData
     227             :             {
     228             :               homer_uint64 fDescriptor[kCount_64b_Words]; //!transient
     229             :               const void* fData; //!transient
     230             :             };
     231             : 
     232             :         unsigned long fDataOffset; //!transient
     233             : 
     234             :         /** list of data blocks */
     235             :         std::vector<TBlockData> fBlocks; //!transient
     236             : #ifdef USE_ROOT
     237         126 :       ClassDef(AliHLTHOMERWriter,0);
     238             : #endif
     239             :     };
     240             : 
     241             : 
     242             : /** defined for backward compatibility */
     243             : typedef AliHLTHOMERWriter HOMERWriter;
     244             : 
     245             : // external interface of the HOMER writer
     246             : #define ALIHLTHOMERWRITER_CREATE "AliHLTHOMERWriterCreate"
     247             : #define ALIHLTHOMERWRITER_DELETE "AliHLTHOMERWriterDelete"
     248             : 
     249             : #ifdef __cplusplus
     250             : extern "C" {
     251             : #endif
     252             : 
     253             :   typedef AliHLTHOMERWriter* (*AliHLTHOMERWriterCreate_t)();
     254             :   typedef void (*AliHLTHOMERWriterDelete_t)(AliHLTHOMERWriter* pInstance);
     255             :   /**
     256             :    * Create instance of HOMER writer.
     257             :    */
     258             :   AliHLTHOMERWriter* AliHLTHOMERWriterCreate();
     259             : 
     260             :   /**
     261             :    * Delete instance of HOMER writer.
     262             :    */
     263             :   void AliHLTHOMERWriterDelete(AliHLTHOMERWriter* pInstance);
     264             : #ifdef __cplusplus
     265             : }
     266             : #endif
     267             : 
     268             : 
     269             : 
     270             : /*
     271             : ***************************************************************************
     272             : **
     273             : ** $Author$ - Initial Version by Timm Morten Steinbeck
     274             : **
     275             : ** $Id$ 
     276             : **
     277             : ***************************************************************************
     278             : */
     279             : 
     280             : #endif // ALIHLTHOMERWRITER_H

Generated by: LCOV version 1.11