25 #ifndef WPROPERTYSTRUCT_H
26 #define WPROPERTYSTRUCT_H
31 #include <boost/shared_ptr.hpp>
33 #include <boost/tuple/tuple.hpp>
34 #include <boost/mpl/vector.hpp>
35 #include <boost/mpl/copy.hpp>
36 #include <boost/mpl/size.hpp>
37 #include <boost/mpl/at.hpp>
38 #include <boost/preprocessor/repetition/enum_params.hpp>
40 #include "WStringUtils.h"
41 #include "WCondition.h"
42 #include "WPropertyGroupBase.h"
43 #include "WPropertyBase.h"
44 #include "WPropertyTypes.h"
45 #include "exceptions/WPropertyUnknown.h"
50 namespace WPropertyStructHelper
58 template<
typename T,
typename Tuple>
59 struct PushTypeToTupleFront;
68 template<
typename T, BOOST_PP_ENUM_PARAMS( 10,
typename T )>
69 struct PushTypeToTupleFront<
T, boost::tuple< BOOST_PP_ENUM_PARAMS( 10, T ) > >
74 typedef boost::tuple< T, BOOST_PP_ENUM_PARAMS( 9, T ) >
type;
82 template<
typename Sequence >
88 typedef typename boost::mpl::reverse_copy<
92 PushTypeToTupleFront< boost::mpl::_2, boost::mpl::_1 >
134 typedef boost::mpl::vector< BOOST_PP_ENUM_PARAMS( 10, T ) >
type;
211 typedef typename boost::shared_ptr< WPropertyStructType >
SPtr;
216 typedef typename boost::shared_ptr< const WPropertyStructType >
ConstSPtr;
278 typename boost::mpl::at< TypeVector, boost::mpl::size_t< N > >::type
getProperty()
280 typedef typename boost::mpl::at< TypeVector, boost::mpl::size_t< N > >::type::element_type TargetType;
281 return boost::shared_dynamic_cast< TargetType >(
getProperty( N ) );
292 typename boost::mpl::at< TypeVector, boost::mpl::size_t< N > >::type::element_type::ConstSPtr
getProperty()
const
294 typedef typename boost::mpl::at< TypeVector, boost::mpl::size_t< N > >::type::element_type TargetType;
295 return boost::shared_dynamic_cast<
const TargetType >(
getProperty( N ) );
310 return l->get()[ n ];
325 return l->get()[ n ];
379 if(
size() != propsAsString.size() )
387 size_t curPropNb = 0;
389 for( std::vector< std::string >::const_iterator iter = propsAsString.begin(); iter != propsAsString.end(); ++iter )
391 success = success && l->get()[ curPropNb ]->setAsString( *iter );
409 std::string result =
"";
410 for(
size_t i = 0; i <
size(); ++i )
412 result += l->get()[ i ]->getAsString() +
"|";
415 result.erase( result.length() - 1, 1 );
428 virtual bool set( boost::shared_ptr< WPropertyBase > value,
bool recommendedOnly = false )
443 for(
size_t curPropNb = 0; curPropNb <
size(); ++curPropNb )
445 success = success && l->get()[ curPropNb ]->set( lother->get()[ curPropNb ], recommendedOnly );
456 static const size_t m_size = boost::mpl::size< TypeVector >::value;
459 #endif // WPROPERTYSTRUCT_H