Chapter 1   Handles (18.05)

Handles are now a distinct control data type. The new handle data type provides a reference counting system similar to iconic objects. This allows HALCON to keep the ownership of handles and to support an automatic destructor mechanism, i.e., the tool will be cleared automatically when the last handle referencing it is destroyed. Thus, the explicit call of a clear operator is not needed anymore, but can still be used for early freeing of resources.

Previously, there was no way to recognize if a number was just a number or a reference to a tool. Furthermore, it was not possible to check the type of a tool or to check whether a tool was already destroyed. Thus, an explicit clear was needed to avoid resource leaks (especially cumbersome for types where you manage many instances like with ObjectModel3D).