SourceXtractorPlusPlus
0.13
Please provide a description of the project.
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
auto
& task_factory =
m_task_factory_registry
->getFactory(property_id.
getTypeId
());
44
auto
task = task_factory.createTask(property_id);
45
46
// Put it in the cache
47
const_cast<
TaskProvider
&
>
(*this).
m_tasks
[property_id] = task;
48
49
return
task;
50
}
else
{
51
return
nullptr
;
52
}
53
}
54
55
}
// SEFramework namespace
std::lock
T lock(T... args)
std::shared_ptr
STL class.
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
std::lock_guard
STL class.
SourceXtractor::PropertyId::getTypeId
std::type_index getTypeId() const
Definition:
PropertyId.h:66
SourceXtractor::TaskProvider
Definition:
TaskProvider.h:42
SourceXtractor::PropertyId
Identifier used to set and retrieve properties.
Definition:
PropertyId.h:40
SourceXtractor
Definition:
Aperture.h:30
SourceXtractor::TaskProvider::m_tasks
std::unordered_map< PropertyId, std::shared_ptr< Task > > m_tasks
Definition:
TaskProvider.h:63
TaskProvider.h
std::mutex
STL class.
SourceXtractor::TaskProvider::m_task_factory_registry
std::shared_ptr< TaskFactoryRegistry > m_task_factory_registry
Definition:
TaskProvider.h:62
Generated by
1.8.20