38 #ifndef ORO_CORELIB_TYPEINFO_HPP 39 #define ORO_CORELIB_TYPEINFO_HPP 43 #include "../base/DataSourceBase.hpp" 44 #include "../base/ChannelElementBase.hpp" 46 #ifndef NO_TYPE_INFO_FACTORY_FUNCTIONS 50 #ifndef NO_TYPE_INFO_STREAMS 69 typedef const std::type_info *
TypeId;
71 TypeInfo(
const std::string& name) : mtypenames(1,name) {}
82 const std::string&
getTypeName()
const {
return mtypenames[0]; }
87 std::vector<std::string> getTypeNames()
const;
94 void addAlias(
const std::string& alias);
102 bool isType(
const std::string& name);
154 bool hasProtocol(
int protocol_id)
const;
159 std::vector<int> getTransportNames()
const;
161 #ifndef NO_TYPE_INFO_FACTORY_FUNCTIONS 174 return mdsf ? mdsf->buildConstant(name, source, sizehint) : 0;
179 return mdsf ? mdsf->buildConstant(name, source) : 0;
189 return mdsf ? mdsf->buildVariable(name) : 0;
198 return mmembf ? mmembf->resize(arg, size) :
false;
207 return mdsf ? mdsf->buildAlias(name, b) : 0;
215 return mdsf ? mdsf->buildProperty(name, desc, source) : 0;
223 return mdsf ? mdsf->buildAttribute(name, source) : 0;
254 #ifndef NO_TYPE_INFO_STREAMS 267 return mstrf->write(os,in);
269 #ifdef OS_HAVE_STREAMS 270 std::string output = std::string(
"(")+ in->getTypeName() +
")";
283 return mstrf ? mstrf->read(os, out) : os;
292 return mstrf ? mstrf->toString(in) : std::string();
300 return mstrf ? mstrf->fromString(value, out) :
false;
309 return mstrf ? mstrf->isStreamable() :
false;
325 return mmembf ? mmembf->getMemberNames() : std::vector<std::string>();
351 return mmembf ? mmembf->getMember(ref, item,name) :
false;
387 return mcompf ? mcompf->composeType(source,target) :
false;
444 #endif // NO_TYPE_INFO_FACTORY_FUNCTIONS 448 mtid_name = tid->name();
482 boost::shared_ptr<internal::ConnFactory>
mconnf;
484 boost::shared_ptr<ValueFactory>
mdsf;
485 boost::shared_ptr<CompositionFactory>
mcompf;
486 boost::shared_ptr<StreamFactory>
mstrf;
base::DataSourceBase::shared_ptr buildReference(void *ptr) const
Build a internal::ReferenceDataSource of this type, pointing to the given pointer.
bool composeType(base::DataSourceBase::shared_ptr source, base::DataSourceBase::shared_ptr target) const
Compose a type (target) from a DataSourceBase (source) containing its members.
boost::shared_ptr< MemberFactory > MemberFactoryPtr
void setStreamFactory(StreamFactoryPtr sf)
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 source=0) const
Build an Attribute of this type.
This interface defines the function a transport protocol must support in order to allow Orocos compon...
const std::string & getTypeName() const
Return the type name which was first registered.
boost::shared_ptr< CompositionFactory > mcompf
TypeInfo(const std::string &name)
bool isStreamable() const
Returns true if this type is directly streamable using read()/write() or toString()/fromString().
void setValueFactory(ValueFactoryPtr dsf)
Base class for all properties.
std::string toString(base::DataSourceBase::shared_ptr in) const
Usability function which converts data to a string.
boost::shared_ptr< MemberFactory > mmembf
bool resize(base::DataSourceBase::shared_ptr arg, int size) const
Tries to resize a data source in case it's a resizable sequence.
const std::type_info * TypeId
void setCompositionFactory(CompositionFactoryPtr cf)
base::DataSourceBase::shared_ptr buildActionAlias(base::ActionInterface *action, base::DataSourceBase::shared_ptr source) const
Returns a DataSource that first executes an action and returns the result of another data source...
TypeId getTypeId() const
Returns the compiler generated type id pointer.
Transporters transporters
A connection policy object describes how a given connection should behave.
The base class of each OutputPort.
CompositionFactoryPtr getCompositionFactory() const
boost::shared_ptr< internal::ConnFactory > mconnf
const char * getTypeIdName() const
Returns the compiler generated type name (non portable accross compilers!).
bool getMember(internal::Reference *ref, base::DataSourceBase::shared_ptr item, const std::string &name) const
Stores a reference to a member of a struct identified by its name.
MemberFactoryPtr getMemberFactory() const
std::vector< std::string > getMemberNames() const
Returns the list of struct member names of this type.
void setTypeId(TypeId tid)
An attribute is a minimalistic, named placeholder for data.
boost::shared_ptr< StreamFactory > StreamFactoryPtr
bool fromString(const std::string &value, base::DataSourceBase::shared_ptr out) const
Usability function which converts a string to data.
base::AttributeBase * buildConstant(std::string name, base::DataSourceBase::shared_ptr source, int sizehint) const
Build a non modifyable instance of this type.
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.
boost::shared_ptr< internal::ConnFactory > ConnFactoryPtr
base::DataSourceBase::shared_ptr getMember(base::DataSourceBase::shared_ptr item, base::DataSourceBase::shared_ptr id) const
Returns a reference to a member of a given data source struct identified by its name.
ConnFactoryPtr getPortFactory() const
base::AttributeBase * buildConstant(std::string name, base::DataSourceBase::shared_ptr source) const
Build a non modifyable instance of this type.
Based on the software pattern 'command', this interface allows execution of action objects...
A class for representing a user type, and which can build instances of that type. ...
base::AttributeBase * buildAlias(std::string name, base::DataSourceBase::shared_ptr b) const
build an alias with b as the value.
void setMemberFactory(MemberFactoryPtr mf)
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...
base::PropertyBase * buildProperty(const std::string &name, const std::string &desc, base::DataSourceBase::shared_ptr source=0) const
Build a Property of this type.
boost::shared_ptr< ValueFactory > ValueFactoryPtr
boost::intrusive_ptr< ChannelElementBase > shared_ptr
Constructors constructors
boost::shared_ptr< CompositionFactory > CompositionFactoryPtr
ValueFactoryPtr getValueFactory() const
std::vector< std::string > mtypenames
base::DataSourceBase::shared_ptr buildValue() const
Build a internal::ValueDataSource of this type.
This interface describes how constructors work.
boost::shared_ptr< ValueFactory > mdsf
Object that may receive a reference to some data by means of a pointer or data source.
boost::shared_ptr< StreamFactory > mstrf
void setPortFactory(ConnFactoryPtr cf)
Installs a new port factory such that in-process data can be communicated between components...
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.
StreamFactoryPtr getStreamFactory() const
std::vector< TypeConstructor * > Constructors
base::DataSourceBase::shared_ptr decomposeType(base::DataSourceBase::shared_ptr source) const
Specialize this function to return an alternate type which represents this one in a compatible way...
std::vector< TypeTransporter * > Transporters
std::istream & read(std::istream &os, base::DataSourceBase::shared_ptr out) const
Read a new value for this datasource from a human readable string.
std::ostream & write(std::ostream &os, base::DataSourceBase::shared_ptr in) const
Output this datasource as a human readable string.