Download
latest Releases : 2.0.0-RELESE
2.0.0-RELESE | Download page |
Number of Projects
RT-Component | 154 |
RT-Middleware | 35 |
Tools | 23 |
Documentation | 2 |
Choreonoid
Motion editor/Dynamics simulator
OpenHRP3
Dynamics simulator
OpenRTP
Integrated Development Platform
AIST RTC collection
RT-Components collection by AIST
TORK
Tokyo Opensource Robotics Association
DAQ-Middleware
Middleware for DAQ (Data Aquisition) by KEK
Structure/Object reference
In C++, the structure of CORBA is mapped to the structure "struct".
If the structure contains variable length members (string, wstring, sequence, (struct with variable length members, union with variable length member), the structure is considered variable length data. In this case, C ++ code different from the fixed length structure is generated, and handling in return value and out parameter is different.
_ var type
Transformation constructor (T_ptr)
The ownership of object reference of type _ptr moves to type _ var, so there is no increase or decrease of reference count.
Transformation constructor (const T_var&)
The ownership of the object reference of _var type of the assignment source is copied.
Transformation constructor (const T_member)
in argument and in () function
It simply returns _ptr type pointer of object reference. Movement of ownership does not occur.
It is usually used to pass an object reference to the in argument of a function. Functions given object references do not have ownership and should not be 'released' in the function. After returning from the function, the _var type variable still holds ownership, and the object is released when the _var type variable is disassembled.
When defining a function that takes an object reference as an in argument, it is defined as an argument of type _ptr. Furthermore, within a function, just call the operation of the object, do not do release etc. Also, if you want to save an object reference in a function somewhere (global variable, static variable, object member etc.), you need to duplicate the duplicate function to copy ownership.
out argument and out () function
Returns the currently owned reference as release (decrement the reference count) and sets the reference pointer to nil and returns it. That is, if an object reference is held before the out () function call, the ownership is abandoned and the reference is discarded.
It is usually used to pass an object reference to the out argument of a function. That is, after returning from the function, it is expected that a new object reference is held in this variable. At this time, ownership of the object reference is assumed to be held in this variable. On the function side passed the variable with out(), it is necessary to generate or duplicate an object reference in some way and pass ownership to the argument.
When defining a function that takes an object reference as an out argument, it is defined as an argument of _ptr type reference. Within a function, an argument is always a nil object reference, and it is normally expected to substitute some object for ownership.
inout()
Returns a pointer reference to the reference.
It is usually used to pass an object reference to the inout argument of a function. That is, within the function, it is expected that some object reference is included in the argument, and the ownership of the object shifts to the function side. Also, the function is expected to give some object reference to this argument and return it, giving arguments, ie ownership of the calling variable. In the function, when setting an object reference newly as an argument, it is necessary to first generate release and then create or duplicate a new object reference and pass ownership to the argument.
Functions that take object references as inout arguments are not highly recommended from a design standpoint. If you need to define a function to take as an inout argument, define it as an argument to _ptr type reference.
_retn()
Abandon ownership of the object reference currently held and return a pointer.
It is usually used when returning an object reference to the return value of a function. Since ownership passes to the caller of the function, the caller is responsible for discarding object references. Therefore, it needs to be released on the caller side or received with the _var type variable. Conversely, when returning an object reference by return value, since the reference always decrements the reference count by release on the caller side, it is necessary to duplicate the ownership by _duplicate () etc. within the function.
Rule summary
Reference count with substitution of _var type, _ptr type
Assigning _var type to _ptr type
Assignment to a pointer.
No replication, no release.
_ptr type assignment to type _var
It is released () for the object held by _var, It is not duplicate () for _ptr type objects passed as arguments.
No duplication, release.
Assigning _var type to _var type
Release () is called on the object held by _var, Also, duplicate () is called on the object passed in the argument.
There is duplication, release.
Reference count with _narrow ()
In the process of _narrow () processing, when the call to _narrow () succeeds, the reference count of the target object is incremented, but if it fails it is not incremented.
Decrement is not performed.
Rules
Client side
If the client receives an object reference from the call, the client must release it when that object reference is no longer needed.
Server side
The ownership of the reference passed to the caller is abandoned (that is, its reference count is decremented by one, so it is normal to call the appropriate _duplicate () function before returning the reference)