Skip to content

Commit cd12ba6

Browse files
authored
Remove unnecessary PodioDataSvc from DataHandle and harmonize constructors (#321)
1 parent 181277e commit cd12ba6

File tree

1 file changed

+13
-20
lines changed

1 file changed

+13
-20
lines changed

k4FWCore/include/k4FWCore/DataHandle.h

Lines changed: 13 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -20,12 +20,14 @@
2020
#define K4FWCORE_DATAHANDLE_H
2121

2222
#include "k4FWCore/DataWrapper.h"
23-
#include "k4FWCore/PodioDataSvc.h"
24-
25-
#include "GaudiKernel/DataObjectHandle.h"
2623

2724
#include <GaudiKernel/AnyDataWrapper.h>
25+
#include <GaudiKernel/DataObjectHandle.h>
26+
#include <GaudiKernel/ServiceHandle.h>
27+
28+
#include <memory>
2829
#include <stdexcept>
30+
#include <string>
2931
#include <type_traits>
3032

3133
/**
@@ -39,12 +41,13 @@ class DataHandle : public DataObjectHandle<DataWrapper<T>> {
3941
friend class AlgTool;
4042

4143
public:
42-
DataHandle();
44+
DataHandle() = delete;
45+
DataHandle(const DataHandle&) = delete;
46+
DataHandle& operator=(const DataHandle&) = delete;
47+
DataHandle(DataHandle&&) = default;
48+
DataHandle& operator=(DataHandle&&) = default;
4349
~DataHandle() override;
4450

45-
/// Initialises mother class
46-
DataHandle(DataObjID& descriptor, Gaudi::DataHandle::Mode a, IDataHandleHolder* fatherAlg);
47-
4851
DataHandle(const std::string& k, Gaudi::DataHandle::Mode a, IDataHandleHolder* fatherAlg);
4952

5053
/// Retrieve object from transient data store
@@ -64,7 +67,7 @@ class DataHandle : public DataObjectHandle<DataWrapper<T>> {
6467

6568
private:
6669
ServiceHandle<IDataProviderSvc> m_eds;
67-
T* m_dataPtr;
70+
T* m_dataPtr{nullptr};
6871
};
6972

7073
template <typename T>
@@ -75,22 +78,12 @@ DataHandle<T>::~DataHandle() {
7578
}
7679
}
7780

78-
//---------------------------------------------------------------------------
79-
template <typename T>
80-
DataHandle<T>::DataHandle(DataObjID& descriptor, Gaudi::DataHandle::Mode a, IDataHandleHolder* fatherAlg)
81-
: DataObjectHandle<DataWrapper<T>>(descriptor, a, fatherAlg), m_eds("EventDataSvc", "DataHandle") {}
82-
8381
template <typename T>
8482
DataHandle<T>::DataHandle(const std::string& descriptor, Gaudi::DataHandle::Mode a, IDataHandleHolder* fatherAlg)
8583
: DataObjectHandle<DataWrapper<T>>(descriptor, a, fatherAlg), m_eds("EventDataSvc", "DataHandle") {
8684
if (a == Gaudi::DataHandle::Writer) {
87-
m_eds.retrieve().ignore();
88-
m_dataPtr = nullptr;
89-
auto* podio_data_service = dynamic_cast<PodioDataSvc*>(m_eds.get());
90-
if (nullptr != podio_data_service) {
91-
if constexpr (std::is_integral_v<T> || std::is_floating_point_v<T>) {
92-
m_dataPtr = new T();
93-
}
85+
if constexpr (std::is_integral_v<T> || std::is_floating_point_v<T>) {
86+
m_dataPtr = new T();
9487
}
9588
}
9689
}

0 commit comments

Comments
 (0)