VPTissue Reference Manual
Blad/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"
28 #include "sim/CoreData.h"
29 
30 #include <boost/property_tree/ptree.hpp>
31 
32 namespace SimPT_Blad {
33 
34 using namespace std;
35 
36 template<typename T>
37 static typename ComponentTraits<T>::ComponentType CreateHelper(const CoreData& cd, const typename ComponentTraits<T>::MapType& map)
38 {
39  const auto it = map.find(cd.m_parameters->get<string>(ComponentTraits<T>::Label()));
40  return (it != map.end()) ? (it->second)(cd) : typename ComponentTraits<T>::ComponentType();
41 }
42 
43 template<typename T>
44 static vector<string> ListHelper(const typename ComponentTraits<T>::MapType& map)
45 {
46  vector<string> vec;
47  for(const auto& e : map) {
48  vec.push_back(e.first);
49  }
50  return vec;
51 }
52 
53 
55 {
56  return CreateHelper<CellChemistryTag>(cd, CellChemistry::g_component_factories);
57 }
58 
59 CellColorComponent ComponentFactory::CreateCellColor(const string& select, const ptree& pt) const
60 {
61  const auto it = CellColor::g_component_factories.find(select);
62  return (it != CellColor::g_component_factories.end()) ? (it->second)(pt) : CellColorComponent();
63 }
64 
66 {
67  return CreateHelper<CellDaughtersTag>(cd, CellDaughters::g_component_factories);
68 }
69 
71 {
72  return CreateHelper<CellHousekeepTag>(cd, CellHousekeep::g_component_factories);
73 }
74 
76 {
77  return CreateHelper<CellSplitTag>(cd, CellSplit::g_component_factories);
78 }
79 
81 {
82  return CreateHelper<CellToCellTransportTag>(cd, CellToCellTransport::g_component_factories);
83 }
84 
86 {
87  return ListHelper<CellChemistryTag>(CellChemistry::g_component_factories);
88 }
89 
90 vector<string> ComponentFactory::ListCellColor() const
91 {
92  return ListHelper<CellColorTag>(CellColor::g_component_factories);
93 }
94 
96 {
97  return ListHelper<CellDaughtersTag>(CellDaughters::g_component_factories);
98 }
99 
101 {
102  return ListHelper<CellHousekeepTag>(CellHousekeep::g_component_factories);
103 }
104 
105 vector<string> ComponentFactory::ListCellSplit() const
106 {
107  return ListHelper<CellSplitTag>(CellSplit::g_component_factories);
108 }
109 
111 {
112  return ListHelper<CellToCellTransportTag>(CellToCellTransport::g_component_factories);
113 }
114 
115 } // namespace
Namespace for components of the Blad model group.
virtual CellSplitComponent CreateCellSplit(const CoreData &cd) const override final
Core data with mesh, parameters, random engine and time data.
Definition: CoreData.h:38
STL namespace.
virtual CellToCellTransportComponent CreateCellToCellTransport(const CoreData &cd) const override final
const ComponentTraits< CellDaughtersTag >::MapType g_component_factories
Stores cell chemistry component factories.
Core data used during model execution.
std::function< std::tuple< bool, bool, std::array< double, 3 >>(Cell *)> CellSplitComponent
CellSplit component interface.
const ComponentTraits< CellChemistryTag >::MapType g_component_factories
Stores cell chemistry component factories.
virtual std::vector< std::string > ListCellToCellTransport() const override final
List components for CellToCellTransport.
virtual CellColorComponent CreateCellColor(const string &select, const ptree &) const override final
virtual std::vector< std::string > ListCellColor() const override final
List components for CellColor.
virtual CellChemistryComponent CreateCellChemistry(const CoreData &cd) const override final
std::function< void(Cell *, Cell *)> CellDaughtersComponent
CellDaughters component interface.
virtual std::vector< std::string > ListCellChemistry() const override final
List components for CellChemistry.
const ComponentTraits< CellSplitTag >::MapType g_component_factories
Stores cell chemistry component factories.
virtual std::vector< std::string > ListCellDaughters() const override final
List components for cell daughters.
std::function< void(Cell *, double *)> CellChemistryComponent
CellChemistry component interface.
std::function< void(Cell *)> CellHousekeepComponent
CellHousekeep component interface.
virtual CellDaughtersComponent CreateCellDaughters(const CoreData &cd) const override final
Component factory for the Blad model group.
virtual CellHousekeepComponent CreateCellHousekeep(const CoreData &cd) const override final
virtual std::vector< std::string > ListCellHousekeep() const override final
List components for CellHouseKeep.
const ComponentTraits< CellToCellTransportTag >::MapType g_component_factories
Stores cell chemistry component factories.
const ComponentTraits< CellColorTag >::MapType g_component_factories
Stores cell color component factories.
std::function< std::array< double, 3 >(Cell *)> CellColorComponent
CellColor component interface.
virtual std::vector< std::string > ListCellSplit() const override final
List components for cell division.
std::function< void(Wall *, double *, double *)> CellToCellTransportComponent
CellToCellTransport component interface.
const ComponentTraits< CellHousekeepTag >::MapType g_component_factories
Stores cell chemistry component factories.