# Objects-by-Value

Points of contact: Jeff Parsons Boris Kolpackov George Edwards

Last Update: 2003/06/30

Objects-by-Value (OBV) describes the new type, `valuetype`, introduced in CORBA 2.3
(Core: formal/02-12-06.pdf; Mapping to C++: formal/03-06-03.pdf).

The original TAO implementation was contributed by Torsten Kuepper, and has subsequently been enhanced and corrected by Jeff Parsons and George Edwards.

`Valuetype`s are similar to IDL `struct`s extended with these capabilities:

- Encapsulate both state information and operations in an implementation that is guaranteed to be local.

- Can be declared `abstract`, in which case no state members are defined.

- Can inherit from a single concrete `valuetype` and multiple `abstract valuetype`s.

- Can support a single concrete `interface`, allowing them to be manipulated as either a valuetype or an object reference.

- Can support multiple `abstract interface`s, allowing them to be substituted for those interfaces in operation invocations.

- Can hold references to other `valuetype`s, with the possibility of NULL references or shared (aliased) references.

Valuetypes have the following uses:

- Implement abstract datatypes (ADTs) that can be copied to another process.

- Represent `eventtype`s in the Event Service.

- Ensure operations are executed locally for increased performance.

### Current status:

- The IDL compiler understands `valuetype`. Relevant options of TAO's IDL compiler are:

  - -Gv Enable OBV support (default)
  - -Sv Disable OBV support
  - -Wb,obv_opt_accessor Make accessor and modifier functions inline. Overriding them is not allowed in this mode.

  `libTAO` must be compiled with `TAO_HAS_VALUETYPE`.

- `Valuetype`s can be used as arguments in CORBA invocations. There is an example in $TAO_ROOT/TAO/examples/OBV/Typed_Events. `Valuetype`s can reference other `valuetype` objects (but without sharing).

- Support for valuetypes as members of IDL aggregate types has been added.

- Support for inheritance from a concrete interface (`supports`) has been added. There is an example in $TAO_ROOT/TAO/tests/OBV/Supports.

- Support for inheritance from abstract interfaces has been added. There is an example in $TAO_ROOT/TAO/tests/Abstract_Interface.

- Support for forward declared valuetypes defined in another compilation unit has been added. See $TAO_ROOT/TAO/examples/OBV/Typed_Events.

- Support for recursively-defined valuetypes has been added. See $TAO_ROOT/TAO/tests/OBV/Supports.

- Support for user-declared factories has been added. See $TAO_ROOT/TAO/tests/OBV/Factory.

### Known issues:

- `Valuetype`s work only in conjunction with compiled marshaling (`-Gc`, currently default for `tao_idl`).

- No support for sharing (aliasing).

- No support for `valuebox`es

- No support for `valuetype`s with cyclic references.

- No support for fragmentation (chunking) of the marshalled `valuetype` object. Hence no support for truncation or custom marshalling.

- The marshal engine accesses the state members directly and does not utilize the accessor/modifier functions. This is different from the CORBA specs and needs to be changed. But the optimized mode (`-Wb,obv_opt_accessor`) should be unaffected by that.

- The map of `valuetype` factories needs some revision to provide proper locking. Currently the registration of factories is best completed before unmarshalling `valuetype`s. There is one map of factories for the whole process. This will once be changed to conform to the specs, which suggests one per ORB.

Back to TOC