VPTissue Reference Manual
RandomEngineType.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 "RandomEngineType.h"
21 
22 #include <map>
23 
24 using namespace std;
25 using namespace SimPT_Sim::RandomEngineType;
26 
27 namespace {
28 
29 std::map<TypeId, string> g_type_id_to_name {
30  make_pair(TypeId::lcg64, "lcg64"),
31  make_pair(TypeId::lcg64_shift, "lcg64_shift"),
32  make_pair(TypeId::mrg2, "mrg2"),
33  make_pair(TypeId::mrg3, "mrg3"),
34  make_pair(TypeId::yarn2, "yarn2"),
35  make_pair(TypeId::yarn3, "yarn3")
36 };
37 
38 std::map<string, TypeId> g_name_to_type_id {
39  make_pair("lcg64", TypeId::lcg64),
40  make_pair("lcg64_shift", TypeId::lcg64_shift),
41  make_pair("mrg2", TypeId::mrg2),
42  make_pair("mrg3", TypeId::mrg3),
43  make_pair("yarn2", TypeId::yarn2),
44  make_pair("yarn3", TypeId::yarn3)
45 };
46 
47 }
48 
49 namespace SimPT_Sim {
50 namespace RandomEngineType {
51 
52 bool IsExisting(std::string s)
53 {
54  return g_name_to_type_id.count(s) == 1;
55 }
56 
58 {
59  return g_type_id_to_name.count(b) == 1;
60 }
61 
62 string ToString(TypeId b)
63 {
64  string ret = "";
65  if (g_type_id_to_name.count(b) == 1) {
66  ret = g_type_id_to_name[b];
67  }
68  return ret;
69 }
70 
71 TypeId FromString(string s)
72 {
73  TypeId ret = TypeId::mrg2;
74  if (g_name_to_type_id.count(s) == 1) {
75  ret = g_name_to_type_id[s];
76  }
77  return ret;
78 }
79 
80 } // namespace
81 } // namespace
82 
83 
84 
85 
STL namespace.
string ToString(TypeId b)
Convert a type id to corresponding name.
TypeId FromString(string s)
Convert a string with name to type id.
Namespace for the core simulator.
bool IsExisting(TypeId b)
Check whether type with id b exists.
Namespace for Types of random engines.
TypeId
Enumerates type ids.
Interface of RandomEngineType.