feat: encoding accessor in foundry & less constrained forge setup

Allow forge setup to be called on nullptr and have an empty constructor
setup. Useful to build up forge vectors in one pass instead of add/setup
loops.
This commit is contained in:
Johann Dreo 2020-04-22 07:55:56 +02:00
commit 5a64a1755a
2 changed files with 18 additions and 2 deletions

View file

@ -62,6 +62,11 @@ class eoAlgoFoundry : public eoAlgo<EOT>
return _size;
}
std::vector<size_t> encoding() const
{
return _encoding;
}
protected:
const size_t _size;
std::vector<size_t> _encoding;

View file

@ -265,12 +265,23 @@ class eoForgeVector : public std::vector<eoForgeInterface<Itf>*>
template<class Op, typename... Args>
void setup(size_t index, Args... args)
{
assert(this->at(index) != nullptr);
delete this->at(index);
assert(index < this->size());
delete this->at(index); // Silent on nullptr.
auto pfo = new eoForgeOperator<Itf,Op,Args...>(args...);
this->at(index) = pfo;
}
/** Specialization for empty constructors.
*/
template<class Op>
void setup(size_t index)
{
assert(index < this->size());
delete this->at(index);
auto pfo = new eoForgeOperator<Itf,Op>;
this->at(index) = pfo;
}
/** Instanciate the operator managed at the given index.
*/
Itf& instanciate(size_t index)