SourceXtractorPlusPlus 0.19
SourceXtractor++, the next generation SExtractor
Loading...
Searching...
No Matches
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
26
27namespace SourceXtractor {
28
38
39 template <typename Collection>
41
42public:
43
45 public:
46
48
49 SourceWrapper(const SourceWrapper& source) = delete;
50
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
66 return *m_source;
67 }
68
72
73 private:
75 };
76
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
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) {
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.
110
111}; // end of SourceGroupInterface class
112
113} /* namespace SourceXtractor */
114
115#endif /* _SEFRAMEWORK_SOURCEGROUPINTERFACE_H */
116
Identifier used to set and retrieve properties.
Definition: PropertyId.h:40
Base class for all Properties. (has no actual content)
Definition: Property.h:33
const Property & getProperty(const PropertyId &property_id) const override
SourceWrapper(const SourceWrapper &source)=delete
bool operator<(const SourceWrapper &other) const
SourceWrapper(std::unique_ptr< SourceInterface > source)
void setProperty(std::unique_ptr< Property > property, const PropertyId &property_id) override
Defines the interface used to group sources.
virtual iterator removeSource(iterator pos)=0
void addAllSources(SourceCollection &&sources)
Convenient method to add all the sources of a collection.
virtual void merge(SourceGroupInterface &&other)=0
std::list< SourceWrapper >::const_iterator const_iterator
virtual const_iterator end() const =0
virtual const_iterator cend() const =0
std::list< SourceWrapper >::iterator iterator
typename std::iterator_traits< typename Collection::iterator >::value_type CollectionType
virtual const_iterator begin() const =0
virtual unsigned int size() const =0
virtual void addSource(std::unique_ptr< SourceInterface > source)=0
virtual const_iterator cbegin() const =0
The SourceInterface is an abstract "source" that has properties attached to it.
void setIndexedProperty(std::size_t index, Args... args)
Convenience template method to call setProperty() with a more user-friendly syntax.
const PropertyType & getProperty(unsigned int index=0) const
Convenience template method to call getProperty() with a more user-friendly syntax.
T move(T... args)
STL namespace.