4 #ifndef ExpressionParsing_PlainAccessor_h_
5 #define ExpressionParsing_PlainAccessor_h_
9 #include "GaudiKernel/EventContext.h"
25 template <
typename T_src>
28 std::size_t
size(
const std::vector<T_src> &cont)
const {
33 T_src
get(
const std::vector<T_src> &cont)
const {
39 T_src
get(
const std::vector<T_src> &cont, std::size_t
idx)
const {
57 template <
typename T_src>
60 std::size_t
size(
const T_src &cont)
const {
66 T_src
get(
const T_src &cont)
const {
72 T_src
get(
const T_src &cont, std::size_t
idx)
const {
96 virtual std::unique_ptr<IAccessor>
createAccessor(
const std::any &handle_key)
const = 0;
97 virtual bool registerReadKey(std::unordered_map<std::string, std::any > &read_keys,
100 std::vector<Gaudi::DataHandle *> &new_input_handles,
106 std::stringstream
msg;
107 msg <<
"Failed to add read handle key for " <<
var_name;
108 throw std::runtime_error(
msg.str());
111 template <
class T_Cont>
115 std::vector<Gaudi::DataHandle *> &new_input_handles,
120 if (ret.first != read_keys.end()
122 && ret.first->second.type().hash_code() ==
typeid(
key).hash_code()) {
131 if (
parent.declare(*key_final).isFailure()) {
137 std::cout <<
"DEBUG PlainAccessorFactory::registerReadKey register read handle key for " <<
var_name <<
" [" <<
typeid(T_Cont).
name() <<
"]."<< std::endl;
142 template <
typename T, IProxyLoader::VariableType T_variable_type>
145 virtual std::unique_ptr<IAccessor>
createAccessor(
const std::any &handle_key)
const override {
148 return std::make_unique<GenAccessor<std::vector<T>,
157 std::vector<Gaudi::DataHandle *> &new_input_handles,
159 return PlainAccessorFactory::registerReadKey<std::vector<T> >(read_keys,
parent,
var_name, new_input_handles,
verbose);
162 template <
typename T, IProxyLoader::VariableType T_variable_type>
165 virtual std::unique_ptr<IAccessor>
createAccessor(
const std::any &handle_key)
const override {
177 std::vector<Gaudi::DataHandle *> &new_input_handles,
179 return PlainAccessorFactory::registerReadKey<T >(read_keys,
parent,
var_name, new_input_handles,
verbose);
183 template <
typename T,IProxyLoader::VariableType T_variable_type>
188 template <
typename T,IProxyLoader::VariableType T_variable_type>
196 registerPlainValueKit<bool,IProxyLoader::VT_INT>();
197 registerPlainValueKit<int,IProxyLoader::VT_INT>();
198 registerPlainValueKit<unsigned int,IProxyLoader::VT_INT>();
199 registerPlainValueKit<float,IProxyLoader::VT_DOUBLE>();
200 registerPlainValueKit<double,IProxyLoader::VT_DOUBLE>();
202 registerStdVectorKit<bool,IProxyLoader::VT_VECINT>();
203 registerStdVectorKit<int,IProxyLoader::VT_VECINT>();
204 registerStdVectorKit<unsigned int,IProxyLoader::VT_VECINT>();
205 registerStdVectorKit<float,IProxyLoader::VT_VECDOUBLE>();
206 registerStdVectorKit<double,IProxyLoader::VT_VECDOUBLE>();
209 std::unordered_map<std::size_t,std::unique_ptr<IKit> >::const_iterator
210 kit_iter=
m_kits.find(handle_key.type().hash_code());
211 if (kit_iter ==
m_kits.end()) {
212 std::stringstream
msg;
213 msg <<
"ExpressionParsing::PlainAccessorFactory: no kit for type " << handle_key.type().name();
214 throw std::runtime_error(
msg.str());
216 return kit_iter->second->createAccessor(handle_key);
219 const std::type_info &the_type,
222 std::vector<Gaudi::DataHandle *> &new_input_handles,
224 std::unordered_map<std::size_t,std::unique_ptr<IKit> >::const_iterator
225 kit_iter=
m_kits.find(the_type.hash_code());
226 if (kit_iter ==
m_kits.end()) {
228 std::cout <<
"DEBUG PlainAccessorFactory::createReadKey no matching kit for " << the_type.name() <<
" " << the_type.hash_code() << std::endl;
229 for (
const std::pair<
const std::size_t,std::unique_ptr<IKit> > &elm :
m_kits) {
230 std::cout <<
"DEBUG PlainAccessorFactory::createReadKey have " << elm.first << std::endl;
238 std::unordered_map<std::size_t,std::unique_ptr<IKit> >
m_kits;