SourceXtractorPlusPlus
0.21
SourceXtractor++, the next generation SExtractor
Loading...
Searching...
No Matches
SEFramework
src
lib
Task
TaskProvider.cpp
Go to the documentation of this file.
1
24
#include <mutex>
25
#include "
SEFramework/Task/TaskProvider.h
"
26
27
namespace
SourceXtractor
{
28
29
namespace
{
30
std::mutex
task_provider_mutex;
31
}
32
33
std::shared_ptr<const Task>
TaskProvider::getTask
(
const
PropertyId
&
property_id
)
const
{
34
std::lock_guard<std::mutex>
lock
(
task_provider_mutex
);
35
36
// tries to find the Task for the property
37
auto
iterTask
=
m_tasks
.find(
property_id
);
38
39
if
(
iterTask
!=
m_tasks
.end()) {
40
return
iterTask
->second;
41
}
else
if
(
m_task_factory_registry
!=
nullptr
) {
42
// Use the TaskFactoryRegistry to get the correct factory for the requested property_id
43
try
{
44
auto
&
task_factory
=
m_task_factory_registry
->getFactory(
property_id
.getTypeId());
45
auto
task
=
task_factory
.createTask(
property_id
);
46
47
// Put it in the cache
48
const_cast<
TaskProvider
&
>
(*this).
m_tasks
[
property_id
] =
task
;
49
50
return
task
;
51
}
catch
(
std::out_of_range
&) {
52
throw
Elements::Exception
() <<
"No TaskFactory for property: "
<<
property_id
.getString();
53
}
54
}
else
{
55
return
nullptr
;
56
}
57
}
58
59
}
// SEFramework namespace
TaskProvider.h
Elements::Exception
SourceXtractor::PropertyId
Identifier used to set and retrieve properties.
Definition
PropertyId.h:40
SourceXtractor::TaskProvider
Definition
TaskProvider.h:42
SourceXtractor::TaskProvider::getTask
std::shared_ptr< const T > getTask(const PropertyId &property_id) const
Template version of getTask() that includes casting the returned pointer to the appropriate type.
Definition
TaskProvider.h:54
SourceXtractor::TaskProvider::m_tasks
std::unordered_map< PropertyId, std::shared_ptr< Task > > m_tasks
Definition
TaskProvider.h:63
SourceXtractor::TaskProvider::m_task_factory_registry
std::shared_ptr< TaskFactoryRegistry > m_task_factory_registry
Definition
TaskProvider.h:62
std::function
std::lock
T lock(T... args)
std::mutex
SourceXtractor
Definition
Aperture.h:30
std::out_of_range
Generated by
1.10.0