SourceXtractorPlusPlus
0.21
SourceXtractor++, the next generation SExtractor
Loading...
Searching...
No Matches
SEFramework
src
lib
Source
SourceWithOnDemandProperties.cpp
Go to the documentation of this file.
1
23
#include "ElementsKernel/Logging.h"
24
25
#include "
SEFramework/Task/TaskProvider.h
"
26
#include "
SEFramework/Task/SourceTask.h
"
27
#include "
SEFramework/Property/PropertyNotFoundException.h
"
28
29
#include "
SEFramework/Source/SourceWithOnDemandProperties.h
"
30
31
namespace
SourceXtractor
{
32
33
static
Elements::Logging
logger
=
Elements::Logging::getLogger
(
"SourceWithOnDemandProperties"
);
34
35
SourceWithOnDemandProperties::SourceWithOnDemandProperties
(
std::shared_ptr<const TaskProvider>
task_provider) :
36
m_task_provider(task_provider) {
37
}
38
39
const
Property
&
SourceWithOnDemandProperties::getProperty
(
const
PropertyId
&
property_id
)
const
{
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
61
void
SourceWithOnDemandProperties::setProperty
(
std::unique_ptr<Property>
property
,
const
PropertyId
&
property_id
) {
62
// just forward to the ObjectWithProperties implementation
63
m_property_holder
.
setProperty
(
std::move
(
property
),
property_id
);
64
}
65
66
67
}
// SEFramework namespace
68
PropertyNotFoundException.h
SourceTask.h
SourceWithOnDemandProperties.h
TaskProvider.h
Elements::Exception
Elements::Logging
Elements::Logging::debug
void debug(const std::string &logMessage)
Elements::Logging::getLogger
static Logging getLogger(const std::string &name="")
SourceXtractor::PropertyHolder::isPropertySet
bool isPropertySet(const PropertyId &property_id) const
Returns true if the property is set.
Definition
PropertyHolder.cpp:44
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::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::PropertyId
Identifier used to set and retrieve properties.
Definition
PropertyId.h:40
SourceXtractor::PropertyNotFoundException
An exception indicating that a Property was not available and could not be computed on demand.
Definition
PropertyNotFoundException.h:36
SourceXtractor::Property
Base class for all Properties. (has no actual content)
Definition
Property.h:33
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::m_task_provider
std::shared_ptr< const TaskProvider > m_task_provider
Definition
SourceWithOnDemandProperties.h:76
SourceXtractor::SourceWithOnDemandProperties::m_property_holder
PropertyHolder m_property_holder
Definition
SourceWithOnDemandProperties.h:77
SourceXtractor::SourceWithOnDemandProperties::SourceWithOnDemandProperties
SourceWithOnDemandProperties(const SourceWithOnDemandProperties &)=delete
SourceXtractor::SourceWithOnDemandProperties::getProperty
const Property & getProperty(const PropertyId &property_id) const override
Definition
SourceWithOnDemandProperties.cpp:39
SourceXtractor::SourceWithOnDemandProperties::setProperty
void setProperty(std::unique_ptr< Property > property, const PropertyId &property_id) override
Definition
SourceWithOnDemandProperties.cpp:61
std::function
std::move
T move(T... args)
Euclid::Configuration::logger
static Elements::Logging logger
SourceXtractor
Definition
Aperture.h:30
Generated by
1.10.0