Orocos Real-Time Toolkit
2.5.0
|
Type information for Enum types for which they are convertible to int. More...
#include <rtt/types/EnumTypeInfo.hpp>
Public Types | |
typedef T | UserType |
The given T parameter is the type for reading DataSources. | |
typedef Property< T > ::DataSourceType | PropertyType |
When Properties of T are constructed, they are non-const, non-reference. | |
typedef T | DataType |
The given T parameter is the type of the DataSources. | |
Public Member Functions | |
EnumTypeInfo (std::string type) | |
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 kept in result. | |
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. | |
virtual bool | decomposeType (base::DataSourceBase::shared_ptr source, PropertyBag &targetbag) const |
virtual bool | composeTypeImpl (const PropertyBag &source, typename internal::AssignableDataSource< T >::reference_t result) const |
User, implement this function in case you want to control reading the XML data format. | |
virtual bool | decomposeTypeImpl (typename internal::AssignableDataSource< T >::const_reference_t source, PropertyBag &targetbag) const |
User, implement this function in case you want to control writing the XML data format. | |
base::InputPortInterface * | inputPort (std::string const &name) const |
Returns a new InputPort<T> object where T is the type represented by this TypeInfo object. | |
base::OutputPortInterface * | outputPort (std::string const &name) const |
Returns a new OutputPort<T> object where T is the type represented by this TypeInfo object. | |
base::ChannelElementBase::shared_ptr | buildDataStorage (ConnPolicy const &policy) const |
Creates single data or buffered storage for this type. | |
base::ChannelElementBase::shared_ptr | buildChannelOutput (base::InputPortInterface &port) const |
Register a protocol for data transport over a network. | |
base::ChannelElementBase::shared_ptr | buildChannelInput (base::OutputPortInterface &port) const |
Register a protocol for data transport over a network. | |
bool | installTypeInfoObject () |
Installs the type info object in the global data source type info handler. | |
base::AttributeBase * | buildConstant (std::string name, base::DataSourceBase::shared_ptr dsb) const |
Build a non modifyable instance of this type. | |
base::AttributeBase * | buildVariable (std::string name) const |
Build a non modifyable instance of this type. | |
base::AttributeBase * | buildAttribute (std::string name, base::DataSourceBase::shared_ptr in) const |
Build an Attribute of this type. | |
base::AttributeBase * | buildAlias (std::string name, base::DataSourceBase::shared_ptr in) const |
build an alias with b as the value. | |
base::DataSourceBase::shared_ptr | buildActionAlias (base::ActionInterface *action, base::DataSourceBase::shared_ptr in) const |
Returns a DataSource that first executes an action and returns the result of another data source. | |
virtual const std::string & | getTypeName () const |
Return unique the type name. | |
virtual base::PropertyBase * | buildProperty (const std::string &name, const std::string &desc, base::DataSourceBase::shared_ptr source=0) const |
Build a Property of this type. | |
virtual base::DataSourceBase::shared_ptr | buildValue () const |
Build a internal::ValueDataSource of this type. | |
virtual base::DataSourceBase::shared_ptr | buildReference (void *ptr) const |
Build a internal::ReferenceDataSource of this type, pointing to the given pointer. | |
virtual std::ostream & | write (std::ostream &os, base::DataSourceBase::shared_ptr in) const |
Output this datasource as a human readable string. | |
virtual std::istream & | read (std::istream &os, base::DataSourceBase::shared_ptr out) const |
Read a new value for this datasource from a human readable string. | |
virtual bool | isStreamable () const |
Returns true if this type is directly streamable using read()/write() or toString()/fromString(). | |
TypeInfo::TypeId | getTypeId () const |
Register a protocol for data transport over a network. | |
const char * | getTypeIdName () const |
Register a protocol for data transport over a network. | |
Type building/factory functions | |
Used to create objects that hold data of a certain type. | |
virtual base::AttributeBase * | buildConstant (std::string name, base::DataSourceBase::shared_ptr, int sizehint) const |
Build a non modifyable instance of this type. | |
virtual base::AttributeBase * | buildVariable (std::string name, int sizehint) const |
Build a modifyable instance of this type. | |
virtual bool | resize (base::DataSourceBase::shared_ptr arg, int size) const |
Tries to resize a data source in case it's a resizable sequence. | |
virtual base::DataSourceBase::shared_ptr | construct (const std::vector< base::DataSourceBase::shared_ptr > &args) const |
Constructor syntax: construct a internal::DataSource which returns an instance of data depending on the given arguments. | |
virtual base::DataSourceBase::shared_ptr | convert (base::DataSourceBase::shared_ptr arg) const |
Automatic conversion: convert a internal::DataSource to this type. | |
virtual void | addConstructor (TypeBuilder *tb) |
Add a constructor/convertor object. | |
Conversion to/from text | |
Used to convert data to human readable text and vice versa. | |
virtual std::string | toString (base::DataSourceBase::shared_ptr in) const |
Usability function which converts data to a string. | |
virtual bool | fromString (const std::string &value, base::DataSourceBase::shared_ptr out) const |
Usability function which converts a string to data. | |
Inspecting data structures. | |
Used to write a complex type to an external representation, like XML. | |
virtual std::vector< std::string > | getMemberNames () const |
Returns the list of struct member names of this type. | |
virtual base::DataSourceBase::shared_ptr | getMember (base::DataSourceBase::shared_ptr item, const std::string &name) const |
Returns a member of a given data source struct identified by its name. | |
virtual base::DataSourceBase::shared_ptr | getMember (base::DataSourceBase::shared_ptr item, base::DataSourceBase::shared_ptr id) const |
Returns a member of a given data source struct identified by a data source id. | |
virtual base::DataSourceBase::shared_ptr | convertType (base::DataSourceBase::shared_ptr source) const |
Specialize this function to return an alternate type which represents this one in a compatible way. | |
Protected Types | |
typedef std::map< T, std::string > | MapType |
typedef std::vector < TypeBuilder * > | Constructors |
typedef std::vector < TypeTransporter * > | Transporters |
Static Protected Member Functions | |
static int | enum_to_int (T e) |
static T | int_to_enum (int i) |
Protected Attributes | |
std::map< T, std::string > | to_string |
const std::string | tname |
Constructors | constructors |
Transporters | transporters |
Distribution of objects | |
bool | addProtocol (int protocol_id, TypeTransporter *tt) |
Register a protocol for data transport over a network. | |
TypeTransporter * | getProtocol (int protocol_id) const |
Returns this type's transport for a given protocol. | |
bool | hasProtocol (int protocol_id) const |
Check if this type is transporable over a given protocol. | |
std::vector< int > | getTransportNames () const |
Return a list of protocols that have transporters. | |
typedef const std::type_info * | TypeId |
Register a protocol for data transport over a network. | |
void | migrateProtocols (TypeInfo *orig) |
Migrates all protocols present in orig to this type info object. |
Type information for Enum types for which they are convertible to int.
Definition at line 56 of file EnumTypeInfo.hpp.
base::DataSourceBase::shared_ptr RTT::types::PrimitiveTypeInfo< T, use_ostream >::buildActionAlias | ( | base::ActionInterface * | action, |
base::DataSourceBase::shared_ptr | source | ||
) | const [inline, virtual, inherited] |
Returns a DataSource that first executes an action and returns the result of another data source.
If source is an AssignableDataSource, an AssignableDataSource is returned of the same type, otherwise, a plain DataSource is returned.
Implements RTT::types::TypeInfo.
Definition at line 129 of file PrimitiveTypeInfo.hpp.
base::AttributeBase* RTT::types::PrimitiveTypeInfo< T, use_ostream >::buildAlias | ( | std::string | name, |
base::DataSourceBase::shared_ptr | b | ||
) | const [inline, virtual, inherited] |
build an alias with b as the value.
If b is of the wrong type, 0 will be returned..
Implements RTT::types::TypeInfo.
Definition at line 121 of file PrimitiveTypeInfo.hpp.
base::AttributeBase* RTT::types::PrimitiveTypeInfo< T, use_ostream >::buildConstant | ( | std::string | name, |
base::DataSourceBase::shared_ptr | |||
) | const [inline, virtual, inherited] |
Build a non modifyable instance of this type.
sizehint | For variable size instances, use it to hint the size of the instance. |
Implements RTT::types::TypeInfo.
Definition at line 87 of file PrimitiveTypeInfo.hpp.
AttributeBase * RTT::TypeInfo::buildConstant | ( | std::string | name, |
base::DataSourceBase::shared_ptr | dsb, | ||
int | sizehint | ||
) | const [virtual, inherited] |
Build a non modifyable instance of this type.
sizehint | For variable size instances, use it to hint the size of the instance. |
Definition at line 63 of file TypeInfo.cpp.
base::ChannelElementBase::shared_ptr RTT::types::TemplateTypeInfo< T, use_ostream >::buildDataStorage | ( | ConnPolicy const & | policy | ) | const [inline, virtual, inherited] |
Creates single data or buffered storage for this type.
policy | Describes the kind of storage requested by the user |
Reimplemented from RTT::types::PrimitiveTypeInfo< T, use_ostream >.
Definition at line 159 of file TemplateTypeInfo.hpp.
AttributeBase * RTT::TypeInfo::buildVariable | ( | std::string | name, |
int | sizehint | ||
) | const [virtual, inherited] |
Build a modifyable instance of this type.
sizehint | For variable size instances, use it to hint the size of the instance. |
Reimplemented in RTT::types::CArrayTypeInfo< T, has_ostream >.
Definition at line 59 of file TypeInfo.cpp.
base::AttributeBase* RTT::types::PrimitiveTypeInfo< T, use_ostream >::buildVariable | ( | std::string | name | ) | const [inline, virtual, inherited] |
Build a non modifyable instance of this type.
sizehint | For variable size instances, use it to hint the size of the instance. |
Implements RTT::types::TypeInfo.
Definition at line 100 of file PrimitiveTypeInfo.hpp.
virtual bool RTT::types::EnumTypeInfo< T >::composeType | ( | base::DataSourceBase::shared_ptr | source, |
base::DataSourceBase::shared_ptr | result | ||
) | const [inline, virtual] |
Composition also checks if source is an int or string, and if so, converts it to the enum of type T kept in result.
source | a DataSource<int> or DataSource<string>, generated by decomposeType(). |
result | An AssignableDataSource<T> that will get the new enum value. |
Reimplemented from RTT::types::TemplateTypeInfo< T, false >.
Definition at line 90 of file EnumTypeInfo.hpp.
References RTT::internal::DataSource< T >::get(), and RTT::internal::AssignableDataSource< T >::set().
DataSourceBase::shared_ptr RTT::TypeInfo::construct | ( | const std::vector< base::DataSourceBase::shared_ptr > & | args | ) | const [virtual, inherited] |
Constructor syntax: construct a internal::DataSource which returns an instance of data depending on the given arguments.
When args is empty, the default 'variable' is returned.
Reimplemented in RTT::types::EmptyTypeInfo.
Definition at line 79 of file TypeInfo.cpp.
References RTT::base::AttributeBase::getDataSource().
DataSourceBase::shared_ptr RTT::TypeInfo::convert | ( | base::DataSourceBase::shared_ptr | arg | ) | const [virtual, inherited] |
Automatic conversion: convert a internal::DataSource to this type.
For example, for converting float -> double. If no valid conversion was found, returns arg again, otherwise, a new data source.
Definition at line 110 of file TypeInfo.cpp.
Referenced by RTT::types::CArrayTypeInfo< T, has_ostream >::getMember(), RTT::internal::AssignableDataSource< T >::update(), and RTT::internal::AssignableDataSource< T >::updateAction().
base::DataSourceBase::shared_ptr RTT::TypeInfo::convertType | ( | base::DataSourceBase::shared_ptr | source | ) | const [virtual, inherited] |
Specialize this function to return an alternate type which represents this one in a compatible way.
For example, a short converts to an long or an enum to an int or a string.
Definition at line 134 of file TypeInfo.cpp.
virtual base::DataSourceBase::shared_ptr RTT::types::EnumTypeInfo< T >::decomposeType | ( | base::DataSourceBase::shared_ptr | source | ) | const [inline, virtual] |
Converts the enum to a string in case source is an enum and the string mapping is known.
In case there is no string mapping, an int is returned. The conversion the other way around is done by composeType()
Reimplemented from RTT::types::TemplateTypeInfo< T, false >.
Definition at line 132 of file EnumTypeInfo.hpp.
References RTT::internal::DataSource< T >::get(), and RTT::types::PrimitiveTypeInfo< T, use_ostream >::getTypeName().
virtual bool RTT::types::TemplateTypeInfo< T, use_ostream >::decomposeTypeImpl | ( | typename internal::AssignableDataSource< T >::const_reference_t | source, |
PropertyBag & | targetbag | ||
) | const [inline, virtual, inherited] |
User, implement this function in case you want to control writing the XML data format.
Add the structural elements of source to targetbag.
Definition at line 152 of file TemplateTypeInfo.hpp.
DataSourceBase::shared_ptr RTT::TypeInfo::getMember | ( | base::DataSourceBase::shared_ptr | item, |
const std::string & | name | ||
) | const [virtual, inherited] |
Returns a member of a given data source struct identified by its name.
item | The item of which to return a reference to a member |
name | The name of a member within item. Is a name of a member in case of a struct or an index number in case of a sequence. |
** Strong typed data **
for( set i = 0; i <=10; set i = i + 1) { value[i] = i; // sequence index, runtime structure value.i = i; // part name, browse static structure } set frame.pos = vector(a,b,c); // getMember("pos") set frame.pos[3] = vector(a,b,c); // getMember("pos")->getMember(3) set frame[3].pos = vector(a,b,c); // getMember(3)->getMember("pos") set frame[i].pos = vector(a,b,c); // getMember( $i )->getMember("pos") set frame["tool"].pos = vector(a,b,c); // getMember("tool") xx set frame[arg].pos = vector(a,b,c);// getMember( arg )->getMember("pos")
Reimplemented in RTT::types::CArrayTypeInfo< T, has_ostream >, RTT::types::BoostArrayTypeInfo< T, has_ostream >, and RTT::types::StructTypeInfo< T, has_ostream >.
Definition at line 230 of file TypeInfo.cpp.
Referenced by RTT::base::DataSourceBase::getMember().
DataSourceBase::shared_ptr RTT::TypeInfo::getMember | ( | base::DataSourceBase::shared_ptr | item, |
base::DataSourceBase::shared_ptr | id | ||
) | const [virtual, inherited] |
Returns a member of a given data source struct identified by a data source id.
item | The item of which to return a member |
id | Or a string data source containing the name of a member if item is a struct, Or an unsigned int data source containing the index of an element if item is a sequence |
** Strong typed data **
for( set i = 0; i <=10; set i = i + 1) { value[i] = i; // sequence index, runtime structure value.i = i; // part name, browse static structure } set frame.pos = vector(a,b,c); // getMember("pos") set frame.pos[3] = vector(a,b,c); // getMember("pos")->getMember(3) set frame[3].pos = vector(a,b,c); // getMember(3)->getMember("pos") set frame[i].pos = vector(a,b,c); // getMember( $i )->getMember("pos") set frame["tool"].pos = vector(a,b,c); // getMember("tool") xx set frame[arg].pos = vector(a,b,c);// getMember( arg )->getMember("pos")
Reimplemented in RTT::types::CArrayTypeInfo< T, has_ostream >, and RTT::types::BoostArrayTypeInfo< T, has_ostream >.
Definition at line 252 of file TypeInfo.cpp.
vector< string > RTT::TypeInfo::getMemberNames | ( | ) | const [virtual, inherited] |
Returns the list of struct member names of this type.
In case this type is not a struct, returns an empty list.
Reimplemented in RTT::types::CArrayTypeInfo< T, has_ostream >, RTT::types::BoostArrayTypeInfo< T, has_ostream >, and RTT::types::StructTypeInfo< T, has_ostream >.
Definition at line 225 of file TypeInfo.cpp.
Referenced by RTT::base::DataSourceBase::getMemberNames().
TypeTransporter * RTT::TypeInfo::getProtocol | ( | int | protocol_id | ) | const [inherited] |
Returns this type's transport for a given protocol.
Will print a warning when returning null. Use hasProtocol() to query without warning.
Definition at line 172 of file TypeInfo.cpp.
Referenced by RTT::corba::RemoteInputPort::buildRemoteChannelOutput(), RTT::internal::ConnFactory::createAndCheckStream(), RTT::corba::DataSourceProxy< T >::DataSourceProxy(), RTT::corba::CorbaOperationCallerFactory::produce(), RTT::corba::CorbaOperationCallerFactory::produceCollect(), and RTT::corba::CorbaOperationCallerFactory::produceSend().
bool RTT::types::PrimitiveTypeInfo< T, use_ostream >::installTypeInfoObject | ( | ) | [inline, virtual, inherited] |
Installs the type info object in the global data source type info handler.
This will be called by the TypeInfoRepository, prior to registering this type. If installation fails the TypeInfoRepository will delete this object, and all its associated constructors.
true | installation succeeded. This object should not be deleted during the execution of the current process. |
false | installation failed. This object is not used and may be deleted. |
Implements RTT::types::TypeInfo.
Definition at line 62 of file PrimitiveTypeInfo.hpp.
void RTT::TypeInfo::migrateProtocols | ( | TypeInfo * | orig | ) | [protected, inherited] |
Migrates all protocols present in orig to this type info object.
It is meant as a helper when a type info object is replaced by a new instance.
Definition at line 190 of file TypeInfo.cpp.
Referenced by RTT::types::PrimitiveTypeInfo< std::vector< T >, use_ostream >::installTypeInfoObject(), and RTT::types::TypeInfoName< T >::installTypeInfoObject().
virtual std::istream& RTT::types::PrimitiveTypeInfo< T, use_ostream >::read | ( | std::istream & | os, |
base::DataSourceBase::shared_ptr | out | ||
) | const [inline, virtual, inherited] |
Read a new value for this datasource from a human readable string.
The default does nothing.
Implements RTT::types::TypeInfo.
Reimplemented in RTT::types::BoolTypeInfo.
Definition at line 177 of file PrimitiveTypeInfo.hpp.
Referenced by RTT::types::PrimitiveTypeInfo< std::vector< T >, use_ostream >::read().
bool RTT::TypeInfo::resize | ( | base::DataSourceBase::shared_ptr | arg, |
int | size | ||
) | const [virtual, inherited] |
Tries to resize a data source in case it's a resizable sequence.
Definition at line 139 of file TypeInfo.cpp.
virtual std::ostream& RTT::types::PrimitiveTypeInfo< T, use_ostream >::write | ( | std::ostream & | os, |
base::DataSourceBase::shared_ptr | in | ||
) | const [inline, virtual, inherited] |
Output this datasource as a human readable string.
The default just writes the type name in parentheses to os.
Implements RTT::types::TypeInfo.
Reimplemented in RTT::types::BoolTypeInfo.
Definition at line 163 of file PrimitiveTypeInfo.hpp.
Referenced by RTT::types::PrimitiveTypeInfo< std::vector< T >, use_ostream >::write().