25 #ifndef WPROPERTYSTRUCT_H
26 #define WPROPERTYSTRUCT_H
32 #include <boost/shared_ptr.hpp>
36 #include <boost/tuple/tuple.hpp>
39 #include <boost/mpl/vector.hpp>
42 #include <boost/mpl/copy.hpp>
45 #include <boost/mpl/size.hpp>
48 #include <boost/mpl/at.hpp>
51 #include <boost/preprocessor/repetition/enum_params.hpp>
54 #include "WStringUtils.h"
55 #include "WCondition.h"
56 #include "WPropertyGroupBase.h"
57 #include "WPropertyBase.h"
58 #include "WPropertyTypes.h"
59 #include "exceptions/WPropertyUnknown.h"
72 template<
typename T,
typename Tuple>
82 template<
typename T, BOOST_PP_ENUM_PARAMS( 10,
typename T )>
88 typedef boost::tuple< T, BOOST_PP_ENUM_PARAMS( 9, T ) >
type;
96 template<
typename Sequence >
102 typedef typename boost::mpl::reverse_copy<
104 boost::mpl::inserter<
148 typedef boost::mpl::vector< BOOST_PP_ENUM_PARAMS( 10, T ) >
type;
225 typedef typename boost::shared_ptr< WPropertyStructType >
SPtr;
230 typedef typename boost::shared_ptr< const WPropertyStructType >
ConstSPtr;
292 typename boost::mpl::at< TypeVector, boost::mpl::size_t< N > >::type
getProperty()
294 typedef typename boost::mpl::at< TypeVector, boost::mpl::size_t< N > >::type::element_type TargetType;
295 return boost::dynamic_pointer_cast< TargetType >(
getProperty( N ) );
306 typename boost::mpl::at< TypeVector, boost::mpl::size_t< N > >::type::element_type::ConstSPtr
getProperty()
const
308 typedef typename boost::mpl::at< TypeVector, boost::mpl::size_t< N > >::type::element_type TargetType;
309 return boost::dynamic_pointer_cast<
const TargetType >(
getProperty( N ) );
324 return l->get()[ n ];
339 return l->get()[ n ];
393 if(
size() != propsAsString.size() )
401 size_t curPropNb = 0;
403 for( std::vector< std::string >::const_iterator iter = propsAsString.begin(); iter != propsAsString.end(); ++iter )
405 success = success && l->get()[ curPropNb ]->setAsString( *iter );
423 std::string result =
"";
424 for(
size_t i = 0; i <
size(); ++i )
426 result += l->get()[ i ]->getAsString() +
"|";
429 result.erase( result.length() - 1, 1 );
442 virtual bool set( boost::shared_ptr< WPropertyBase > value,
bool recommendedOnly =
false )
457 for(
size_t curPropNb = 0; curPropNb <
size(); ++curPropNb )
459 success = success && l->get()[ curPropNb ]->set( lother->get()[ curPropNb ], recommendedOnly );
470 static const size_t m_size = boost::mpl::size< TypeVector >::value;
473 #endif // WPROPERTYSTRUCT_H
boost::shared_ptr< const WPropertyStructType > ConstSPtr
Convenience typedef for a boost::shared_ptr< const WPropertyStructType >
WPropertyStruct< BOOST_PP_ENUM_PARAMS(10, T) > WPropertyStructType
The type of this template instantiation.
WPropertyBase::SPtr getProperty(size_t n)
Returns the property with the given number, but only as base type.
std::vector< std::string > tokenize(const std::string &source, const std::string &delim=WHITESPACE, bool compress=true)
Splits the given string into a vector of strings (so called tokens).
virtual ~WPropertyStruct()
Destructor.
Convert a list of template parameters to a boost::mpl::vector.
static void createAndAdd(WPropertyGroupBase *group, std::string name, std::string description, const ValueType &initial=ValueType())
Actually does the work and adds a new property with the given name, description and other parameters ...
WPropertyStruct(std::string name, std::string description)
Create an empty named property.
virtual bool set(boost::shared_ptr< WPropertyBase > value, bool recommendedOnly=false)
Sets the value from the specified property to this one.
WPropertyStructHelper::NOTYPE ValueType
The type of the initial value.
boost::tuple< T, BOOST_PP_ENUM_PARAMS(9, T) > type
The resulting tuple type.
PropertySharedContainerType m_properties
The set of proerties.
static void createAndAdd(WPropertyGroupBase *, std::string, std::string, const ValueType &)
Dummy method which does nothing for NOTYPE types.
ReadTicket getReadTicket() const
Returns a ticket to get read access to the contained data.
WPropertyStructHelper::AsVector< BOOST_PP_ENUM_PARAMS(10, T) >::type TypeVector
The boost mpl vector for all the types specified.
WPropertyStructHelper::SequenceToTuple< TypeVector >::type TupleType
The type vector as a boost tuple.
static const size_t m_size
How many elements are in this WPropertyStruct?
This is the base class and interface for property groups.
Comfortable template to create a property instance and add it to the group.
virtual bool setAsString(std::string value)
This methods allows properties to be set by a string value.
boost::mpl::at< TypeVector, boost::mpl::size_t< N > >::type getProperty()
Get the N'th property in the struct.
This contains some helping classes for compile time type conversion and similar.
boost::mpl::reverse_copy< Sequence, boost::mpl::inserter< boost::tuple<>, PushTypeToTupleFront< boost::mpl::_2, boost::mpl::_1 > > >::type type
This is the tuple type for the sequence.
boost::shared_ptr< WPropertyBase > SPtr
Convenience typedef for a boost::shared_ptr< WPropertyBase >
Converts a boost mpl sequence to a boost tuple.
size_t size() const
The size of the WPropertyStruct.
boost::mpl::na NOTYPE
Alias for default type to emulate variadic templates.
boost::shared_ptr< WPropertyStructType > SPtr
Convenience typedef for a boost::shared_ptr< WPropertyStructType >
boost::mpl::vector< BOOST_PP_ENUM_PARAMS(10, T) > type
The template types as mpl vector.
WPropertyStruct(const WPropertyStructType &from)
Copy constructor.
virtual PROPERTY_TYPE getType() const
Gets the real WPropertyVariable type of this instance.
Class to push a type from a sequence to the front of a tuple type.
This is a property which encapsulates a given, fixed number of other properties.
virtual WPropertyBase::SPtr clone()
This method clones a property and returns the clone.
virtual std::string getAsString()
Returns the current value as a string.
boost::mpl::at< TypeVector, boost::mpl::size_t< N > >::type::element_type::ConstSPtr getProperty() const
Get the N'th property in the struct.
boost::shared_ptr< WSharedObjectTicketRead< PropertyContainerType > > ReadTicket
Type for read tickets.
static void createAndAdd(WPropertyGroupBase *, std::string, std::string)
Dummy method which does nothing for NOTYPE types.
const WPropertyBase::SPtr & getProperty(size_t n) const
Returns the property with the given number, but only as base type.