#include "functor.hpp" namespace xmlioserver { namespace func { /// ////////////////////// Définitions ////////////////////// /// CFunctor::CFunctor(const StdString & id, ARRAY(double, 1) doutput, const CFunData & data, CFuncType type) : SuperClass(id) , doutput(doutput), size() , data(data), type(type) { this->resize(size); } CFunctor::CFunctor(const StdString & id, DoubleArray doutput, const std::vector size, const CFunData & data, CFuncType type) : SuperClass(id) , doutput(doutput), size(size) , data(data), type(type) { this->resize(size); } CFunctor::~CFunctor(void) { /* Ne rien faire de plus */ } //--------------------------------------------------------------- const CFunctor::CFunData & CFunctor::getData(void) const { return (this->data); } CFunctor::CFuncType CFunctor::getType(void) const { return (this->type); } ARRAY(double, 1) CFunctor::getDataOutput(void) const { return (this->doutput); } const std::vector & CFunctor::getShape(void) const { return (this->size); } StdSize CFunctor::getSize(void) const { return (this->doutput->size()); } //--------------------------------------------------------------- void CFunctor::resize(StdSize x, StdSize y, StdSize z) { this->size.clear(); this->size.push_back(x); if (y != 1) this->size.push_back(y); if (z != 1) this->size.push_back(z); this->doutput->resize(boost::extents[x * y * z]); } void CFunctor::resize(const std::vector & sizes) { StdSize newsize = 1; this->size.clear(); std::vector::const_iterator it = sizes.begin(), end = sizes.end(); for (; it!=end; it++) { StdSize size = *it; newsize *= size; this->size.push_back(size); } this->doutput->resize(boost::extents[newsize]); } //--------------------------------------------------------------- StdString CFunctor::toString(void) const { ERROR("CFunctor::toString()", << "Not implemented yet !"); return (SuperClass::getId()); } void CFunctor::fromString(const StdString & str) { ERROR("CFunctor::fromString(str)", << "[ str = " << str << "] Not implemented yet !"); } //--------------------------------------------------------------- ARRAY(double, 1) CFunctor::operator ()(const ARRAY(double, 1) dinput) { if (dinput->size() != this->doutput->size()) ERROR("CFunctor::operator ()(dinput)", << "[ input size = " << dinput->size() << ", output size = " << this->doutput->size() << " ]" << " size of input array != size of output array !"); this->apply(dinput, this->doutput, this->size, this->data); return (this->doutput); } //--------------------------------------------------------------- } // namespace func } // namespace xmlioserver