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
operation
operation_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/operation/operation_registry.h
"
16
17
namespace
bdm
{
18
19
OperationRegistry::~OperationRegistry
() {
20
for
(
auto
&pair :
operations_
) {
21
delete
pair.second;
22
}
23
}
24
25
OperationRegistry
*
OperationRegistry::GetInstance
() {
26
static
OperationRegistry
operation_registry;
27
return
&operation_registry;
28
}
29
30
Operation
*
OperationRegistry::GetOperation
(
const
std::string &op_name) {
31
auto
search =
operations_
.find(op_name);
32
if
(search ==
operations_
.end()) {
33
std::string msg =
"Operation not found in registry: "
+ op_name;
34
Log::Fatal
(
"OperationRegistry::GetOperation"
, msg);
35
}
36
return
search->second;
37
}
38
39
bool
OperationRegistry::AddOperationImpl
(
const
std::string &op_name,
40
OpComputeTarget
target,
41
OperationImpl
*impl,
42
uint32_t frequency) {
43
auto
op =
operations_
.find(op_name);
44
// If operation doesn't exist yet, make a new operation under given name
45
if
(op ==
operations_
.end()) {
46
operations_
.insert(
47
std::make_pair(op_name,
new
Operation
(op_name, frequency)));
48
op =
operations_
.find(op_name);
49
op->second->AddOperationImpl(target, impl);
50
}
else
if
(op->second->implementations_.size() >=
51
static_cast<
size_t
>
(target + 1)) {
52
// If operation exists, check if the implementation already exists too
53
if
(op->second->implementations_[target]) {
54
Log::Fatal
(
"OperationRegistry::AddOperationImpl"
,
"Operation '"
, op_name,
55
"' with implementation '"
,
OpComputeTargetString
(target),
56
"' already exists in the registry!"
);
57
}
58
}
else
{
59
// Add the implementation to the existing operation
60
op->second->AddOperationImpl(target, impl);
61
}
62
return
true
;
63
}
64
65
OperationRegistry::OperationRegistry
() =
default
;
66
67
}
// namespace bdm
bdm::OperationRegistry::~OperationRegistry
~OperationRegistry()
Definition:
operation_registry.cc:19
bdm::OperationRegistry::GetOperation
Operation * GetOperation(const std::string &op_name)
Definition:
operation_registry.cc:30
bdm
Definition:
agent.cc:39
bdm::OpComputeTargetString
std::string OpComputeTargetString(OpComputeTarget t)
Definition:
operation.h:33
bdm::OperationImpl
Definition:
operation.h:46
operation_registry.h
bdm::OperationRegistry::AddOperationImpl
bool AddOperationImpl(const std::string &op_name, OpComputeTarget target, OperationImpl *impl, uint32_t frequency=1)
Definition:
operation_registry.cc:39
bdm::OpComputeTarget
OpComputeTarget
Definition:
operation.h:31
bdm::OperationRegistry::OperationRegistry
OperationRegistry()
bdm::Log::Fatal
static void Fatal(const std::string &location, const Args &... parts)
Prints fatal error message.
Definition:
log.h:115
bdm::OperationRegistry::GetInstance
static OperationRegistry * GetInstance()
Singleton class - returns the static instance.
Definition:
operation_registry.cc:25
bdm::OperationRegistry::operations_
std::unordered_map< std::string, Operation * > operations_
The map containing the operations; accessible by their name.
Definition:
operation_registry.h:55
bdm::Operation
Definition:
operation.h:99
bdm::OperationRegistry
Definition:
operation_registry.h:27
Generated by
1.8.17