SourceXtractorPlusPlus  0.8
Please provide a description of the project.
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
SourceGroupWithOnDemandProperties.h
Go to the documentation of this file.
1 
23 #ifndef _SEFRAMEWORK_SOURCE_SOURCEGROUP_H
24 #define _SEFRAMEWORK_SOURCE_SOURCEGROUP_H
25 
26 #include <set>
27 #include <iterator>
28 #include <type_traits>
29 
34 
35 namespace SourceXtractor {
36 
43 
44 public:
45 
47 
51  virtual ~SourceGroupWithOnDemandProperties() = default;
52 
53  iterator begin() override;
54 
55  iterator end() override;
56 
57  const_iterator cbegin() override;
58 
59  const_iterator cend() override;
60 
61  const_iterator begin() const override;
62 
63  const_iterator end() const override;
64 
65  void addSource(std::shared_ptr<SourceInterface> source) override;
66 
67  iterator removeSource(iterator pos) override;
68 
69  void merge(const SourceGroupInterface& other) override;
70 
71  unsigned int size() const override;
72 
75 
76 protected:
77 
78  const Property& getProperty(const PropertyId& property_id) const override;
79 
80  void setProperty(std::unique_ptr<Property> property, const PropertyId& property_id) override;
81 
82 private:
83 
84  class iter;
89 
90  void clearGroupProperties();
91 
92 }; /* End of SourceGroup class */
93 
94 
95 
97 
98 public:
99 
101 
102  virtual ~EntangledSource() = default;
103 
104  const Property& getProperty(const PropertyId& property_id) const override;
105 
106  void setProperty(std::unique_ptr<Property> property, const PropertyId& property_id) override;
107 
108  bool operator<(const EntangledSource& other) const;
109 
110 private:
111 
115 
118 
119 };
120 
121 
123 
124 public:
125 
127  : m_entangled_it(m_entangled_it) {
128  }
129 
130  virtual ~iter() = default;
131 
132  // Note to developers
133  // The std::set provides only constant iterator, because modifying its entries
134  // might mean that their ordering (which is used internally) might change. In
135  // our case we have no such problem, because the ordering of the EntangledSource
136  // is based on the pointer address of the encapsulated Source. This allows
137  // for the following const casts, so if the user iterates over a non-const
138  // SourceGroup he will get Sources on which he can call the setProperty().
139  SourceInterface& dereference() const override {
140  return const_cast<EntangledSource&>(*m_entangled_it);
141  }
142 
143  void increment() override {
144  ++m_entangled_it;
145  }
146 
147  void decrement() override {
148  --m_entangled_it;
149  }
150 
151  bool equal(const IteratorImpl& other) const override {
152  try {
153  auto& other_iter = dynamic_cast<const iter&>(other);
154  return this->m_entangled_it == other_iter.m_entangled_it;
155  } catch (...) {
156  return false;
157  }
158  }
159 
161  return std::make_shared<iter>(m_entangled_it);
162  }
163 
164 private:
165 
167 
169 
170 };
171 
172 } /* namespace SourceXtractor */
173 
174 #endif
void setProperty(std::unique_ptr< Property > property, const PropertyId &property_id) override
iter(std::list< EntangledSource >::iterator m_entangled_it)
void merge(const SourceGroupInterface &other) override
const PropertyType & getProperty(unsigned int index=0) const
Convenience template method to call getProperty() with a more user-friendly syntax.
A SourceGroupInterface implementation which used a TaskProvider to compute missing properties...
void addSource(std::shared_ptr< SourceInterface > source) override
SourceGroupWithOnDemandProperties(std::shared_ptr< TaskProvider > task_provider)
const Property & getProperty(const PropertyId &property_id) const override
Base class for all Properties. (has no actual content)
Definition: Property.h:33
void setProperty(std::unique_ptr< Property > property, const PropertyId &property_id) override
STL class.
Defines the interface used to group sources.
STL class.
Identifier used to set and retrieve properties.
Definition: PropertyId.h:40
virtual ~SourceGroupWithOnDemandProperties()=default
Destructor.
A class providing a simple implementation of a container of properties.
EntangledSource(std::shared_ptr< SourceInterface > source, SourceGroupWithOnDemandProperties &group)
The SourceInterface is an abstract &quot;source&quot; that has properties attached to it.
const Property & getProperty(const PropertyId &property_id) const override