SourceXtractorPlusPlus 0.21
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#include <list>
27
28namespace SourceXtractor {
29
39
40 template <typename Collection>
42
43public:
44
46 public:
47
49
51
53
54 const Property& getProperty(const PropertyId& property_id) const override {
55 return m_source->getProperty(property_id);
56 }
57
61
62 bool operator<(const SourceWrapper& other) const {
63 return this->m_source < other.m_source;
64 }
65
67 return *m_source;
68 }
69
73
74 private:
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
90 virtual void merge(SourceGroupInterface&& other) = 0;
91 virtual unsigned int size() const = 0;
92
94 template <typename SourceCollection>
97 "SourceCollection must be a collection of std::shared_ptr to SourceInterface or a type that inherits from it");
98 for (auto& source : sources) {
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.
111
112}; // end of SourceGroupInterface class
113
114} /* namespace SourceXtractor */
115
116#endif /* _SEFRAMEWORK_SOURCEGROUPINTERFACE_H */
117
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.