25 #ifndef WSTRATEGYHELPER_H
26 #define WSTRATEGYHELPER_H
31 #include <boost/shared_ptr.hpp>
32 #include <boost/thread.hpp>
35 #include "WItemSelection.h"
36 #include "WItemSelector.h"
37 #include "WSharedSequenceContainer.h"
38 #include "WProperties.h"
39 #include "WPropertyHelper.h"
67 template<
class StrategyType >
74 typedef boost::shared_ptr< WStrategyHelper >
SPtr;
79 typedef boost::shared_ptr< const WStrategyHelper >
ConstSPtr;
90 WStrategyHelper( std::string name, std::string description,
const char** icon = NULL, std::string selectorName = std::string(),
91 std::string selectorDescription = std::string() );
132 void addStrategy(
typename StrategyType::SPtr strategy );
139 typename StrategyType::ConstSPtr
operator()()
const;
191 template<
typename StrategyType >
193 std::string selectorName, std::string selectorDescription ):
195 m_properties( new
WProperties( name, description ) ),
199 selectorName = selectorName.empty() ? name : selectorName;
200 selectorDescription = selectorDescription.empty() ? name : selectorDescription;
211 template<
typename StrategyType >
217 template<
typename StrategyType >
224 size_t currentID = 0;
225 size_t selectedID = m_possibleSelectionProp->get();
229 ( *i )->getProperties()->setHidden( currentID != selectedID );
235 template<
typename StrategyType >
238 return m_properties->getName();
241 template<
typename StrategyType >
244 return m_properties->getDescription();
247 template<
typename StrategyType >
253 template<
typename StrategyType >
259 template<
typename StrategyType >
263 boost::lock_guard< boost::mutex > lock( m_addLock );
267 w->get().push_back( strategy );
268 size_t size = w->get().size();
271 m_possibleSelections->addItem( strategy->getName(), strategy->getDescription(), strategy->getIcon() );
272 m_properties->addProperty( strategy->getProperties() );
282 m_possibleSelectionProp->set( m_possibleSelections->getSelectorFirst() );
286 m_possibleSelectionProp->set( m_possibleSelectionProp->get().newSelector() );
292 template<
typename StrategyType >
297 return r->get()[ m_possibleSelectionProp->get() ];
301 template<
typename StrategyType >
306 return w->get()[ m_possibleSelectionProp->get() ];
310 #endif // WSTRATEGYHELPER_H