Panzer Version of the Day
Loading...
Searching...
No Matches
Panzer_TypeAssocMap.hpp
Go to the documentation of this file.
1// @HEADER
2// *****************************************************************************
3// Panzer: A partial differential equation assembly
4// engine for strongly coupled complex multiphysics systems
5//
6// Copyright 2011 NTESS and the Panzer contributors.
7// SPDX-License-Identifier: BSD-3-Clause
8// *****************************************************************************
9// @HEADER
10
11#ifndef __Panzer_TypeAssocMap_hpp__
12#define __Panzer_TypeAssocMap_hpp__
13
14#include "Sacado_mpl_for_each.hpp"
15
16namespace panzer {
17
21template <typename TypesVector,typename ValueType>
23public:
24 typedef TypesVector types_vector;
25
27 {
28 const int sz = Sacado::mpl::size<TypesVector>::value;
29 mapValues_.resize(sz);
30 }
31
33 template <typename T>
34 void set(ValueType v)
35 {
36 const int idx = Sacado::mpl::find<TypesVector,T>::value;
37 mapValues_[idx] = v;
38 }
39
41 template <typename T>
42 ValueType get() const
43 {
44 const int idx = Sacado::mpl::find<TypesVector,T>::value;
45 return mapValues_[idx];
46 }
47
48 template <typename BuilderOpT>
49 void buildObjects(const BuilderOpT & builder)
50 { Sacado::mpl::for_each_no_kokkos<TypesVector>(BuildObjects<BuilderOpT>(mapValues_,builder)); }
51
52public:
53
55 template <typename BuilderOpT>
56 struct BuildObjects {
57 std::vector<ValueType> & mv_;
58 const BuilderOpT & builder_;
59 BuildObjects(std::vector<ValueType> & mv,const BuilderOpT& builder) : mv_(mv), builder_(builder) {}
60
61 template <typename T> void operator()(T) const {
62 const int idx = Sacado::mpl::find<TypesVector,T>::value;
63 mv_[idx] = builder_.template build<T>();
64 }
65 };
66
67 std::vector<ValueType> mapValues_;
68};
69
70}
71
72#endif
std::vector< ValueType > mapValues_
ValueType get() const
Access routine.
void set(ValueType v)
Modify routine.
void buildObjects(const BuilderOpT &builder)
This struct helps will build the values stored in the map.
BuildObjects(std::vector< ValueType > &mv, const BuilderOpT &builder)