26 #include <boost/optional.hpp>
34 using boost::optional;
40 WallAttributes::WallAttributes(
unsigned int num_chem)
41 : m_rest_length(0.0), m_rest_length_init(0.0), m_strength(0.0),
42 m_transporters1(vector<double>(num_chem)), m_transporters2(vector<double>(num_chem)),
43 m_wall_type(WallType::
Type::Normal)
47 WallAttributes::WallAttributes(
double rest_length,
double rest_length_init,
double strength,
48 const vector<double>& transporters1,
const vector<double>& transporters2,
WallType::Type wall_type)
49 : m_rest_length(rest_length), m_rest_length_init(rest_length_init), m_strength(strength),
50 m_transporters1(transporters1), m_transporters2(transporters2), m_wall_type(wall_type)
54 void WallAttributes::CycleWallType()
56 if (m_wall_type == WallType::Type::Normal) {
57 m_wall_type = WallType::Type::AuxinSource;
58 }
else if (m_wall_type == WallType::Type::AuxinSource) {
59 m_wall_type = WallType::Type::AuxinSink;
60 }
else if (m_wall_type == WallType::Type::AuxinSink) {
61 m_wall_type = WallType::Type::Normal;
67 swap(m_rest_length, src.m_rest_length);
68 swap(m_rest_length_init, src.m_rest_length_init);
69 swap(m_transporters1, src.m_transporters1);
70 swap(m_transporters2, src.m_transporters2);
71 swap(m_wall_type, src.m_wall_type);
74 void WallAttributes::ReadPtree(boost::property_tree::ptree
const& wall_pt)
77 m_rest_length = wall_pt.get<
double>(
"rest_length");
78 m_rest_length_init = wall_pt.get<
double>(
"rest_length_init");
79 m_strength = wall_pt.get<
double>(
"strength");
80 m_transporters1.assign(m_transporters1.size(), 0.0);
81 m_transporters2.assign(m_transporters2.size(), 0.0);
84 optional<ptree const&> tp1_array_pt = wall_pt.get_child_optional(
"transporter1_array");
86 assert(tp1_array_pt->size() <= m_transporters1.size());
88 for (
auto const& tp1_v : *tp1_array_pt) {
89 m_transporters1[tp1_i++] = tp1_v.second.get_value<
double>();
93 optional<ptree const&> tp2_array_pt = wall_pt.get_child_optional(
"transporter2_array");
95 assert(tp2_array_pt->size() <= m_transporters1.size());
97 for (
auto const& tp2_v : *tp2_array_pt) {
98 m_transporters2[tp2_i++] = tp2_v.second.get_value<
double>();
102 catch(exception& e) {
103 const string here = string(VL_HERE) +
" exception:\n";
112 ret.put(
"rest_length", GetRestLength());
113 ret.put(
"rest_length_init", GetRestLengthInit());
114 ret.put(
"strength", GetStrength());
118 for (
const auto& t : m_transporters1) {
119 tp1_pt.add(
"transporter1", t);
121 ret.put_child(
"transporter1_array", tp1_pt);
124 for (
const auto& t : m_transporters2) {
125 tp2_pt.add(
"transporter2", t);
127 ret.put_child(
"transporter2_array", tp2_pt);
Type FromString(string s)
Converts a string with name to WallType::Type value.
Namespace for miscellaneous utilities.
string ToString(Type w)
Converts a WallType::Type value to corresponding name.
Type
Enumerates the wall types.
Extremely simple Exception root class.
Namespace for the core simulator.
Interface for WallAttributes.
Macro defs for debug and logging.
Attributes associated with a wall.
Header file for Exception class.
virtual boost::property_tree::ptree ToPtree() const
Convert the wall attributes to a ptree.