VPTissue Reference Manual
WallType.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 "WallType.h"
21 
22 #include <boost/algorithm/string.hpp>
23 #include <map>
24 #include <string>
25 
26 using namespace std;
27 using boost::to_upper;
28 using namespace SimPT_Sim::WallType;
29 
30 namespace {
31 
32 std::map<Type, string> g_wall_type_name {
33  make_pair(Type::AuxinSource, "aux_source"),
34  make_pair(Type::AuxinSink, "aux_sink"),
35  make_pair(Type::Normal, "normal")
36 };
37 
38 std::map<string, Type> g_wall_name_type {
39  make_pair("AUX_SOURCE", Type::AuxinSource),
40  make_pair("AUX_SINK", Type::AuxinSink),
41  make_pair("NORMAL", Type::Normal)
42 };
43 
44 }
45 
46 namespace SimPT_Sim {
47 namespace WallType {
48 
49 string ToString(Type w)
50 {
51  string ret = "Unknown";
52  if (g_wall_type_name.count(w) == 1)
53  {
54  ret = g_wall_type_name[w];
55  }
56  return ret;
57 }
58 
59 Type FromString(string s)
60 {
61  Type ret = Type::Normal;
62  to_upper(s);
63  if (g_wall_name_type.count(s) == 1)
64  {
65  ret = g_wall_name_type[s];
66  }
67  return ret;
68 }
69 
70 } // namespace
71 } // namespace
Type FromString(string s)
Converts a string with name to WallType::Type value.
Definition: WallType.cpp:59
STL namespace.
Namespace for Types walls.
Definition: WallType.cpp:47
string ToString(Type w)
Converts a WallType::Type value to corresponding name.
Definition: WallType.cpp:49
Type
Enumerates the wall types.
Definition: WallType.h:27
Definition of WallType.
Namespace for the core simulator.