VPTissue Reference Manual
BoundaryType.h
Go to the documentation of this file.
1 #ifndef BOUNDARY_TYPE_H_INCLUDED
2 #define BOUNDARY_TYPE_H_INCLUDED
3 /*
4  * Copyright 2011-2016 Universiteit Antwerpen
5  *
6  * Licensed under the EUPL, Version 1.1 or as soon they will be approved by
7  * the European Commission - subsequent versions of the EUPL (the "Licence");
8  * You may not use this work except in compliance with the Licence.
9  * You may obtain a copy of the Licence at: http://ec.europa.eu/idabc/eupl5
10  *
11  * Unless required by applicable law or agreed to in writing, software
12  * distributed under the Licence is distributed on an "AS IS" basis,
13  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14  * See the Licence for the specific language governing
15  * permissions and limitations under the Licence.
16  */
22 #include "util/misc/StringUtils.h"
23 
24 #include <istream>
25 #include <map>
26 #include <ostream>
27 #include <string>
28 
29 namespace SimPT_Sim {
30 
34 enum class BoundaryType
35 {
36  None, NoFlux, SourceSink, SAM
37 };
38 
39 inline std::ostream& operator<<(std::ostream& os, BoundaryType b)
40 {
41  static const std::map<BoundaryType, std::string> m {
42  std::make_pair(BoundaryType::None, "None"),
43  std::make_pair(BoundaryType::NoFlux, "NoFlux"),
44  std::make_pair(BoundaryType::SourceSink, "SourceSink"),
45  std::make_pair(BoundaryType::SAM, "SAM")
46  };
47 
48  const auto search = m.find(b);
49  os << ((search != m.end()) ? search->second : "Unknown");
50 
51  return os;
52 }
53 
54 inline std::istream& operator>>(std::istream& is, BoundaryType& b)
55 {
56  static const std::map<std::string, BoundaryType> m {
57  std::make_pair("NONE", BoundaryType::None),
58  std::make_pair("NOFLUX", BoundaryType::NoFlux),
59  std::make_pair("SOURCESINK", BoundaryType::SourceSink),
60  std::make_pair("SAM", BoundaryType::SAM)
61  };
62 
63  std::string s;
64  is >> s;
65  const auto search = m.find(SimPT_Sim::Util::ToUpper(s));
66  b = (search != m.end()) ? search->second : BoundaryType::None;
67 
68  return is;
69 }
70 
71 } // namespace
72 
73 #endif // end-of-include-guard
static std::string ToUpper(const std::string &source)
Builds a string with upper case characters only.
Definition: StringUtils.h:87
Namespace for the core simulator.
BoundaryType
Enumerates cell boundary types.
Definition: BoundaryType.h:34
String manipulation utilities.