<div dir="ltr">Hi Klaus<div><br></div><div>A major flaw of this solution is: you can't use the same strategy with different parameters.</div><div>Consider the following setup:</div><div><ul><li>namespace=/, strategy=/my-strategy/param=no</li><li>namespace=/A , strategy=/my-strategy/param=yes</li></ul></div><div><font face="monospace, monospace">StrategyChoice::getStrategy</font> returns the same instance (from m_strategyInstances), so that the second set of parameters would change the state of that instance, and affect both namespaces.</div><div>Since most simulations only deal with one strategy, this shouldn't cause big problems.<br></div><div><br></div><div>Given you are only using this in simulations, an easier approach is to pass the parameters with a ns3::GlobalVariable.</div><div><br></div><div>Yours, Junxiao<br><div class="gmail_extra"><br><div class="gmail_quote">On Sun, Apr 19, 2015 at 2:16 PM, Klaus Schneider <span dir="ltr"><<a href="mailto:klaus.schneider@uni-bamberg.de" target="_blank">klaus.schneider@uni-bamberg.de</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Here is my quick and dirty solution for including parameters in the strategy name.<br><br>
2. I changed StrategyChoice::getStrategy() in strategy-choice.cpp to<br>
<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
fw::Strategy*<br>
StrategyChoice::getStrategy(const Name& strategyName) const<br>
{<br>
fw::Strategy* candidate = nullptr;<br>
for (auto n : m_strategyInstances) {<br>
if (strategyName.isPrefixOf(n.first) || n.first.isPrefixOf(strategyName)) {<br>
switch (n.first.size() + 1 - strategyName.size()) {<br>
case 0: // Strategy with parameters (one element longer than exact match)<br>
<span style="background-color:rgb(244,204,204)">n.second->setParameters(strategyName.toUri().erase(0, n.first.toUri().size() + 1));</span><br>
return n.second.get();<br>
case 1: // exact match<br>
return n.second.get();<br>
case 2: // unversioned strategyName matches versioned strategy<br>
candidate = n.second.get();<br>
break;<br>
}<br>
}<br>
}<br>
return candidate;<br>
}</blockquote></blockquote></div></div></div></div>