25 #ifndef WPROPERTYSTRUCT_H
26 #define WPROPERTYSTRUCT_H
32 #include <boost/mpl/at.hpp>
33 #include <boost/mpl/copy.hpp>
34 #include <boost/mpl/size.hpp>
35 #include <boost/mpl/vector.hpp>
36 #include <boost/preprocessor/repetition/enum_params.hpp>
37 #include <boost/tuple/tuple.hpp>
39 #include "WCondition.h"
40 #include "WPropertyBase.h"
41 #include "WPropertyGroupBase.h"
42 #include "WPropertyTypes.h"
43 #include "WStringUtils.h"
44 #include "exceptions/WPropertyUnknown.h"
57 template<
typename T,
typename Tuple>
67 template<
typename T, BOOST_PP_ENUM_PARAMS( 10,
typename T )>
73 typedef boost::tuple< T, BOOST_PP_ENUM_PARAMS( 9, T ) >
type;
81 template<
typename Sequence >
87 typedef typename boost::mpl::reverse_copy<
133 typedef boost::mpl::vector< BOOST_PP_ENUM_PARAMS( 10, T ) >
type;
210 typedef typename std::shared_ptr< WPropertyStructType >
SPtr;
215 typedef typename std::shared_ptr< const WPropertyStructType >
ConstSPtr;
277 typename boost::mpl::at< TypeVector, boost::mpl::size_t< N > >::type
getProperty()
279 typedef typename boost::mpl::at< TypeVector, boost::mpl::size_t< N > >::type::element_type TargetType;
280 return std::dynamic_pointer_cast< TargetType >(
getProperty( N ) );
291 typename boost::mpl::at< TypeVector, boost::mpl::size_t< N > >::type::element_type::ConstSPtr
getProperty()
const
293 typedef typename boost::mpl::at< TypeVector, boost::mpl::size_t< N > >::type::element_type TargetType;
294 return std::dynamic_pointer_cast< const TargetType >(
getProperty( N ) );
309 return l->get()[ n ];
324 return l->get()[ n ];
378 if(
size() != propsAsString.size() )
386 size_t curPropNb = 0;
388 for( std::vector< std::string >::const_iterator iter = propsAsString.begin(); iter != propsAsString.end(); ++iter )
390 success = success && l->get()[ curPropNb ]->setAsString( *iter );
408 std::string result =
"";
409 for(
size_t i = 0; i <
size(); ++i )
411 result += l->get()[ i ]->getAsString() +
"|";
414 result.erase( result.length() - 1, 1 );
427 virtual bool set( std::shared_ptr< WPropertyBase > value,
bool recommendedOnly =
false )
442 for(
size_t curPropNb = 0; curPropNb <
size(); ++curPropNb )
444 success = success && l->get()[ curPropNb ]->set( lother->get()[ curPropNb ], recommendedOnly );
455 static const size_t m_size = boost::mpl::size< TypeVector >::value;
std::shared_ptr< WPropertyBase > SPtr
Convenience typedef for a std::shared_ptr< WPropertyBase >
This is the base class and interface for property groups.
PropertySharedContainerType m_properties
The set of proerties.
This is a property which encapsulates a given, fixed number of other properties.
WPropertyStruct(std::string name, std::string description)
Create an empty named property.
WPropertyStruct< BOOST_PP_ENUM_PARAMS(10, T) > WPropertyStructType
The type of this template instantiation.
boost::mpl::at< TypeVector, boost::mpl::size_t< N > >::type::element_type::ConstSPtr getProperty() const
Get the N'th property in the struct.
virtual std::string getAsString()
Returns the current value as a string.
size_t size() const
The size of the WPropertyStruct.
std::shared_ptr< WPropertyStructType > SPtr
Convenience typedef for a std::shared_ptr< WPropertyStructType >
static const size_t m_size
How many elements are in this WPropertyStruct?
const WPropertyBase::SPtr & getProperty(size_t n) const
Returns the property with the given number, but only as base type.
std::shared_ptr< const WPropertyStructType > ConstSPtr
Convenience typedef for a std::shared_ptr< const WPropertyStructType >
virtual WPropertyBase::SPtr clone()
This method clones a property and returns the clone.
WPropertyStructHelper::AsVector< BOOST_PP_ENUM_PARAMS(10, T) >::type TypeVector
The boost mpl vector for all the types specified.
virtual PROPERTY_TYPE getType() const
Gets the real WPropertyVariable type of this instance.
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.
virtual bool set(std::shared_ptr< WPropertyBase > value, bool recommendedOnly=false)
Sets the value from the specified property to this one.
WPropertyStructHelper::SequenceToTuple< TypeVector >::type TupleType
The type vector as a boost tuple.
WPropertyBase::SPtr getProperty(size_t n)
Returns the property with the given number, but only as base type.
WPropertyStruct(const WPropertyStructType &from)
Copy constructor.
virtual ~WPropertyStruct()
Destructor.
std::shared_ptr< WSharedObjectTicketRead< T > > ReadTicket
Type for read tickets.
ReadTicket getReadTicket() const
Returns a ticket to get read access to the contained data.
This contains some helping classes for compile time type conversion and similar.
boost::mpl::na NOTYPE
Alias for default type to emulate variadic templates.
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).
WPropertyStructHelper::NOTYPE ValueType
The type of the initial value.
static void createAndAdd(WPropertyGroupBase *, std::string, std::string, const ValueType &)
Dummy method which does nothing for NOTYPE types.
static void createAndAdd(WPropertyGroupBase *, std::string, std::string)
Dummy method which does nothing for NOTYPE types.
Comfortable template to create a property instance and add it to the group.
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 ...
Convert a list of template parameters to a boost::mpl::vector.
boost::mpl::vector< BOOST_PP_ENUM_PARAMS(10, T) > type
The template types as mpl vector.
boost::tuple< T, BOOST_PP_ENUM_PARAMS(9, T) > type
The resulting tuple type.
Class to push a type from a sequence to the front of a tuple type.
Converts a boost mpl sequence to a boost tuple.
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.