EDGetToken

Macros

Line Code
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43
#ifndef HeterogeneousCore_AlpakaCore_interface_alpaka_EDGetToken_h
#define HeterogeneousCore_AlpakaCore_interface_alpaka_EDGetToken_h

#include "DataFormats/Common/interface/DeviceProduct.h"
#include "FWCore/Utilities/interface/EDGetToken.h"
#include "HeterogeneousCore/AlpakaCore/interface/alpaka/DeviceProductType.h"
#include "HeterogeneousCore/AlpakaInterface/interface/config.h"

namespace ALPAKA_ACCELERATOR_NAMESPACE::device {
  class Event;
  /**
   * The device::EDGetToken is similar to edm::EDGetTokenT, but is
   * intended for Event data products in the device memory space
   * defined by the backend (i.e. ALPAKA_ACCELERATOR_NAMESPACE). It
   * can be used only to get data from a device::Event.
   *
   * A specific token class is motivated with
   * - enforce stronger the type-deducing consumes(). Consumes() with
   *   explicit type will fail anyway in general, but succeeds on one
   *   of the backends. With a specific token type the explicit-type
   *   consumes() would fail always.
   *- to avoid using device::EDGetToken with edm::Event
   */
  template <typename TProduct>
  class EDGetToken {
    using ProductType = detail::DeviceProductType<TProduct>;

  public:
    constexpr EDGetToken() = default;

    template <typename TAdapter>
    constexpr EDGetToken(TAdapter&& iAdapter) : token_(std::forward<TAdapter>(iAdapter)) {}

  private:
    friend class Event;

    auto const& underlyingToken() const { return token_; }

    edm::EDGetTokenT<ProductType> token_;
  };
}  // namespace ALPAKA_ACCELERATOR_NAMESPACE::device

#endif