39 #include "../rtt-config.h" 78 if (!
Types()->type(
"int")) {
79 log(
Error) <<
"Failed to register enum <-> int conversion because type int is not known in type system."<<endlog();
102 if (result->update(source.get()))
112 menum->
set( (T)ds->
get() );
123 for(
typename MapType::const_iterator it = to_string.begin(); it != to_string.end(); ++it)
124 if ( it->second == dss->
get() ) {
125 menum->
set( it->first );
147 if ( to_string.count( ds->
get() ) == 0 ) {
virtual result_t get() const =0
Return the data as type T.
void addConstructor(TypeConstructor *tb)
Add a constructor/convertor object.
This template class allows user types to be used in all Orocos primitives.
Type information for Enum types for which they are convertible to int.
virtual bool composeType(base::DataSourceBase::shared_ptr source, base::DataSourceBase::shared_ptr result) const
Composition also checks if source is an int or string, and if so, converts it to the enum of type T k...
virtual void set(param_t t)=0
Set this DataSource with a value.
virtual base::DataSourceBase::shared_ptr decomposeType(base::DataSourceBase::shared_ptr source) const
Converts the enum to a string in case source is an enum and the string mapping is known...
EnumTypeInfo(std::string type)
TypeConstructor * newConstructor(Function *foo, bool automatic=false)
Create a new Constructor.
std::map< T, std::string > to_string
std::map< T, std::string > MapType
A class for representing a user type, and which can build instances of that type. ...
TypeInfoRepository::shared_ptr Types()
Obtain a pointer to the global type system.
boost::intrusive_ptr< DataSource< T > > shared_ptr
boost::intrusive_ptr< AssignableDataSource< T > > shared_ptr
Use this type to store a pointer to an AssignableDataSource.
static AssignableDataSource< T > * narrow(base::DataSourceBase *db)
This method narrows a base::DataSourceBase to a typeded AssignableDataSource, possibly returning a ne...
bool installTypeInfoObject(TypeInfo *ti)
Installs the type info object in the global data source type info handler and adds any additional fea...
static DataSource< T > * narrow(base::DataSourceBase *db)
This method narrows a base::DataSourceBase to a typeded DataSource, possibly returning a new object...
bool installTypeInfoObject(TypeInfo *ti)
Installs the type info object in the global data source type info handler and adds any additional fea...
boost::intrusive_ptr< DataSourceBase > shared_ptr
Use this type to store a pointer to a DataSourceBase.
Contains TaskContext, Activity, OperationCaller, Operation, Property, InputPort, OutputPort, Attribute.
static T int_to_enum(int i)
A simple, yet very useful DataSource, which keeps a value, and returns it in its get() method...
static int enum_to_int(T e)
boost::intrusive_ptr< ValueDataSource< T > > shared_ptr