SourceXtractorPlusPlus 1.0.3
SourceXtractor++, the next generation SExtractor
Loading...
Searching...
No Matches
SourceWithOnDemandProperties.cpp
Go to the documentation of this file.
1
22
23#include "ElementsKernel/Logging.h"
24
28
30
31namespace SourceXtractor {
32
33static Elements::Logging logger = Elements::Logging::getLogger("SourceWithOnDemandProperties");
34
38
40 // if we have the property already, just return it
41 if (m_property_holder.isPropertySet(property_id)) {
42 return m_property_holder.getProperty(property_id);
43 }
44
45 try {
46 // if not, get the task that makes it and execute, we should have it then
47 auto task = m_task_provider->getTask<SourceTask>(property_id);
48 if (task) {
49 task->computeProperties(const_cast<SourceWithOnDemandProperties&>(*this));
50 return m_property_holder.getProperty(property_id);
51 }
52 }
53 catch (Elements::Exception& e) {
54 logger.debug() << e.what();
55 }
56
57 // no task available to make the property, just throw an exception
58 throw PropertyNotFoundException(property_id);
59}
60
62 // just forward to the ObjectWithProperties implementation
63 m_property_holder.setProperty(std::move(property), property_id);
64}
65
66
67} // SEFramework namespace
68
static Logging getLogger(const std::string &name="")
Identifier used to set and retrieve properties.
Definition PropertyId.h:40
An exception indicating that a Property was not available and could not be computed on demand.
Base class for all Properties. (has no actual content).
Definition Property.h:33
A Task that acts on a Source to compute one or more properties.
Definition SourceTask.h:36
std::shared_ptr< const TaskProvider > m_task_provider
SourceWithOnDemandProperties(const SourceWithOnDemandProperties &)=delete
const Property & getProperty(const PropertyId &property_id) const override
void setProperty(std::unique_ptr< Property > property, const PropertyId &property_id) override
T move(T... args)
static Elements::Logging logger