SourceXtractorPlusPlus  0.10
Please provide a description of the project.
SourceWithOnDemandProperties.cpp
Go to the documentation of this file.
1 
26 
28 
29 namespace SourceXtractor {
30 
32  m_task_provider(task_provider) {
33 }
34 
36  // if we have the property already, just return it
37  if (m_property_holder.isPropertySet(property_id)) {
38  return m_property_holder.getProperty(property_id);
39  }
40 
41  // if not, get the task that makes it and execute, we should have it then
42  auto task = m_task_provider->getTask<SourceTask>(property_id);
43  if (task) {
44  task->computeProperties(const_cast<SourceWithOnDemandProperties&>(*this));
45  return m_property_holder.getProperty(property_id);
46  }
47 
48  // no task available to make the property, just throw an exception
49  throw PropertyNotFoundException(property_id);
50 }
51 
53  // just forward to the ObjectWithProperties implementation
54  m_property_holder.setProperty(std::move(property), property_id);
55 }
56 
57 
58 } // SEFramework namespace
59 
SourceXtractor::SourceWithOnDemandProperties::SourceWithOnDemandProperties
SourceWithOnDemandProperties(const SourceWithOnDemandProperties &)=delete
std::shared_ptr
STL class.
SourceXtractor::SourceWithOnDemandProperties::m_property_holder
PropertyHolder m_property_holder
Definition: SourceWithOnDemandProperties.h:77
std::move
T move(T... args)
SourceXtractor::Property
Base class for all Properties. (has no actual content)
Definition: Property.h:33
SourceXtractor::SourceTask::computeProperties
virtual void computeProperties(SourceInterface &source) const =0
Computes one or more properties for the Source.
SourceXtractor::PropertyHolder::setProperty
void setProperty(std::unique_ptr< Property > property, const PropertyId &property_id)
Sets a property, overwriting it if necessary.
Definition: PropertyHolder.cpp:40
SourceXtractor::PropertyHolder::isPropertySet
bool isPropertySet(const PropertyId &property_id) const
Returns true if the property is set.
Definition: PropertyHolder.cpp:44
SourceXtractor::PropertyNotFoundException
An exception indicating that a Property was not available and could not be computed on demand.
Definition: PropertyNotFoundException.h:36
SourceXtractor::PropertyId
Identifier used to set and retrieve properties.
Definition: PropertyId.h:40
SourceXtractor::SourceWithOnDemandProperties::setProperty
virtual void setProperty(std::unique_ptr< Property > property, const PropertyId &property_id) override
Definition: SourceWithOnDemandProperties.cpp:52
SourceXtractor::PropertyHolder::getProperty
const Property & getProperty(const PropertyId &property_id) const
Returns a reference to a Property if it is set, if not throws a PropertyNotFoundException.
Definition: PropertyHolder.cpp:29
SourceXtractor
Definition: Aperture.h:30
SourceWithOnDemandProperties.h
TaskProvider.h
SourceXtractor::SourceWithOnDemandProperties::m_task_provider
std::shared_ptr< const TaskProvider > m_task_provider
Definition: SourceWithOnDemandProperties.h:76
SourceXtractor::SourceTask
A Task that acts on a Source to compute one or more properties.
Definition: SourceTask.h:36
SourceXtractor::SourceWithOnDemandProperties
Definition: SourceWithOnDemandProperties.h:43
SourceXtractor::SourceWithOnDemandProperties::getProperty
virtual const Property & getProperty(const PropertyId &property_id) const override
Definition: SourceWithOnDemandProperties.cpp:35
std::unique_ptr
STL class.
SourceTask.h
PropertyNotFoundException.h