Main Page | Modules | Namespace List | Class Hierarchy | Alphabetical List | Class List | File List | Namespace Members | Class Members | Related Pages | Search for

# eoSelectMany.h

    00001
    00025 //-----------------------------------------------------------------------------
    00026
    00027 #ifndef _eoSelectMany_h
    00028 #define _eoSelectMany_h
    00029
    00030
    00031 //-----------------------------------------------------------------------------
    00032 #include <eoSelect.h>
    00033 #include <eoSelectOne.h>
    00034 #include <utils/eoHowMany.h>
    00035 #include <math.h>
    00036 //-----------------------------------------------------------------------------
    00037
    00044 template<class EOT>
    00045 class eoSelectMany : public eoSelect<EOT>
    00046 {
    00047  public:
    00049      eoSelectMany(eoSelectOne<EOT>& _select,
    00050                     double  _rate, bool _interpret_as_rate = true)
    00051          : select(_select), howMany(_rate, _interpret_as_rate) {}
    00052
    00053      // Ctor with eoHowMany
    00054      eoSelectMany(eoSelectOne<EOT>& _select, eoHowMany _howMany)
    00055          : select(_select), howMany(_howMany) {}
    00056
    00063   virtual void operator()(const eoPop<EOT>& _source, eoPop<EOT>& _dest)
    00064   {
    00065     unsigned target = howMany(_source.size());
    00066
    00067     _dest.resize(target);
    00068
    00069     select.setup(_source);
    00070
    00071     for (size_t i = 0; i < _dest.size(); ++i)
    00072       _dest[i] = select(_source);
    00073   }
    00074
    00075 private :
    00076   eoSelectOne<EOT>& select;
    00077   eoHowMany howMany;
    00078 };
    00079
    00080 #endif