SourceXtractorPlusPlus
0.19
SourceXtractor++, the next generation SExtractor
Loading...
Searching...
No Matches
SEFramework
SEFramework
Source
SourceGroupInterface.h
Go to the documentation of this file.
1
17
/*
18
* @file SourceGroupInterface.h
19
* @author nikoapos
20
*/
21
22
#ifndef _SEFRAMEWORK_SOURCEGROUPINTERFACE_H
23
#define _SEFRAMEWORK_SOURCEGROUPINTERFACE_H
24
25
#include "
SEFramework/Source/SourceInterface.h
"
26
27
namespace
SourceXtractor
{
28
37
class
SourceGroupInterface
:
protected
SourceInterface
{
38
39
template
<
typename
Collection>
40
using
CollectionType
=
typename
std::iterator_traits<typename Collection::iterator>::value_type
;
41
42
public
:
43
44
class
SourceWrapper
:
public
SourceInterface
{
45
public
:
46
47
explicit
SourceWrapper
(
std::unique_ptr<SourceInterface>
source) :
m_source
(
std
::
move
(source)) {}
48
49
SourceWrapper
(
const
SourceWrapper
& source) =
delete
;
50
51
SourceWrapper
(
SourceWrapper
&&) =
default
;
52
53
const
Property
&
getProperty
(
const
PropertyId
& property_id)
const override
{
54
return
m_source
->getProperty(property_id);
55
}
56
57
void
setProperty
(
std::unique_ptr<Property>
property,
const
PropertyId
& property_id)
override
{
58
m_source
->setProperty(
std::move
(property), property_id);
59
}
60
61
bool
operator<
(
const
SourceWrapper
& other)
const
{
62
return
this->
m_source
< other.
m_source
;
63
}
64
65
SourceInterface
&
getRef
()
const
{
66
return
*
m_source
;
67
}
68
69
using
SourceInterface::getProperty
;
70
using
SourceInterface::setProperty
;
71
using
SourceInterface::setIndexedProperty
;
72
73
private
:
74
std::unique_ptr<SourceInterface>
m_source
;
75
};
76
77
using
iterator
=
std::list<SourceWrapper>::iterator
;
78
using
const_iterator
=
std::list<SourceWrapper>::const_iterator
;
79
80
virtual
iterator
begin
() = 0;
81
virtual
iterator
end
() = 0;
82
virtual
const_iterator
cbegin
()
const
= 0;
83
virtual
const_iterator
cend
()
const
= 0;
84
virtual
const_iterator
begin
()
const
= 0;
85
virtual
const_iterator
end
()
const
= 0;
86
87
virtual
void
addSource
(
std::unique_ptr<SourceInterface>
source) = 0;
88
virtual
iterator
removeSource
(
iterator
pos) = 0;
89
virtual
void
merge
(
SourceGroupInterface
&& other) = 0;
90
virtual
unsigned
int
size
()
const
= 0;
91
93
template
<
typename
SourceCollection>
94
void
addAllSources
(SourceCollection&& sources) {
95
static_assert
(
std::is_base_of<SourceInterface, typename CollectionType<SourceCollection>::element_type
>::value,
96
"SourceCollection must be a collection of std::shared_ptr to SourceInterface or a type that inherits from it"
);
97
for
(
auto
& source : sources) {
98
addSource
(
std::move
(source));
99
}
100
sources.clear();
101
}
102
103
// We introduce the get/setProperty methods from the SourceInterface in the
104
// public symbols so they become part of the SourceGroupInterface. The group
105
// implementations must implement the methods with the PropertyId
106
// in their signature.
107
using
SourceInterface::getProperty
;
108
using
SourceInterface::setProperty
;
109
using
SourceInterface::setIndexedProperty
;
110
111
};
// end of SourceGroupInterface class
112
113
}
/* namespace SourceXtractor */
114
115
#endif
/* _SEFRAMEWORK_SOURCEGROUPINTERFACE_H */
116
SourceInterface.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::SourceGroupInterface::SourceWrapper
Definition:
SourceGroupInterface.h:44
SourceXtractor::SourceGroupInterface::SourceWrapper::getProperty
const Property & getProperty(const PropertyId &property_id) const override
Definition:
SourceGroupInterface.h:53
SourceXtractor::SourceGroupInterface::SourceWrapper::SourceWrapper
SourceWrapper(const SourceWrapper &source)=delete
SourceXtractor::SourceGroupInterface::SourceWrapper::operator<
bool operator<(const SourceWrapper &other) const
Definition:
SourceGroupInterface.h:61
SourceXtractor::SourceGroupInterface::SourceWrapper::getRef
SourceInterface & getRef() const
Definition:
SourceGroupInterface.h:65
SourceXtractor::SourceGroupInterface::SourceWrapper::m_source
std::unique_ptr< SourceInterface > m_source
Definition:
SourceGroupInterface.h:74
SourceXtractor::SourceGroupInterface::SourceWrapper::SourceWrapper
SourceWrapper(std::unique_ptr< SourceInterface > source)
Definition:
SourceGroupInterface.h:47
SourceXtractor::SourceGroupInterface::SourceWrapper::setProperty
void setProperty(std::unique_ptr< Property > property, const PropertyId &property_id) override
Definition:
SourceGroupInterface.h:57
SourceXtractor::SourceGroupInterface::SourceWrapper::SourceWrapper
SourceWrapper(SourceWrapper &&)=default
SourceXtractor::SourceGroupInterface
Defines the interface used to group sources.
Definition:
SourceGroupInterface.h:37
SourceXtractor::SourceGroupInterface::removeSource
virtual iterator removeSource(iterator pos)=0
SourceXtractor::SourceGroupInterface::addAllSources
void addAllSources(SourceCollection &&sources)
Convenient method to add all the sources of a collection.
Definition:
SourceGroupInterface.h:94
SourceXtractor::SourceGroupInterface::merge
virtual void merge(SourceGroupInterface &&other)=0
SourceXtractor::SourceGroupInterface::const_iterator
std::list< SourceWrapper >::const_iterator const_iterator
Definition:
SourceGroupInterface.h:78
SourceXtractor::SourceGroupInterface::end
virtual const_iterator end() const =0
SourceXtractor::SourceGroupInterface::cend
virtual const_iterator cend() const =0
SourceXtractor::SourceGroupInterface::iterator
std::list< SourceWrapper >::iterator iterator
Definition:
SourceGroupInterface.h:77
SourceXtractor::SourceGroupInterface::CollectionType
typename std::iterator_traits< typename Collection::iterator >::value_type CollectionType
Definition:
SourceGroupInterface.h:40
SourceXtractor::SourceGroupInterface::begin
virtual iterator begin()=0
SourceXtractor::SourceGroupInterface::end
virtual iterator end()=0
SourceXtractor::SourceGroupInterface::begin
virtual const_iterator begin() const =0
SourceXtractor::SourceGroupInterface::size
virtual unsigned int size() const =0
SourceXtractor::SourceGroupInterface::addSource
virtual void addSource(std::unique_ptr< SourceInterface > source)=0
SourceXtractor::SourceGroupInterface::cbegin
virtual const_iterator cbegin() const =0
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::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
std::is_base_of
std::iterator_traits
std::list
std::move
T move(T... args)
SourceXtractor
Definition:
Aperture.h:30
std
STL namespace.
std::unique_ptr
Generated by
1.9.5