]> git.uio.no Git - u/mrichter/AliRoot.git/commitdiff
starting proper implementation of control evente (SOR,EOR, etc.) into AliHLTSystem...
authorrichterm <richterm@f7af4fe6-9843-0410-8265-dc069ae4e863>
Thu, 7 Aug 2008 07:45:30 +0000 (07:45 +0000)
committerrichterm <richterm@f7af4fe6-9843-0410-8265-dc069ae4e863>
Thu, 7 Aug 2008 07:45:30 +0000 (07:45 +0000)
HLT/BASE/AliHLTControlTask.cxx [new file with mode: 0644]
HLT/BASE/AliHLTControlTask.h [new file with mode: 0644]
HLT/libHLTbase.pkg

diff --git a/HLT/BASE/AliHLTControlTask.cxx b/HLT/BASE/AliHLTControlTask.cxx
new file mode 100644 (file)
index 0000000..b9e271e
--- /dev/null
@@ -0,0 +1,136 @@
+// $Id$
+
+//**************************************************************************
+//* This file is property of and copyright by the ALICE HLT Project        * 
+//* ALICE Experiment at CERN, All rights reserved.                         *
+//*                                                                        *
+//* Primary Authors: Matthias Richter <Matthias.Richter@ift.uib.no>        *
+//*                  for The ALICE HLT Project.                            *
+//*                                                                        *
+//* Permission to use, copy, modify and distribute this software and its   *
+//* documentation strictly for non-commercial purposes is hereby granted   *
+//* without fee, provided that the above copyright notice appears in all   *
+//* copies and that both the copyright notice and this permission notice   *
+//* appear in the supporting documentation. The authors make no claims     *
+//* about the suitability of this software for any purpose. It is          *
+//* provided "as is" without express or implied warranty.                  *
+//**************************************************************************
+
+/** @file   AliHLTControlTask.cxx
+    @author Matthias Richter
+    @date   
+    @brief  Special task to produce the control events.
+*/
+
+#include "AliHLTControlTask.h"
+#include "AliHLTComponentHandler.h"
+#include <cassert>
+
+/** ROOT macro for the implementation of ROOT specific class methods */
+ClassImp(AliHLTControlTask)
+
+AliHLTControlTask::AliHLTControlTask()
+  :
+  fEvent(kAliHLTVoidDataType),
+  fSpecification(kAliHLTVoidDataSpec),
+  fpData(NULL),
+  fSize(0)
+{
+  // see header file for class documentation
+  // or
+  // refer to README to build package
+  // or
+  // visit http://web.ift.uib.no/~kjeks/doc/alice-hlt
+}
+
+AliHLTControlTask::~AliHLTControlTask()
+{
+  // see header file for class documentation
+}
+
+int AliHLTControlTask::CreateComponent(AliHLTConfiguration* /*pConf*/, AliHLTComponentHandler* pCH, AliHLTComponent*& pComponent) const
+{
+  // see header file for class documentation
+  int iResult=0;
+  if ((pComponent=new AliHLTControlEventComponent(this))) {
+    const AliHLTAnalysisEnvironment* pEnv=pCH->GetEnvironment();
+    if ((iResult=pComponent->Init(pEnv, NULL, 0, NULL))>=0) {
+      //HLTDebug("component %s (%p) created", pComponent->GetComponentID(), pComponent); 
+    } else {
+      HLTError("Initialization of component \"%s\" failed with error %d", pComponent->GetComponentID(), iResult);
+    }
+    return iResult;
+  }
+  return -ENOMEM;
+}
+
+AliHLTControlTask::AliHLTControlEventComponent::AliHLTControlEventComponent(const AliHLTControlTask* pParent)
+  :
+  fpParent(pParent)
+{
+  // see header file for class documentation
+  assert(pParent);
+}
+
+AliHLTControlTask::AliHLTControlEventComponent::~AliHLTControlEventComponent()
+{
+  // see header file for class documentation
+}
+
+AliHLTComponentDataType AliHLTControlTask::AliHLTControlEventComponent::GetOutputDataType()
+{
+  // see header file for class documentation
+  return kAliHLTMultipleDataType;
+}
+
+int AliHLTControlTask::AliHLTControlEventComponent::GetOutputDataTypes(AliHLTComponentDataTypeList& tgtList)
+{
+  // see header file for class documentation
+  tgtList.clear();
+  tgtList.push_back(kAliHLTDataTypeSOR);
+  tgtList.push_back(kAliHLTDataTypeEOR);
+  return tgtList.size();
+}
+
+void AliHLTControlTask::AliHLTControlEventComponent::GetOutputDataSize( unsigned long& constBase, double& inputMultiplier )
+{
+  // see header file for class documentation
+  if (fpParent && fpParent->fSize>0) constBase=fpParent->fSize;
+  else constBase=sizeof(AliHLTRunDesc);
+  inputMultiplier=0;
+}
+
+int AliHLTControlTask::AliHLTControlEventComponent::GetEvent(const AliHLTComponentEventData& /*evtData*/,
+                                                            AliHLTComponentTriggerData& /*trigData*/,
+                                                            AliHLTUInt8_t* outputPtr, 
+                                                            AliHLTUInt32_t& size,
+                                                            vector<AliHLTComponentBlockData>& outputBlocks )
+{
+  // see header file for class documentation
+  if (!fpParent) return -ENODEV;
+  const AliHLTControlTask* pParent=fpParent;
+  if (size<pParent->fSize) {
+    return -ENOSPC;
+  }
+
+  if (pParent->fpData && pParent->fSize) {
+    memcpy(outputPtr, pParent->fpData, pParent->fSize);
+  }
+
+  // return if no event has been set
+  if (pParent->fEvent==kAliHLTVoidDataType) {
+    HLTInfo("no control event to send");
+    return 0;
+  }
+
+  HLTInfo("publishing control event %s", DataType2Text(pParent->fEvent).c_str());
+  AliHLTComponentBlockData bd;
+  FillBlockData(bd);
+  bd.fOffset=0;
+  bd.fSize=pParent->fSize;
+  bd.fDataType=pParent->fEvent;
+  bd.fSpecification=pParent->fSpecification;
+  outputBlocks.push_back( bd );
+
+  return bd.fSize;
+}
diff --git a/HLT/BASE/AliHLTControlTask.h b/HLT/BASE/AliHLTControlTask.h
new file mode 100644 (file)
index 0000000..a7eae0d
--- /dev/null
@@ -0,0 +1,129 @@
+//-*- Mode: C++ -*-
+// $Id$
+#ifndef ALIHLTCONTROLTASK_H
+#define ALIHLTCONTROLTASK_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   AliHLTControlTask.h
+    @author Matthias Richter
+    @date   
+    @brief  Special task to produce the control events.
+*/
+
+#include "AliHLTTask.h"
+#include "AliHLTDataSource.h"
+
+class AliHLTComponentHandler;
+class AliHLTConfiguration;
+
+/**
+ * @class AliHLTControlTask
+ * This task is automatically added to the beginning of each chain and
+ * produces the special steering events. The first component in every
+ * branch get the special events from the task.
+ *
+ * This task gets initialized with data type, specification and payload
+ * of the control event to be sent. It produces the data block if data
+ * type differs from fAliHLTVoidDataType. The guard class can be used to
+ * set the parameters.
+ * <pre>
+ * AliHLTControlEventGuard(task, kAliHLTDataTypeSOR, 0, payload, size);
+ * </pre>
+ *
+ * @ingroup alihlt_system
+ */
+class AliHLTControlTask : public AliHLTTask {
+ public:
+  /** constructor */
+  AliHLTControlTask();
+  /** standard destructor */
+  virtual ~AliHLTControlTask();
+
+  // AliHLTTask interface function
+  int CreateComponent(AliHLTConfiguration* pConf, AliHLTComponentHandler* pCH, AliHLTComponent*& pComponent) const;
+
+  class AliHLTControlEventGuard {
+  public:
+    AliHLTControlEventGuard(AliHLTControlTask* me, AliHLTComponentDataType dt, AliHLTUInt32_t spec, AliHLTUInt8_t* pData, AliHLTUInt32_t size) :
+      fTask(me) {
+      if (!fTask) return;
+      fTask->fEvent=dt; 
+      fTask->fSpecification=spec; 
+      fTask->fpData=pData; 
+      fTask->fSize=size;
+    }
+      ~AliHLTControlEventGuard() {
+       if (!fTask) return;
+       fTask->fEvent=kAliHLTVoidDataType;
+       fTask->fSpecification=kAliHLTVoidDataSpec;
+       fTask->fpData=NULL;
+       fTask->fSize=0;
+      }
+
+  private:
+      /** standard constructor prohibited */
+      AliHLTControlEventGuard();
+      /** copy constructor prohibited */
+      AliHLTControlEventGuard(const AliHLTControlEventGuard&);
+      /** assignment operator prohibited */
+      AliHLTControlEventGuard& operator=(const AliHLTControlEventGuard&);
+
+      /** by the guard controlled task */
+      AliHLTControlTask* fTask; //! transient
+  };
+
+  /**
+   * Source component producing the data blocks
+   */
+  class AliHLTControlEventComponent : public AliHLTDataSource {
+  public:
+    AliHLTControlEventComponent(const AliHLTControlTask* pParent);
+    ~AliHLTControlEventComponent();
+
+    // AliHLTComponent interface functions
+    const char* GetComponentID() {return "__priv_AliHLTControlTask";}
+    AliHLTComponentDataType GetOutputDataType();
+    int GetOutputDataTypes(AliHLTComponentDataTypeList& tgtList);
+    void GetOutputDataSize( unsigned long& constBase, double& inputMultiplier );
+    AliHLTComponent* Spawn() {return NULL;}
+
+  private:
+    /** standard constructor prohibited */
+    AliHLTControlEventComponent();
+    /** copy constructor prohibited */
+    AliHLTControlEventComponent(const AliHLTControlEventComponent&);
+    /** assignment operator prohibited */
+    AliHLTControlEventComponent& operator=(const AliHLTControlEventComponent&);
+
+    // AliHLTDataSource interface function
+    int GetEvent(const AliHLTComponentEventData& evtData,
+                AliHLTComponentTriggerData& trigData,
+                AliHLTUInt8_t* outputPtr, 
+                AliHLTUInt32_t& size,
+                vector<AliHLTComponentBlockData>& outputBlocks );
+
+    const AliHLTControlTask* fpParent; //! transient
+  };
+
+ protected:
+
+ private:
+  /** copy constructor prohibited */
+  AliHLTControlTask(const AliHLTControlTask&);
+  /** assignment operator prohibited */
+  AliHLTControlTask& operator=(const AliHLTControlTask&);
+
+  /** data type of the control event */
+  AliHLTComponentDataType fEvent; //! transient
+  /** specification of the control evtent */
+  AliHLTUInt32_t fSpecification; //! transient
+  /** payload to be sent with the control event */
+  AliHLTUInt8_t* fpData; //! transient
+  /** payload size */
+  AliHLTUInt32_t fSize; //!transient
+
+  ClassDef(AliHLTControlTask, 0)
+    };
+#endif
index a1228973c5b061a2b3cde43445d80dc0cf436ad6..dc0999d0202c8276bc83802ed1d5bda059b91a5c 100644 (file)
@@ -12,6 +12,7 @@ CLASS_HDRS:=          AliHLTComponent.h \
                AliHLTConfiguration.h \
                AliHLTConfigurationHandler.h \
                AliHLTTask.h \
+               AliHLTControlTask.h \
                AliHLTLogging.h \
                AliHLTDataBuffer.h \
                AliHLTConsumerDescriptor.h \