SourceXtractorPlusPlus
0.14
Please provide a description of the project.
Main Page
Related Pages
Namespaces
Classes
Files
File List
File Members
All
Classes
Namespaces
Files
Functions
Variables
Typedefs
Enumerations
Enumerator
Friends
Macros
Groups
Pages
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
// This is used to determine if a type is a kind of std::shared_ptr
43
template
<
class
T>
44
struct
is_shared_ptr
:
std::false_type
{};
45
template
<
class
T>
46
struct
is_shared_ptr
<std::
shared_ptr
<T>> :
std::true_type
{};
47
48
public
:
49
50
class
SourceWrapper
:
public
SourceInterface
{
51
public
:
52
53
SourceWrapper
(
std::shared_ptr<SourceInterface>
source) :
m_source
(source) {}
54
55
SourceWrapper
(
const
SourceWrapper
& source) :
m_source
(source.
m_source
) {}
56
57
const
Property
&
getProperty
(
const
PropertyId
& property_id)
const override
{
58
return
m_source
->getProperty(property_id);
59
}
60
61
void
setProperty
(
std::unique_ptr<Property>
property,
const
PropertyId
& property_id)
override
{
62
m_source
->setProperty(
std::move
(property), property_id);
63
}
64
65
bool
operator<
(
const
SourceWrapper
& other)
const
{
66
return
this->
m_source
< other.
m_source
;
67
}
68
69
SourceInterface
&
getRef
()
const
{
70
return
*
m_source
;
71
}
72
73
using
SourceInterface::getProperty
;
74
using
SourceInterface::setProperty
;
75
using
SourceInterface::setIndexedProperty
;
76
77
private
:
78
std::shared_ptr<SourceInterface>
m_source
;
79
};
80
81
using
iterator
=
std::list<SourceWrapper>::iterator
;
82
using
const_iterator
=
std::list<SourceWrapper>::const_iterator
;
83
84
virtual
iterator
begin
() = 0;
85
virtual
iterator
end
() = 0;
86
virtual
const_iterator
cbegin
() = 0;
87
virtual
const_iterator
cend
() = 0;
88
virtual
const_iterator
begin
()
const
= 0;
89
virtual
const_iterator
end
()
const
= 0;
90
91
virtual
void
addSource
(
std::shared_ptr<SourceInterface>
source) = 0;
92
virtual
iterator
removeSource
(
iterator
pos) = 0;
93
virtual
void
merge
(
const
SourceGroupInterface
& other) = 0;
94
virtual
unsigned
int
size
()
const
= 0;
95
97
template
<
typename
SourceCollection>
98
void
addAllSources
(
const
SourceCollection& sources) {
99
static_assert(
is_shared_ptr
<
CollectionType<SourceCollection>
>::value,
100
"SourceCollection must be a collection of std::shared_ptr"
);
101
static_assert(
std::is_base_of
<
SourceInterface
,
typename
CollectionType<SourceCollection>::element_type
>::value,
102
"SourceCollection must be a collection of std::shared_ptr to SourceInterface or a type that inherits from it"
);
103
for
(
auto
& source : sources) {
104
addSource
(source);
105
}
106
}
107
108
// We introduce the get/setProperty methods from the SourceInterface in the
109
// public symbols so they become part of the SourceGroupInterface. The group
110
// implementations must implement the methods with the PropertyId
111
// in their signature.
112
using
SourceInterface::getProperty
;
113
using
SourceInterface::setProperty
;
114
using
SourceInterface::setIndexedProperty
;
115
116
};
// end of SourceGroupInterface class
117
118
}
/* namespace SourceXtractor */
119
120
#endif
/* _SEFRAMEWORK_SOURCEGROUPINTERFACE_H */
121
SourceXtractor::SourceGroupInterface::SourceWrapper
Definition:
SourceGroupInterface.h:50
std::shared_ptr
SourceXtractor::SourceGroupInterface::is_shared_ptr
Definition:
SourceGroupInterface.h:44
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::SourceGroupInterface::cend
virtual const_iterator cend()=0
SourceXtractor::SourceGroupInterface::SourceWrapper::setProperty
void setProperty(std::unique_ptr< Property > property, const PropertyId &property_id) override
Definition:
SourceGroupInterface.h:61
SourceXtractor::SourceGroupInterface::iterator
std::list< SourceWrapper >::iterator iterator
Definition:
SourceGroupInterface.h:81
SourceXtractor::SourceGroupInterface::cbegin
virtual const_iterator cbegin()=0
SourceXtractor::SourceGroupInterface::SourceWrapper::getProperty
const Property & getProperty(const PropertyId &property_id) const override
Definition:
SourceGroupInterface.h:57
SourceXtractor::SourceGroupInterface::SourceWrapper::SourceWrapper
SourceWrapper(std::shared_ptr< SourceInterface > source)
Definition:
SourceGroupInterface.h:53
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::SourceGroupInterface::SourceWrapper::operator<
bool operator<(const SourceWrapper &other) const
Definition:
SourceGroupInterface.h:65
SourceXtractor::SourceGroupInterface::addSource
virtual void addSource(std::shared_ptr< SourceInterface > source)=0
SourceXtractor::Property
Base class for all Properties. (has no actual content)
Definition:
Property.h:33
SourceXtractor::SourceGroupInterface::merge
virtual void merge(const SourceGroupInterface &other)=0
SourceXtractor::SourceInterface::setProperty
void setProperty(Args...args)
Definition:
SourceInterface.h:72
std::iterator_traits
std::list
STL class.
std::move
T move(T...args)
SourceInterface.h
SourceXtractor::SourceGroupInterface
Defines the interface used to group sources.
Definition:
SourceGroupInterface.h:37
SourceXtractor::SourceGroupInterface::SourceWrapper::m_source
std::shared_ptr< SourceInterface > m_source
Definition:
SourceGroupInterface.h:78
SourceXtractor::SourceGroupInterface::CollectionType
typename std::iterator_traits< typename Collection::iterator >::value_type CollectionType
Definition:
SourceGroupInterface.h:40
SourceXtractor::SourceGroupInterface::addAllSources
void addAllSources(const SourceCollection &sources)
Convenient method to add all the sources of a collection.
Definition:
SourceGroupInterface.h:98
std::unique_ptr
STL class.
SourceXtractor::PropertyId
Identifier used to set and retrieve properties.
Definition:
PropertyId.h:40
std::false_type
SourceXtractor::SourceGroupInterface::const_iterator
std::list< SourceWrapper >::const_iterator const_iterator
Definition:
SourceGroupInterface.h:82
SourceXtractor::SourceGroupInterface::end
virtual iterator end()=0
std::is_base_of
SourceXtractor::SourceGroupInterface::begin
virtual iterator begin()=0
SourceXtractor::SourceGroupInterface::removeSource
virtual iterator removeSource(iterator pos)=0
SourceXtractor::SourceInterface
The SourceInterface is an abstract "source" that has properties attached to it.
Definition:
SourceInterface.h:46
SourceXtractor::SourceGroupInterface::size
virtual unsigned int size() const =0
SourceXtractor::SourceGroupInterface::SourceWrapper::getRef
SourceInterface & getRef() const
Definition:
SourceGroupInterface.h:69
SourceXtractor::SourceGroupInterface::SourceWrapper::SourceWrapper
SourceWrapper(const SourceWrapper &source)
Definition:
SourceGroupInterface.h:55
Generated by
1.8.5