TAOVar Out type
来源:互联网 发布:淘宝客优惠券采集软件 编辑:程序博客网 时间:2024/05/20 03:40
TAOVar Out type
By WalterXia walter.xia@gmail.com
In our project, TAO, ACE are used widelyand they are crossing platforms. Especially, the CORBA based on them is highweight IPCinfrastructure and used ininfra-card, inter-card, intra-process, and inter-process (different threads).
The Var, Out type implemented in TAO are employedto encapsulate defined IDL structures. In brief, the Var type is a smartpointer class and wrap native pointer and provides following member functions:
Supposed native type is T and its pointeris T*, T* & is a reference of native pointer.
Fucntion
Return type
Comment
in
const T &
Used as input parameter
out
T *&
The implementation is as followed:
delete this->ptr_; //destruct the original pointed content
this->ptr_ = 0; //set empty to the pointer
return this->ptr_;
inout
T &
_retn()
T *
The implementation is as followed:
T * tmp = this->ptr_;
this->ptr_ = 0; //original pointer will be set empty
return tmp; //original pointer content will be returned
ptr
T *
Return native pointer
While Out type is a reference of native pointer.
PracticeI:
If you want to convert the Var type to Out,such as XXX_Var to XXX_Out
XXX_Var à XXX_Out //invoke XXX_Var’s _retn() member functionfor converting
Func(XXX_Out xxx_out)
{
XXX_Var tmpVar;
….
xxx_out= tmpVar. _retn();
}
If want to use as following:
XXX_Var xxx_var;
……//changing the xxx_var
Func(xxx_var) //implicitly convert to Out type for the Vartype using following construct functionTAO_Out_T (T_var &)
(OR) Func(xxx_var.out())
The xxx_var contents will be erased when invokingthe Func.
Make sure the Func the statement of “ xxx_out= tmpVar. _retn();” will be called and there will be issues (xxx_var will benull and accessing its member functions is forbidden) if exception is thrown orreturned before the statement is executed.
The construct function’s implementation isas followed:
template<typename T, typename T_var>
ACE_INLINE
TAO_Out_T<T,T_var>::TAO_Out_T (T_var& p)
:ptr_ (p.out ())
{
delete this->ptr_; //original pointed content will be erased
this->ptr_ = 0;
}
PracticeII:
Passing native pointer as input argumentand doesn’t change the content
Using in member function of Var is recommended.
PracticeIII:
A function has an argument Var and want tochange the content in the function body. Just considering the Var ordinaryclass and its reference is recommend.
References:
ACE_wrappers/TAO/tao/VarOut_T.h //header files for
ACE_wrappers/TAO/tao/VarOut_T.inl //inline functions implementations
http://www.dre.vanderbilt.edu/Doxygen/5.5.1/html/tao/VarOut__T_8h.html
- TAOVar Out type
- Using PropertyInfo to find out the property type
- Out of memory. Type HELP MEMORY for your options (
- Out of memory. Type HELP MEMORY for your options
- out
- out
- out
- Out
- out
- C# 参数-ref 参数、out 参数和 params type[] 参数数列(转)
- C# 参数-ref 参数、out 参数和 params type[] 参数数列(转)
- The literal XXXXXXXXXX of type int is out of range 处理办法
- C++ typeid: find out type in rea…
- The literal 9999999999 of type int is out of range 或 400(rad request)
- 解决SPSS Modeler sql data type out of range<-25>报错
- Java 中The literal 078 of type int is out of range问题
- MATLAB问题之Out of memory. Type HELP MEMORY for your options
- KUDU-Got out-of-order key column: name: "ID" type: STRING is_key: true is_nullable: false
- SQL语句
- DDR工作原理
- 人人农场 renren 外挂 Java 实现
- Java集群平台terracotta
- Zend实用指南连载二:性能优化
- TAOVar Out type
- 半角 全角转换
- OpenJWeb网上商城开发文档及源代码
- CompareTo Semantics
- 走进SQL Server 2005 tempdb数据库
- 基础总结篇之三:Activity的task相关 (转载liuhe688)
- ExpandableListView控件
- OpenGL的坐标系
- CentOS设置默认启动命令行(不启动图形界面)