.. role:: blue :class: blue MbRefItem Reference Counter =========================== .. _MbRefItem_Reference_Counter_: .. kernel version: 118060 The :blue:`MbRefItem` class is declared in the *reference_item.h* file. The :blue:`MbRefItem` class is characterized by the number of its owners *useCount* and represents a counter of objects that own the given object. The geometric objects of the C3D kernel are divided into three groups: two-dimensional geometric objects, three-dimensional geometric objects and topological objects. Geometric objects of these three groups are derived from the :blue:`MbRefItem` and :blue:`TapeBase` classes: .. figure:: /MODELER/GEOMETRICAL_OBJECTS/pictures/O.2.1.1.png :width: 12cm :align: center The :blue:`TapeBase` class provides stream writing and reading for its child class. The following objects are derived from the :blue:`MbRefItem` and :blue:`TapeBase` classes: :ref:`MbSpaceItem ` is the base abstract class of three-dimensional geometric objects; :ref:`MbTopItem ` is the base abstract class of topological objects; :ref:`MbPlaneItem ` is the base abstract class of two-dimensional geometric objects; :ref:`MbFunction ` is the base abstract class of scalar functions. The reference counter ensures correct work of classes and methods that contain pointers to geometric objects. If a class stores a pointer to a geometric object in its data, then in its constructor it must increase the reference counter of the geometric object by one using the :blue:`AddRef`\() method, and in its destructor it must call the :blue:`Release`\() method of the geometric object, which decreases the reference counter of the geometric object by one and, when the reference counter reaches zero, deletes the geometric object. The :blue:`DecRef`\() method decreases the reference counter of the geometric object by one. It is intended for internal use in the implementation where a decrease of the counter without ownership release is explicitly required. The :blue:`MbRefItem` class is processed by the duplication registrar :blue:`MbRegDuplicate` and by the transformation registrar :blue:`MbRegTransform`. The :blue:`RefType`\() method returns the registration type of the object that uses the reference counter.