10#ifndef IMPACTX_ELEMENTS_MIXIN_DYNAMICDATA_H
11#define IMPACTX_ELEMENTS_MIXIN_DYNAMICDATA_H
13#include "impactx_export.H"
58 IMPACTX_EXPORT
static std::map<int, std::shared_ptr<T>>&
registry () {
59 static std::map<int, std::shared_ptr<T>> reg;
72 static std::shared_ptr<T>
const &
76 auto it = reg.find(
id);
77 if (it == reg.end() || !it->second)
78 throw std::runtime_error(
79 "GPUDataRegistry::get failed for id=" + std::to_string(
id));
88 static void store (
int id, std::shared_ptr<T> data)
99 template<
typename... Args>
102 auto ptr = std::shared_ptr<T>(
new T{std::forward<Args>(args)...});
130#define IMPACTX_GPUDATA_EXTERN(ElementType) \
131 extern template struct impactx::elements::mixin::GPUDataRegistry< \
132 ElementType::DynamicData::DataType>;
141#define IMPACTX_GPUDATA_INSTANTIATE(ElementType) \
142 template struct impactx::elements::mixin::GPUDataRegistry< \
143 ElementType::DynamicData::DataType>;
Definition alignment.H:23
Definition dynamicdata.H:50
static void store(int id, std::shared_ptr< T > data)
Definition dynamicdata.H:88
static IMPACTX_EXPORT int & next_id()
Definition dynamicdata.H:53
static std::shared_ptr< T > const & get(int id)
Definition dynamicdata.H:73
static int allocate_id()
Definition dynamicdata.H:64
static T & emplace(int id, Args &&... args)
Definition dynamicdata.H:100
CFbendCoefficients DataType
Definition dynamicdata.H:51
static IMPACTX_EXPORT std::map< int, std::shared_ptr< T > > & registry()
Definition dynamicdata.H:58
static void clear()
Definition dynamicdata.H:108