55 typedef std::pair<index_t, T*> entry_t;
65 T & getCloned()
const = 0;
68 entry_t getClonerEntry()
const = 0;
91 size_t count()
const = 0;
116 template <
class B,
class S>
125 typedef typename clonerbase_t::entry_t entry_t;
127 typedef std::map<index_t,S *> ptr_container_t;
142 for (
typename ptr_container_t::iterator it=ptrs.begin(); it!= ptrs.end(); ++it){
175 typename ptr_container_t::iterator it = ptrs.find(i);
176 if (it == ptrs.end()){
177 std::stringstream sstr;
178 sstr << __FILE__ <<
':' << __FUNCTION__ <<
": index not found: "<< i;
179 throw std::runtime_error(sstr.str());
195 entry_t getClonerEntry()
const {
199 return entry_t(i, ptr);
243 size_t count()
const {
252 const typename ptr_container_t::iterator it = ptrs.find(i);
254 if (it != ptrs.end()){
262 std::cerr <<
"already deleted or does not exist: " << i <<
'\n';
298 if (this->ptrs.empty())
302 return this->ptrs.rbegin()->first + 1;
309 ptr_container_t ptrs;
Definition: DataSelector.cpp:1277
size_t index_t
Each cloned entry has an index.
Definition: Cloner.h:52
virtual T & getCloned(index_t i) const =0
Returns an instance at index i.
virtual T & getSource()=0
Returns a reference to an instance.
virtual bool drop(index_t i) const =0
Remove cloned entry (experimental)
virtual const T & getSource() const =0
Returns a reference to an instance (possibly a static one?).
Wrapper for derived class S, returning base class T.
Definition: Cloner.h:117
index_t getNewIndex() const
Remove cloned entries.
Definition: Cloner.h:295
virtual const B & getSource() const
Returns a const reference to a default instance.
Definition: Cloner.h:210
S src
Default instance, also the source for cloning.
Definition: Cloner.h:274
Cloner(const S &s)
Constructor with source object (copied)
Definition: Cloner.h:137
Cloner(const Cloner< B, S > &c)
Copy constructor.
Definition: Cloner.h:133
B & getCloned() const
Implements interface.
Definition: Cloner.h:149
virtual bool drop(index_t i) const
Remove cloned entry.
Definition: Cloner.h:250
S & getClonedSrc() const
Returns a object of class S, initialized with the source.
Definition: Cloner.h:186
virtual const S & getSourceOrig() const
Returns a const reference to a default instance, in actual class.
Definition: Cloner.h:228
virtual B & getSource()
Returns a reference to a default instance.
Definition: Cloner.h:219
virtual S & getSourceOrig()
Returns a reference to a default instance, in actual class.
Definition: Cloner.h:237
virtual B & getCloned(index_t i) const
Returns.
Definition: Cloner.h:174