VPTissue Reference Manual
Default/components/ComponentFactory.cpp
Go to the documentation of this file.
1 /*
2  * Copyright 2011-2016 Universiteit Antwerpen
3  *
4  * Licensed under the EUPL, Version 1.1 or as soon they will be approved by
5  * the European Commission - subsequent versions of the EUPL (the "Licence");
6  * You may not use this work except in compliance with the Licence.
7  * You may obtain a copy of the Licence at: http://ec.europa.eu/idabc/eupl5
8  *
9  * Unless required by applicable law or agreed to in writing, software
10  * distributed under the Licence is distributed on an "AS IS" basis,
11  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12  * See the Licence for the specific language governing
13  * permissions and limitations under the Licence.
14  */
20 #include "ComponentFactory.h"
21 
22 #include "cell_chemistry/factories.h"
23 #include "cell_color/factories.h"
24 #include "cell_daughters/factories.h"
25 #include "cell_housekeep/factories.h"
26 #include "cell_split/factories.h"
27 #include "cell2cell_transport/factories.h"
30 #include "hamiltonian/factories.h"
32 #include "time_evolver/factories.h"
34 #include "sim/CoreData.h"
35 
36 #include <boost/property_tree/ptree.hpp>
37 
38 namespace SimPT_Default {
39 
40 using namespace std;
41 using boost::property_tree::ptree;
42 
43 template<typename T>
44 static typename ComponentTraits<T>::ComponentType Helper(const CoreData& cd, const typename ComponentTraits<T>::MapType& map)
45 {
46  const auto it = map.find(cd.m_parameters->get<std::string>(ComponentTraits<T>::Label()));
47  return (it != map.end()) ? (it->second)(cd) : typename ComponentTraits<T>::ComponentType();
48 }
49 
50 template<typename T>
51 static vector<string> ListHelper(const typename ComponentTraits<T>::MapType& map)
52 {
53  vector<string> vec;
54  for(const auto& e : map) {
55  vec.push_back(e.first);
56  }
57  return vec;
58 }
59 
61 {
62  return Helper<CellChemistryTag>(cd, CellChemistry::g_component_factories);
63 }
64 
65 CellColorComponent ComponentFactory::CreateCellColor(const string& select, const ptree& pt) const
66 {
67  const auto it = CellColor::g_component_factories.find(select);
68  return (it != CellColor::g_component_factories.end()) ? (it->second)(pt) : CellColorComponent();
69 }
70 
72 {
73  return Helper<CellDaughtersTag>(cd, CellDaughters::g_component_factories);
74 }
75 
77 {
78  return Helper<CellHousekeepTag>(cd, CellHousekeep::g_component_factories);
79 }
80 
82 {
83  return Helper<CellSplitTag>(cd, CellSplit::g_component_factories);
84 }
85 
87 {
88  return Helper<CellToCellTransportTag>(cd, CellToCellTransport::g_component_factories);
89 }
90 
92 {
93  return Helper<CellToCellTransportBoundaryTag>(cd, CellToCellTransportBoundary::g_component_factories);
94 }
95 
97 {
98  return Helper<DeltaHamiltonianTag>(cd, DeltaHamiltonian::g_component_factories);
99 }
100 
102 {
103  return Helper<HamiltonianTag>(cd, Hamiltonian::g_component_factories);
104 }
105 
107 {
108  return Helper<MoveGeneratorTag>(cd, MoveGenerator::g_component_factories);
109 }
110 
112 {
113  return Helper<TimeEvolverTag>(cd, TimeEvolver::g_component_factories);
114 }
115 
117 {
118  return Helper<WallChemistryTag>(cd, WallChemistry::g_component_factories);
119 }
120 
122 {
123  return ListHelper<CellChemistryTag>(CellChemistry::g_component_factories);
124 }
125 
126 vector<string> ComponentFactory::ListCellColor() const
127 {
128  return ListHelper<CellColorTag>(CellColor::g_component_factories);
129 }
130 
132 {
133  return ListHelper<CellDaughtersTag>(CellDaughters::g_component_factories);
134 }
135 
137 {
138  return ListHelper<CellHousekeepTag>(CellHousekeep::g_component_factories);
139 }
140 
141 vector<string> ComponentFactory::ListCellSplit() const
142 {
143  return ListHelper<CellSplitTag>(CellSplit::g_component_factories);
144 }
145 
147 {
148  return ListHelper<CellToCellTransportTag>(CellToCellTransport::g_component_factories);
149 }
150 
152 {
153  return ListHelper<DeltaHamiltonianTag>(DeltaHamiltonian::g_component_factories);
154 }
155 
156 vector<string> ComponentFactory::ListHamiltonian() const
157 {
158  return ListHelper<HamiltonianTag>(Hamiltonian::g_component_factories);
159 }
160 
162 {
163  return ListHelper<MoveGeneratorTag>(MoveGenerator::g_component_factories);
164 }
165 
166 vector<string> ComponentFactory::ListTimeEvolver() const
167 {
168  return ListHelper<TimeEvolverTag>(TimeEvolver::g_component_factories);
169 }
170 
172 {
173  return ListHelper<WallChemistryTag>(WallChemistry::g_component_factories);
174 }
175 
176 } // namespace
virtual std::vector< std::string > ListHamiltonian() const override final
virtual CellToCellTransportComponent CreateCellToCellTransport(const CoreData &cd) const override final
std::function< double(Cell *)> HamiltonianComponent
Hamiltonian component interface.
std::function< double(const NeighborNodes &, Node *, std::array< double, 3 >)> DeltaHamiltonianComponent
DeltaHamiltonian component interface.
Core data with mesh, parameters, random engine and time data.
Definition: CoreData.h:38
STL namespace.
virtual std::vector< std::string > ListCellToCellTransport() const override final
Core data used during model execution.
std::function< std::tuple< bool, bool, std::array< double, 3 >>(Cell *)> CellSplitComponent
CellSplit component interface.
WallChemistry component factory map.
std::function< std::array< double, 3 >()> MoveGeneratorComponent
MoveGenerator component interface.
const ComponentTraits< WallChemistryTag >::MapType g_component_factories
Stores cell chemistry component factories.
virtual CellHousekeepComponent CreateCellHousekeep(const CoreData &cd) const override final
virtual TimeEvolverComponent CreateTimeEvolver(const CoreData &cd) const override final
virtual std::vector< std::string > ListWallChemistry() const override final
virtual std::vector< std::string > ListCellSplit() const override final
std::function< void(Cell *, Cell *)> CellDaughtersComponent
CellDaughters component interface.
virtual CellSplitComponent CreateCellSplit(const CoreData &cd) const override final
virtual std::vector< std::string > ListCellDaughters() const override final
Namespace for components of the Default model group.
virtual MoveGeneratorComponent CreateMoveGenerator(const CoreData &cd) const override final
std::function< void(Wall *w, double *dchem_c1, double *dchem_c2)> CellToCellTransportBoundaryComponent
CellToCellTransport boundary condition component interface.
TimeEvolver component factory map.
virtual DeltaHamiltonianComponent CreateDeltaHamiltonian(const CoreData &cd) const override final
virtual CellDaughtersComponent CreateCellDaughters(const CoreData &cd) const override final
virtual std::vector< std::string > ListTimeEvolver() const override final
CellChemistry component factory map.
virtual std::vector< std::string > ListMoveGenerator() const override final
const ComponentTraits< CellToCellTransportTag >::MapType g_component_factories
Stores cell chemistry component factories.
Component factory for SimPT_Default model group.
virtual std::vector< std::string > ListCellHousekeep() const override final
const ComponentTraits< CellToCellTransportBoundaryTag >::MapType g_component_factories
Stores cell chemistry component factories.
const ComponentTraits< CellChemistryTag >::MapType g_component_factories
Stores cell chemistry component factories.
virtual std::vector< std::string > ListDeltaHamiltonian() const override final
const ComponentTraits< CellColorTag >::MapType g_component_factories
Stores cell color component factories.
std::function< void(Cell *, double *)> CellChemistryComponent
CellChemistry component interface.
std::function< void(Cell *)> CellHousekeepComponent
CellHousekeep component interface.
const ComponentTraits< CellSplitTag >::MapType g_component_factories
Stores CellChemistry component factories.
virtual CellChemistryComponent CreateCellChemistry(const CoreData &cd) const override final
CellToCellTransport component factory map.
const ComponentTraits< MoveGeneratorTag >::MapType g_component_factories
Stores MoveGenerator component factories.
virtual std::vector< std::string > ListCellColor() const override final
const ComponentTraits< CellDaughtersTag >::MapType g_component_factories
Stores cell chemistry component factories.
virtual CellColorComponent CreateCellColor(const string &select, const ptree &) const override final
static CellToCellTransportBoundaryComponent CreateCellToCellTransportBoundary(const CoreData &cd)
Create CellToCellTransportBoundaryFunction (internal use).
CellSplit component factory map.
std::function< void(Wall *, double *, double *)> WallChemistryComponent
Wall chemistry component interface.
const ComponentTraits< CellHousekeepTag >::MapType g_component_factories
Stores cell chemistry component factories.
virtual WallChemistryComponent CreateWallChemistry(const CoreData &cd) const override final
const ComponentTraits< TimeEvolverTag >::MapType g_component_factories
Stores cell chemistry component factories.
const ComponentTraits< DeltaHamiltonianTag >::MapType g_component_factories
Stores DeltaHamiltonian component factories.
std::function< std::array< double, 3 >(Cell *)> CellColorComponent
CellColor component interface.
std::function< std::tuple< SimTimingTraits::CumulativeTimings, bool >(double, SimPhase)> TimeEvolverComponent
Time Evolver component interface.
virtual std::vector< std::string > ListCellChemistry() const override final
const ComponentTraits< HamiltonianTag >::MapType g_component_factories
Stores Hamiltonian component factories.
std::function< void(Wall *, double *, double *)> CellToCellTransportComponent
CellToCellTransport component interface.
virtual HamiltonianComponent CreateHamiltonian(const CoreData &cd) const override final