+
+AliHLTTriggerAgent::AliHLTTriggerDecisionHandler::AliHLTTriggerDecisionHandler()
+ : AliHLTOUTHandler()
+ , fESD(NULL)
+ , fpData(NULL)
+ , fSize(0)
+{
+ // see header file for class documentation
+}
+
+AliHLTTriggerAgent::AliHLTTriggerDecisionHandler::~AliHLTTriggerDecisionHandler()
+{
+ // see header file for class documentation
+ if (fESD) delete fESD;
+ fESD=NULL;
+
+ if (fpData) delete fpData;
+ fpData=NULL;
+ fSize=0;
+}
+
+int AliHLTTriggerAgent::AliHLTTriggerDecisionHandler::ProcessData(AliHLTOUT* pData)
+{
+ // see header file for class documentation
+ if (!pData) return -EINVAL;
+ AliHLTComponentDataType dt=kAliHLTVoidDataType;
+ AliHLTUInt32_t spec=kAliHLTVoidDataSpec;
+ int iResult=pData->GetDataBlockDescription(dt, spec);
+ if (iResult>=0) {
+ TObject* pObject=pData->GetDataObject();
+ if (pObject) {
+ AliHLTTriggerDecision* pDecission=dynamic_cast<AliHLTTriggerDecision*>(pObject);
+ if (pDecission) {
+ if (!fESD) {
+ // create the ESD container, but without std content
+ fESD = new AliESDEvent;
+ }
+ if (!fpData) fpData=new TArrayC;
+ if (fESD && fpData) {
+ fESD->Reset();
+ fESD->AddObject(pObject->Clone());
+ AliHLTMessage* pMsg=AliHLTMessage::Stream(fESD);
+ if (pMsg) {
+ if (!pMsg->CompBuffer()) {
+ fSize=pMsg->Length();
+ fpData->Set(fSize, pMsg->Buffer());
+ } else {
+ fSize=pMsg->CompLength();
+ fpData->Set(fSize, pMsg->CompBuffer());
+ }
+ } else {
+ HLTError("streaming of objects failed");
+ }
+ } else {
+ HLTError("memory allocation failed");
+ iResult=-ENOMEM;
+ }
+ } else {
+ HLTError("object %s is not an AliHLTTriggerDecision", pObject->GetName());
+ iResult=-ENODATA;
+ }
+ pData->ReleaseDataObject(pObject);
+ pObject=NULL;
+ } else {
+ HLTError("can not get TObject from HLTOUT buffer");
+ iResult=-ENODATA;
+ }
+ }
+ if (iResult>=0) return fSize;
+ fSize=0;
+ return iResult;
+}
+
+int AliHLTTriggerAgent::AliHLTTriggerDecisionHandler::GetProcessedData(const AliHLTUInt8_t* &pData)
+{
+ // see header file for class documentation
+ if (!fpData) {
+ pData=NULL;
+ return 0;
+ }
+
+ pData=reinterpret_cast<AliHLTUInt8_t*>(fpData->GetArray());
+ return fSize;
+}
+
+int AliHLTTriggerAgent::AliHLTTriggerDecisionHandler::ReleaseProcessedData(const AliHLTUInt8_t* pData, int size)
+{
+ // see header file for class documentation
+ int iResult=0;
+ if (!fpData || size != fSize ||
+ const_cast<AliHLTUInt8_t*>(pData) != reinterpret_cast<AliHLTUInt8_t*>(fpData->GetArray())) {
+ HLTError("attempt to release to wrong data buffer %p size %d, expected %p size %d", pData, size, fpData?fpData->GetArray():NULL, fSize);
+ }
+ fSize=0;
+ return iResult;
+}