Skip to content
Snippets Groups Projects
Commit 7147fdad authored by zwart's avatar zwart
Browse files

BugID: 719

Fixed bug in RoundRobin
parent 5d1c9ed5
No related branches found
No related tags found
No related merge requests found
......@@ -30,7 +30,8 @@ namespace LOFAR
{
Sel_RoundRobin::Sel_RoundRobin(unsigned int noOptions)
: Selector(noOptions)
: Selector(noOptions),
itsSelectedIndex(0)
{
for (unsigned i = 0; i < noOptions; i ++)
itsOptions.push_back(i);
......@@ -38,7 +39,8 @@ Sel_RoundRobin::Sel_RoundRobin(unsigned int noOptions)
Sel_RoundRobin::Sel_RoundRobin(std::vector<int> &options)
: Selector(options.size()),
itsOptions(options)
itsOptions(options),
itsSelectedIndex(0)
{}
Sel_RoundRobin::~Sel_RoundRobin()
......@@ -46,7 +48,8 @@ Sel_RoundRobin::~Sel_RoundRobin()
Sel_RoundRobin::Sel_RoundRobin(const Sel_RoundRobin& that)
: Selector(that),
itsOptions(that.itsOptions)
itsOptions(that.itsOptions),
itsSelectedIndex(that.itsSelectedIndex)
{}
Selector* Sel_RoundRobin::clone() const
......@@ -56,12 +59,13 @@ Selector* Sel_RoundRobin::clone() const
unsigned int Sel_RoundRobin::getNext()
{
itsCurrentSelection++;
if (itsCurrentSelection >= (int)itsNOptions)
itsSelectedIndex++;
if (itsSelectedIndex >= (int)itsNOptions)
{
itsCurrentSelection = 0;
itsSelectedIndex = 0;
}
return itsOptions[itsCurrentSelection];
itsCurrentSelection = itsOptions[itsSelectedIndex];
return itsCurrentSelection;
}
}
......@@ -57,6 +57,7 @@ private:
Sel_RoundRobin(const Sel_RoundRobin&);
std::vector<int> itsOptions;
int itsSelectedIndex;
};
// @}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment