SourceXtractorPlusPlus  0.8
Please provide a description of the project.
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
SimpleSourceGroup.h
Go to the documentation of this file.
1 
17 /*
18  * @file SimpleSourceGroup.h
19  * @author nikoapos
20  */
21 
22 #ifndef _SEFRAMEWORK_SIMPLESOURCEGROUP_H
23 #define _SEFRAMEWORK_SIMPLESOURCEGROUP_H
24 
25 #include <list>
26 
29 
30 namespace SourceXtractor {
31 
40 
41 public:
42 
43  virtual ~SimpleSourceGroup() = default;
44 
45  iterator begin() override;
46 
47  iterator end() override;
48 
49  const_iterator cbegin() override;
50 
51  const_iterator cend() override;
52 
53  const_iterator begin() const override;
54 
55  const_iterator end() const override;
56 
57  void addSource(std::shared_ptr<SourceInterface> source) override;
58 
59  iterator removeSource(iterator pos) override;
60 
61  unsigned int size() const override;
62 
63  void merge(const SourceGroupInterface& other) override;
64 
67 
68 protected:
69 
70  const Property& getProperty(const PropertyId& property_id) const override;
71 
72  void setProperty(std::unique_ptr<Property> property, const PropertyId& property_id) override;
73 
74 private:
75 
76  class iter;
79 
80 }; /* End of SimpleSourceGroup class */
81 
82 
84 
85 public:
87  : m_wrapped_it(wrapped_it) {
88  }
89 
90  virtual ~iter() = default;
91 
92  SourceInterface& dereference() const override {
93  return const_cast<SourceInterface&>(**m_wrapped_it);
94  }
95 
96  void increment() override {
97  ++m_wrapped_it;
98  }
99 
100  void decrement() override {
101  --m_wrapped_it;
102  }
103 
104  bool equal(const IteratorImpl& other) const override {
105  try {
106  auto& other_iter = dynamic_cast<const iter&>(other);
107  return this->m_wrapped_it == other_iter.m_wrapped_it;
108  } catch (...) {
109  return false;
110  }
111  }
112 
114  return std::make_shared<iter>(m_wrapped_it);
115  }
116 
117 
118 private:
119 
121 
123 
124 };
125 
126 } /* namespace SourceXtractor */
127 
128 #endif /* _SEFRAMEWORK_SIMPLESOURCEGROUP_H */
129 
bool equal(const IteratorImpl &other) const override
void addSource(std::shared_ptr< SourceInterface > source) override
const PropertyType & getProperty(unsigned int index=0) const
Convenience template method to call getProperty() with a more user-friendly syntax.
virtual ~SimpleSourceGroup()=default
iter(std::list< std::shared_ptr< SourceInterface >>::iterator wrapped_it)
SourceInterface & dereference() const override
std::list< std::shared_ptr< SourceInterface > >::iterator m_wrapped_it
unsigned int size() const override
const_iterator cend() override
Base class for all Properties. (has no actual content)
Definition: Property.h:33
iterator removeSource(iterator pos) override
A bare bones implementation of SourceGroupInterface meant to be used to implement unit tests...
void merge(const SourceGroupInterface &other) override
STL class.
Defines the interface used to group sources.
STL class.
Identifier used to set and retrieve properties.
Definition: PropertyId.h:40
const_iterator cbegin() override
const Property & getProperty(const PropertyId &property_id) const override
A class providing a simple implementation of a container of properties.
std::list< std::shared_ptr< SourceInterface > > m_sources
The SourceInterface is an abstract &quot;source&quot; that has properties attached to it.
std::shared_ptr< IteratorImpl > clone() const override
void setProperty(std::unique_ptr< Property > property, const PropertyId &property_id) override