The Gaudi Framework  v32r2 (46d42edc)
AnyDataWrapper.h
Go to the documentation of this file.
1 #ifndef GAUDIKERNEL_ANYDATAWRAPPER_H
2 #define GAUDIKERNEL_ANYDATAWRAPPER_H
3 
4 // Include files
6 #include <cstddef>
7 #include <iterator>
8 #include <optional>
9 
10 namespace details {
11  using std::size;
12 
13  template <typename T, typename... Args>
14  constexpr auto size( const T&, Args&&... ) noexcept {
15  static_assert( sizeof...( Args ) == 0, "No extra args please" );
16  return std::nullopt;
17  }
18 } // namespace details
19 
20 // ugly hack to circumvent the usage of std::any
22  virtual std::optional<std::size_t> size() const = 0;
23 };
24 
25 template <class T>
27 public:
28  AnyDataWrapper( T&& data ) : m_data( std::move( data ) ){};
29 
31  : AnyDataWrapperBase( std::move( other ) ), m_data( std::move( other.m_data ) ){};
32 
33  const T& getData() const { return m_data; }
34  T& getData() { return m_data; }
35 
36  std::optional<std::size_t> size() const override {
37  using details::size;
38  return size( m_data );
39  }
40 
41 private:
42  T m_data;
43 };
44 
45 #endif
constexpr auto size(const T &, Args &&...) noexcept
virtual std::optional< std::size_t > size() const =0
STL namespace.
AnyDataWrapper(AnyDataWrapper &&other)
const T & getData() const
std::optional< std::size_t > size() const override
AnyDataWrapper(T &&data)
#define GAUDI_API
Definition: Kernel.h:71
A DataObject is the base class of any identifiable object on any data store.
Definition: DataObject.h:30