MbRefItem Reference Counter

The MbRefItem class is declared in the reference_item.h file.

The 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 MbRefItem and TapeBase classes:

../../../../_images/O.2.1.1.png

The TapeBase class provides stream writing and reading for its child class.

The following objects are derived from the MbRefItem and TapeBase classes:

MbSpaceItem is the base abstract class of three-dimensional geometric objects;

MbTopItem is the base abstract class of topological objects;

MbPlaneItem is the base abstract class of two-dimensional geometric objects;

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 AddRef() method, and in its destructor it must call the 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 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 MbRefItem class is processed by the duplication registrar MbRegDuplicate and by the transformation registrar MbRegTransform.

The RefType() method returns the registration type of the object that uses the reference counter.