SourceXtractorPlusPlus
0.21
SourceXtractor++, the next generation SExtractor
Loading...
Searching...
No Matches
SEFramework
SEFramework
Source
SourceInterface.h
Go to the documentation of this file.
1
23
#ifndef _SEFRAMEWORK_SOURCE_SOURCEINTERFACE_H
24
#define _SEFRAMEWORK_SOURCE_SOURCEINTERFACE_H
25
26
#include <memory>
27
#include <type_traits>
28
29
#include "
SEFramework/Property/PropertyId.h
"
30
#include "
SEFramework/Property/PropertyNotFoundException.h
"
31
#include "
SEFramework/Property/Property.h
"
32
33
namespace
SourceXtractor
{
34
46
class
SourceInterface
{
47
48
public
:
49
53
virtual
~SourceInterface
() =
default
;
54
56
template
<
typename
PropertyType>
57
const
PropertyType
&
getProperty
(
unsigned
int
index = 0)
const
{
58
static_assert
(
std::is_base_of<Property, PropertyType>::value
,
"PropertyType must inherit from SourceXtractor::Property"
);
59
return
dynamic_cast<
const
PropertyType
&
>
(
getProperty
(PropertyId::create<PropertyType>(index)));
60
}
61
63
template
<
typename
PropertyType
,
typename
...
Args
>
64
void
setIndexedProperty
(
std::size_t
index,
Args
...
args
) {
65
static_assert
(
std::is_base_of<Property, PropertyType>::value
,
"PropertyType must inherit from SourceXtractor::Property"
);
66
static_assert
(
std::is_constructible
<
PropertyType
,
Args
...>::value,
"PropertyType must be constructible from args"
);
67
setProperty
(
std::unique_ptr<PropertyType>
{
new
PropertyType
(
std::forward<Args>
(
args
)...)},
68
PropertyId::create<PropertyType>(index));
69
}
70
71
template
<
typename
PropertyType
,
typename
...
Args
>
72
void
setProperty
(
Args
...
args
) {
73
setIndexedProperty<PropertyType>
(0,
std::forward<Args>
(
args
)...);
74
}
75
78
virtual
const
Property
&
getProperty
(
const
PropertyId
&
property_id
)
const
= 0;
79
virtual
void
setProperty
(
std::unique_ptr<Property>
property
,
const
PropertyId
&
property_id
) = 0;
80
81
};
/* End of SourceInterface class */
82
83
}
/* namespace SourceXtractor */
84
85
86
#endif
PropertyId.h
PropertyNotFoundException.h
Property.h
SourceXtractor::PropertyId
Identifier used to set and retrieve properties.
Definition
PropertyId.h:40
SourceXtractor::Property
Base class for all Properties. (has no actual content)
Definition
Property.h:33
SourceXtractor::SourceInterface
The SourceInterface is an abstract "source" that has properties attached to it.
Definition
SourceInterface.h:46
SourceXtractor::SourceInterface::setProperty
void setProperty(Args... args)
Definition
SourceInterface.h:72
SourceXtractor::SourceInterface::setIndexedProperty
void setIndexedProperty(std::size_t index, Args... args)
Convenience template method to call setProperty() with a more user-friendly syntax.
Definition
SourceInterface.h:64
SourceXtractor::SourceInterface::~SourceInterface
virtual ~SourceInterface()=default
Destructor.
SourceXtractor::SourceInterface::getProperty
virtual const Property & getProperty(const PropertyId &property_id) const =0
SourceXtractor::SourceInterface::getProperty
const PropertyType & getProperty(unsigned int index=0) const
Convenience template method to call getProperty() with a more user-friendly syntax.
Definition
SourceInterface.h:57
SourceXtractor::SourceInterface::setProperty
virtual void setProperty(std::unique_ptr< Property > property, const PropertyId &property_id)=0
std::function
std::is_base_of
std::is_constructible
SourceXtractor
Definition
Aperture.h:30
std::size_t
Generated by
1.10.0