SourceXtractorPlusPlus 0.21
SourceXtractor++, the next generation SExtractor
Loading...
Searching...
No Matches
TaskProvider.cpp
Go to the documentation of this file.
1
24#include <mutex>
26
27namespace SourceXtractor {
28
29namespace {
30 std::mutex task_provider_mutex;
31}
32
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
Identifier used to set and retrieve properties.
Definition PropertyId.h:40
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.
std::unordered_map< PropertyId, std::shared_ptr< Task > > m_tasks
std::shared_ptr< TaskFactoryRegistry > m_task_factory_registry
T lock(T... args)