Public Types | Public Member Functions | Protected Types | Protected Attributes
RTT::types::TypeInfo Class Reference

#include <TypeInfo.hpp>

List of all members.

Public Types

typedef const std::type_info * TypeId

Public Member Functions

void addAlias (const std::string &alias)
void addConstructor (TypeConstructor *tb)
base::ChannelElementBase::shared_ptr buildChannelInput (base::OutputPortInterface &port) const
base::ChannelElementBase::shared_ptr buildChannelOutput (base::InputPortInterface &port) const
base::ChannelElementBase::shared_ptr buildDataStorage (ConnPolicy const &policy) const
base::DataSourceBase::shared_ptr construct (const std::vector< base::DataSourceBase::shared_ptr > &args) const
base::DataSourceBase::shared_ptr convert (base::DataSourceBase::shared_ptr arg) const
CompositionFactoryPtr getCompositionFactory () const
MemberFactoryPtr getMemberFactory () const
ConnFactoryPtr getPortFactory () const
StreamFactoryPtr getStreamFactory () const
TypeId getTypeId () const
const char * getTypeIdName () const
const std::string & getTypeName () const
std::vector< std::string > getTypeNames () const
ValueFactoryPtr getValueFactory () const
base::InputPortInterfaceinputPort (std::string const &name) const
bool isType (const std::string &name)
base::OutputPortInterfaceoutputPort (std::string const &name) const
void setCompositionFactory (CompositionFactoryPtr cf)
void setMemberFactory (MemberFactoryPtr mf)
void setPortFactory (ConnFactoryPtr cf)
void setStreamFactory (StreamFactoryPtr sf)
void setTypeId (TypeId tid)
void setValueFactory (ValueFactoryPtr dsf)
 TypeInfo (const std::string &name)
 ~TypeInfo ()
Distribution of objects

Used to transport data over a network.

bool addProtocol (int protocol_id, TypeTransporter *tt)
TypeTransportergetProtocol (int protocol_id) const
bool hasProtocol (int protocol_id) const
std::vector< int > getTransportNames () const
Type building/factory functions

Used to create objects that hold data of a certain type.

base::AttributeBasebuildConstant (std::string name, base::DataSourceBase::shared_ptr source, int sizehint) const
base::AttributeBasebuildConstant (std::string name, base::DataSourceBase::shared_ptr source) const
base::AttributeBasebuildVariable (std::string name, int sizehint) const
base::AttributeBasebuildVariable (std::string name) const
bool resize (base::DataSourceBase::shared_ptr arg, int size) const
base::AttributeBasebuildAlias (std::string name, base::DataSourceBase::shared_ptr b) const
base::PropertyBasebuildProperty (const std::string &name, const std::string &desc, base::DataSourceBase::shared_ptr source=0) const
base::AttributeBasebuildAttribute (std::string name, base::DataSourceBase::shared_ptr source=0) const
base::DataSourceBase::shared_ptr buildValue () const
base::DataSourceBase::shared_ptr buildReference (void *ptr) const
base::DataSourceBase::shared_ptr buildActionAlias (base::ActionInterface *action, base::DataSourceBase::shared_ptr source) const
Conversion to/from text

Used to convert data to human readable text and vice versa.

std::ostream & write (std::ostream &os, base::DataSourceBase::shared_ptr in) const
std::istream & read (std::istream &os, base::DataSourceBase::shared_ptr out) const
std::string toString (base::DataSourceBase::shared_ptr in) const
bool fromString (const std::string &value, base::DataSourceBase::shared_ptr out) const
bool isStreamable () const
Inspecting data structures.

Used to write a complex type to an external representation, like XML.

std::vector< std::string > getMemberNames () const
base::DataSourceBase::shared_ptr getMember (base::DataSourceBase::shared_ptr item, const std::string &name) const
bool getMember (internal::Reference *ref, base::DataSourceBase::shared_ptr item, const std::string &name) const
base::DataSourceBase::shared_ptr getMember (base::DataSourceBase::shared_ptr item, base::DataSourceBase::shared_ptr id) const
bool composeType (base::DataSourceBase::shared_ptr source, base::DataSourceBase::shared_ptr target) const
base::DataSourceBase::shared_ptr decomposeType (base::DataSourceBase::shared_ptr source) const
base::DataSourceBase::shared_ptr convertType (base::DataSourceBase::shared_ptr source) const

Protected Types

typedef std::vector
< TypeConstructor * > 
Constructors
typedef std::vector
< TypeTransporter * > 
Transporters

Protected Attributes

Constructors constructors
boost::shared_ptr
< CompositionFactory
mcompf
boost::shared_ptr< ConnFactorymconnf
boost::shared_ptr< ValueFactorymdsf
boost::shared_ptr< MemberFactorymmembf
boost::shared_ptr< StreamFactorymstrf
TypeId mtid
const char * mtid_name
std::vector< std::string > mtypenames
Transporters transporters

Detailed Description

A class for representing a user type, and which can build instances of that type. Once you get hold of a TypeInfo object pointer, this pointer will be valid during the whole lifetime of the process.

Definition at line 68 of file TypeInfo.hpp.


Member Typedef Documentation

typedef std::vector<TypeConstructor*> RTT::types::TypeInfo::Constructors [protected]

Definition at line 484 of file TypeInfo.hpp.

typedef std::vector<TypeTransporter*> RTT::types::TypeInfo::Transporters [protected]

Definition at line 485 of file TypeInfo.hpp.

typedef const std::type_info* RTT::types::TypeInfo::TypeId

Definition at line 71 of file TypeInfo.hpp.


Constructor & Destructor Documentation

RTT::types::TypeInfo::TypeInfo ( const std::string &  name) [inline]

Definition at line 73 of file TypeInfo.hpp.

Definition at line 55 of file TypeInfo.cpp.


Member Function Documentation

void RTT::TypeInfo::addAlias ( const std::string &  alias)

Adds an alias to the this type.

Parameters:
aliasan alternative name for this type which will be returned in getTypeNames()

Definition at line 71 of file TypeInfo.cpp.

Add a constructor/convertor object.

Definition at line 113 of file TypeInfo.cpp.

bool RTT::TypeInfo::addProtocol ( int  protocol_id,
TypeTransporter tt 
)

Register a protocol for data transport over a network.

Definition at line 135 of file TypeInfo.cpp.

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.

Definition at line 249 of file TypeInfo.hpp.

build an alias with b as the value. If b is of the wrong type, 0 will be returned..

Definition at line 207 of file TypeInfo.hpp.

base::AttributeBase* RTT::types::TypeInfo::buildAttribute ( std::string  name,
base::DataSourceBase::shared_ptr  source = 0 
) const [inline]

Build an Attribute of this type.

Definition at line 223 of file TypeInfo.hpp.

Definition at line 448 of file TypeInfo.hpp.

Definition at line 444 of file TypeInfo.hpp.

base::AttributeBase* RTT::types::TypeInfo::buildConstant ( std::string  name,
base::DataSourceBase::shared_ptr  source,
int  sizehint 
) const [inline]

Build a non modifyable instance of this type.

Parameters:
sizehintFor variable size instances, use it to hint the size of the instance.

Definition at line 174 of file TypeInfo.hpp.

Definition at line 179 of file TypeInfo.hpp.

Creates single data or buffered storage for this type.

Parameters:
policyDescribes the kind of storage requested by the user
Returns:
a storage element.

Definition at line 440 of file TypeInfo.hpp.

base::PropertyBase* RTT::types::TypeInfo::buildProperty ( const std::string &  name,
const std::string &  desc,
base::DataSourceBase::shared_ptr  source = 0 
) const [inline]

Build a Property of this type.

Definition at line 215 of file TypeInfo.hpp.

Build a internal::ReferenceDataSource of this type, pointing to the given pointer

Definition at line 239 of file TypeInfo.hpp.

Build a internal::ValueDataSource of this type.

Definition at line 231 of file TypeInfo.hpp.

base::AttributeBase * RTT::TypeInfo::buildVariable ( std::string  name,
int  sizehint 
) const

Build a modifyable instance of this type.

Parameters:
sizehintFor variable size instances, use it to hint the size of the instance.

Definition at line 81 of file TypeInfo.cpp.

base::AttributeBase* RTT::types::TypeInfo::buildVariable ( std::string  name) const [inline]

Definition at line 189 of file TypeInfo.hpp.

Compose a type (target) from a DataSourceBase (source) containing its members. The default behavior tries to assign source to target. If that fails, it tries to decompose target into its members and update the members of target with the contents of source.

The default implementation in TemplateTypeInfo works for most types, but can be overridden in case there are multiple versions/possibilities to make a target from a source. For example, in order to support legacy formats or in order to do the inverse of decomposeType().

Parameters:
sourceA data source of the same type as target OR a PropertyBag that contains the parts of target to be refreshed.
targetA data source of the same type as this TypeInfo object which contains the data to be updated from source.
Returns:
true if source could be updated, false otherwise.
See also:
types::propertyDecomposition and types::typeDecomposition for the inverse function, decomposing a type into datasources and hierarchical properties.
decomposeType to do the inverse operation.

Definition at line 379 of file TypeInfo.hpp.

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.

Definition at line 86 of file TypeInfo.cpp.

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 117 of file TypeInfo.cpp.

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.

Returns:
null if this type is not convertible to anything else.
Deprecated:
by decomposeType. We want to rename convertType to decomposeType. This function is left here for transitional purposes.

Definition at line 407 of file TypeInfo.hpp.

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. If your return a datasource containing a property bag, then this function should do the inverse of composeType: the returned property bag contains all parts of the current type (source) which can be modified and merged back into this type with composeType. Mathematically: composeType( decomposeType( A ), B); assert( A == B );

Returns:
null in order to indicate that decomposition through getMember() may be tried. You may return source itself in order to prevent any further decomposition of your type (using getMember(), which is used as fall-back by the rest of the software. For example, to avoid that a string is decomposed into a sequence of chars, or to avoid that a primitive type like 'int' is further queried.

Definition at line 395 of file TypeInfo.hpp.

bool RTT::types::TypeInfo::fromString ( const std::string &  value,
base::DataSourceBase::shared_ptr  out 
) const [inline]

Usability function which converts a string to data.

Definition at line 292 of file TypeInfo.hpp.

Definition at line 478 of file TypeInfo.hpp.

Returns a member of a given data source struct identified by its name.

Parameters:
itemThe item of which to return a reference to a member
nameThe 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.
Returns:
null if no such member exists, an assignable datasource referencing that member otherwise.

Definition at line 329 of file TypeInfo.hpp.

bool RTT::types::TypeInfo::getMember ( internal::Reference ref,
base::DataSourceBase::shared_ptr  item,
const std::string &  name 
) const [inline]

Stores a reference to a member of a struct identified by its name. This method does not allocate memory when item is assignable..

Parameters:
refThe reference object in which to store the reference.
itemThe item of which to return a reference to a member. It must be assignable, otherwise, a reference to a copy of item will be returned. This copy will allocate memory.
nameThe name of a member within item.
Returns:
false if no such member exists, true if ref got filled in otherwise.

Definition at line 343 of file TypeInfo.hpp.

Returns a reference to a member of a given data source struct identified by its name.

Parameters:
itemThe item of which to return a reference to a member
nameThe 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.
Returns:
false if no such member exists, true if ref got filled in otherwise.

Definition at line 355 of file TypeInfo.hpp.

Definition at line 470 of file TypeInfo.hpp.

std::vector<std::string> RTT::types::TypeInfo::getMemberNames ( ) const [inline]

Returns the list of struct member names of this type. In case this type is not a struct, returns an empty list.

Definition at line 317 of file TypeInfo.hpp.

Definition at line 466 of file TypeInfo.hpp.

TypeTransporter * RTT::TypeInfo::getProtocol ( int  protocol_id) const

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 148 of file TypeInfo.cpp.

Definition at line 482 of file TypeInfo.hpp.

std::vector< int > RTT::TypeInfo::getTransportNames ( ) const

Return a list of protocols that have transporters

Definition at line 178 of file TypeInfo.cpp.

Returns the compiler generated type id pointer.

Definition at line 109 of file TypeInfo.hpp.

const char* RTT::types::TypeInfo::getTypeIdName ( ) const [inline]

Returns the compiler generated type name (non portable accross compilers!).

Definition at line 114 of file TypeInfo.hpp.

const std::string& RTT::types::TypeInfo::getTypeName ( ) const [inline]

Return the type name which was first registered. Do not rely on this function to return always the same string, as type loading order changes may return different names. Use getTypeNames() to get all aliases as well or getTypeIdName() to return the compiler generated C++ type name (non-portable accross compilers).

Definition at line 84 of file TypeInfo.hpp.

std::vector< std::string > RTT::TypeInfo::getTypeNames ( ) const

Returns all registered names and aliases of this type.

Definition at line 66 of file TypeInfo.cpp.

Definition at line 474 of file TypeInfo.hpp.

bool RTT::TypeInfo::hasProtocol ( int  protocol_id) const

Check if this type is transporable over a given protocol.

Definition at line 166 of file TypeInfo.cpp.

base::InputPortInterface* RTT::types::TypeInfo::inputPort ( std::string const &  name) const [inline]

Returns a new InputPort<T> object where T is the type represented by this TypeInfo object.

Definition at line 420 of file TypeInfo.hpp.

bool RTT::types::TypeInfo::isStreamable ( ) const [inline]

Returns true if this type is directly streamable using read()/write() or toString()/fromString().

Definition at line 301 of file TypeInfo.hpp.

bool RTT::TypeInfo::isType ( const std::string &  name)

Returns true if this type is known by the type system under the given name.

Parameters:
type_namethe name to query for
Returns:
true if this alias exists for this type.

Definition at line 77 of file TypeInfo.cpp.

base::OutputPortInterface* RTT::types::TypeInfo::outputPort ( std::string const &  name) const [inline]

Returns a new OutputPort<T> object where T is the type represented by this TypeInfo object.

Definition at line 429 of file TypeInfo.hpp.

std::istream& RTT::types::TypeInfo::read ( std::istream &  os,
base::DataSourceBase::shared_ptr  out 
) const [inline]

Read a new value for this datasource from a human readable string. The default does nothing.

Definition at line 275 of file TypeInfo.hpp.

bool RTT::types::TypeInfo::resize ( base::DataSourceBase::shared_ptr  arg,
int  size 
) const [inline]

Tries to resize a data source in case it's a resizable sequence.

Returns:
true if the resizing could be done, false otherwise.

Definition at line 198 of file TypeInfo.hpp.

Definition at line 476 of file TypeInfo.hpp.

Definition at line 468 of file TypeInfo.hpp.

Installs a new port factory such that in-process data can be communicated between components.

Definition at line 464 of file TypeInfo.hpp.

Definition at line 480 of file TypeInfo.hpp.

void RTT::types::TypeInfo::setTypeId ( TypeId  tid) [inline]

Definition at line 455 of file TypeInfo.hpp.

Definition at line 472 of file TypeInfo.hpp.

Usability function which converts data to a string.

Definition at line 284 of file TypeInfo.hpp.

std::ostream& RTT::types::TypeInfo::write ( std::ostream &  os,
base::DataSourceBase::shared_ptr  in 
) const [inline]

Output this datasource as a human readable string. The default just writes the type name in parentheses to os.

Definition at line 266 of file TypeInfo.hpp.


Member Data Documentation

Definition at line 486 of file TypeInfo.hpp.

boost::shared_ptr<CompositionFactory> RTT::types::TypeInfo::mcompf [protected]

Definition at line 494 of file TypeInfo.hpp.

boost::shared_ptr<ConnFactory> RTT::types::TypeInfo::mconnf [protected]

Definition at line 491 of file TypeInfo.hpp.

boost::shared_ptr<ValueFactory> RTT::types::TypeInfo::mdsf [protected]

Definition at line 493 of file TypeInfo.hpp.

boost::shared_ptr<MemberFactory> RTT::types::TypeInfo::mmembf [protected]

Definition at line 492 of file TypeInfo.hpp.

boost::shared_ptr<StreamFactory> RTT::types::TypeInfo::mstrf [protected]

Definition at line 495 of file TypeInfo.hpp.

Definition at line 490 of file TypeInfo.hpp.

const char* RTT::types::TypeInfo::mtid_name [protected]

Definition at line 489 of file TypeInfo.hpp.

std::vector<std::string> RTT::types::TypeInfo::mtypenames [protected]

Definition at line 488 of file TypeInfo.hpp.

Definition at line 487 of file TypeInfo.hpp.


The documentation for this class was generated from the following files:


rtt
Author(s): RTT Developers
autogenerated on Thu Jan 2 2014 11:35:45