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