orocos 的数据表示(模板template): DataObject (还有一条主线为 DataSource)
来源:互联网 发布:绿标域名认证生成器 编辑:程序博客网 时间:2024/06/06 19:38
数据有不同的type(int,double,struct…),还有 c-v qualifier, 还可以是 reference、pointer、array等等。因此,在处理数据的时候要正确区分每一种数据类型的处理方法。
例如:不能对引用类型取引用,不能对右值取引用等等:
typedef typename boost::remove_const<typename boost::remove_reference<T>::type>::type value_t;typedef typename boost::call_traits<value_t>::param_type param_t;typedef typename boost::call_traits<value_t>::reference reference_t;typedef typename boost::call_traits<value_t>::const_reference const_reference_t;
see Effective Modern C++ Deducing Types
c++11引入 universal reference( T&&, std::forward) 和 alias(using), 可以简化上述代码:
The forward template exists in C++11, in the
<utility>
header, as std::forward
see link universal-references: http://eli.thegreenplace.net/2014/perfect-forwarding-and-universal-references-in-c/
orocos数据TypeInfo:
struct RTT_API UnknownType {};template< class T>struct DataSourceTypeInfo;template<>struct RTT_API DataSourceTypeInfo<UnknownType> { typedef UnknownType value_type; typedef DataSourceTypeInfo<UnknownType> value_type_info; static types::TypeInfo* TypeInfoObject; static const std::string noqual; // void static const std::string cqual; // const static const std::string refqual; // reference static const std::string crefqual; // const reference static const std::string ptrqual; // pointer static const std::string cptrqual; // const pointer static const std::string& getType(); // 都是 static 函数,包括下列各个特化模板,因此其他类只需要直接使用该模板即可得到其他类的数据类型信息 static const std::string& getTypeName(); static const std::string& getQualifier(); // we drop the const qualifier in this specialisation, since it is // not registered in the type repository (which returns a non const in type() ) static types::TypeInfo* getTypeInfo(); // type_name、 qualifier、std::type_info * etc. compiler dependent info};template< class T> struct DataSourceTypeInfo<const T&> { typedef T value_type; typedef DataSourceTypeInfo<T> value_type_info; static std::string getType() { return getTypeName() + getQualifier(); } static const std::string& getTypeName() { return DataSourceTypeInfo< T >::getTypeName(); } // value_type 的类型 static const std::string& getQualifier() { return DataSourceTypeInfo<UnknownType>::crefqual; } //qualifier: 其他类型就换成别的字符串("const"、"&" 等等) static const types::TypeInfo* getTypeInfo() { return DataSourceTypeInfo< T >::getTypeInfo(); }};// 以下类似template< class T> struct DataSourceTypeInfo<T&> {...}template< class T> struct DataSourceTypeInfo<const T> {...}template< class T> struct DataSourceTypeInfo<T*> {...}template< class T> struct DataSourceTypeInfo<const T*> {...}template<> struct RTT_API DataSourceTypeInfo<void> {...}/*** Specialisation for a types::carray<T> type info object.* All RTT internal primitives should use carray references* to (boost) arrays such that run-time size checks can be done.* For example, Property<carray<double> > holds a* ValueDataSource<carray<double> >( carray<double>( data.c_array(), 6 ) )* where data is a boost::array<double,6> or equivalent*/template< class T> struct DataSourceTypeInfo<types::carray<T> > {...}
Orocos DataObject类的结构:
DataObjectInterface | / \ / \ DataObjectLocked DataObjectLockFree \ / \ / DataOjbect
DataObjectLocked 和 DataObjectLockFree 分别继承自DataObjectInterface; 然后 DataOject再继承 DataObjectLocked 和 DataObjectLockFree
0 0
- orocos 的数据表示(模板template): DataObject (还有一条主线为 DataSource)
- typeinfo dynamic_cast & 模板编程 & orocos OperationCaller 类的设计
- C++ Template初探:以模板为参数的模板
- 保留最后的一条数据为Y
- vue的模板 <template></template>
- 用DataSource控件以外的方法为GridView提供数据
- template tracking(基于模板的跟踪)
- C++template(模板)的使用
- 微信小程序给嵌套template模板传递数据的方式
- mysql插入一条数据之后(ID为自动增长列),返回该条数据的ID
- 创建自定义的DataObject类型
- 多备份数据更新管理器模板设计(C++ Template)
- RobotFrameWork(七)数据驱动之Template模板
- Template(模板)
- 模板模式(Template)
- 模板(Template)
- 模板(Template)
- Template(模板)
- PHP读取大文件
- 播放视频
- 论文修改内容,第一篇
- dubbo,zookeeper,spring 案列
- 地表最强! Unity 5.x 插件合集专用贴 - 更新日期 2015.12.06
- orocos 的数据表示(模板template): DataObject (还有一条主线为 DataSource)
- 外部中断(红外通信)
- iOS开发者的福利 — — iOS9+Xcode7免越狱免证书直接调试
- Xml解析
- rhel 6.5 安装yum源
- UltraEdit if() 后自动缩进问题
- org.hibernate.transaction.JDBCTransaction cannot be cast to javax.transaction.Transaction
- 自定义Android progress bars
- MapReduce性能优化_1. 性能测量