BioDynaMo
v1.05.125-2619fe54
Home
Main Page
Namespaces
Namespace List
Namespace Members
All
a
b
c
d
e
f
g
i
k
l
n
o
p
r
s
t
u
v
w
Functions
a
b
c
d
e
f
g
i
l
n
o
p
r
s
t
u
v
w
Variables
Typedefs
Enumerations
Enumerator
Classes
Class List
Class Index
Class Hierarchy
Class Members
All
:
a
b
c
d
e
f
g
h
i
j
k
l
m
n
o
p
q
r
s
t
u
v
w
x
y
z
~
Functions
a
b
c
d
e
f
g
h
i
j
k
l
m
n
o
p
r
s
t
u
v
w
~
Variables
a
b
c
d
e
f
g
h
i
k
l
m
n
o
p
q
r
s
t
u
v
w
x
y
z
Typedefs
b
c
d
e
f
i
n
p
r
t
v
Enumerations
Enumerator
Related Functions
:
d
e
i
m
o
p
r
s
t
Files
File List
File Members
All
_
b
c
d
h
n
p
s
Functions
Variables
Macros
•
All
Classes
Namespaces
Files
Functions
Variables
Typedefs
Enumerations
Enumerator
Friends
Macros
core
multi_simulation
algorithm
algorithm_registry.cc
Go to the documentation of this file.
1
// -----------------------------------------------------------------------------
2
//
3
// Copyright (C) 2021 CERN & University of Surrey for the benefit of the
4
// BioDynaMo collaboration. All Rights Reserved.
5
//
6
// Licensed under the Apache License, Version 2.0 (the "License");
7
// you may not use this file except in compliance with the License.
8
//
9
// See the LICENSE file distributed with this work for details.
10
// See the NOTICE file distributed with this work for additional information
11
// regarding copyright ownership.
12
//
13
// -----------------------------------------------------------------------------
14
15
#include "
core/multi_simulation/algorithm/algorithm_registry.h
"
16
#include "
core/util/log.h
"
17
18
namespace
bdm
{
19
namespace
experimental {
20
21
AlgorithmRegistry::~AlgorithmRegistry
() {
22
for
(
auto
&pair :
algorithms_
) {
23
delete
pair.second;
24
}
25
}
26
27
AlgorithmRegistry
*
AlgorithmRegistry::GetInstance
() {
28
static
AlgorithmRegistry
algorithm_registry;
29
return
&algorithm_registry;
30
}
31
32
Algorithm
*
AlgorithmRegistry::GetAlgorithm
(
const
std::string &algo_name) {
33
if
(algo_name.empty()) {
34
Log::Warning
(
"AlgorithmRegistry::GetAlgorithm"
,
35
"No algorithm name defined in parameter configuration."
);
36
return
nullptr
;
37
}
38
auto
search =
algorithms_
.find(algo_name);
39
if
(search ==
algorithms_
.end()) {
40
std::string msg =
"Algorithm not found in registry: "
+ algo_name;
41
Log::Fatal
(
"AlgorithmRegistry::GetAlgorithm"
, msg);
42
}
43
return
search->second;
44
}
45
46
bool
AlgorithmRegistry::AddAlgorithm
(
const
std::string &algo_name,
47
Algorithm
*algo) {
48
auto
algo_it =
algorithms_
.find(algo_name);
49
// If algorithm doesn't exist yet, register the new algorithm under given name
50
if
(algo_it ==
algorithms_
.end()) {
51
algorithms_
.insert(std::make_pair(algo_name, algo));
52
}
53
return
true
;
54
}
55
56
AlgorithmRegistry::AlgorithmRegistry
() =
default
;
57
58
}
// namespace experimental
59
}
// namespace bdm
bdm::experimental::AlgorithmRegistry::algorithms_
std::unordered_map< std::string, Algorithm * > algorithms_
The map containing the algorithms; accessible by their name.
Definition:
algorithm_registry.h:54
bdm
Definition:
agent.cc:39
algorithm_registry.h
bdm::experimental::Algorithm
An interface for creating new optimization algorithms.
Definition:
algorithm.h:30
bdm::experimental::AlgorithmRegistry
Registry of all optimization algorithms.
Definition:
algorithm_registry.h:30
bdm::Log::Warning
static void Warning(const std::string &location, const Args &... parts)
Prints warning message.
Definition:
log.h:67
bdm::experimental::AlgorithmRegistry::~AlgorithmRegistry
~AlgorithmRegistry()
Definition:
algorithm_registry.cc:21
bdm::experimental::AlgorithmRegistry::AddAlgorithm
bool AddAlgorithm(const std::string &algo_name, Algorithm *algo)
Definition:
algorithm_registry.cc:46
bdm::experimental::AlgorithmRegistry::GetAlgorithm
Algorithm * GetAlgorithm(const std::string &algo_name)
Definition:
algorithm_registry.cc:32
bdm::Log::Fatal
static void Fatal(const std::string &location, const Args &... parts)
Prints fatal error message.
Definition:
log.h:115
log.h
bdm::experimental::AlgorithmRegistry::GetInstance
static AlgorithmRegistry * GetInstance()
Singleton class - returns the static instance.
Definition:
algorithm_registry.cc:27
bdm::experimental::AlgorithmRegistry::AlgorithmRegistry
AlgorithmRegistry()
Generated by
1.8.17