Share

AcDbObjectPointerBase

Class Hierarchy

AcDbObjectPointerBase

C++

template <class T_OBJECT>
class AcDbObjectPointerBase;

File

dbobjptr.h

Description

AcDbObjectPointerBase is the base class for a group of template classes that simplify memory management of pointers to AcDbObjects and opening and closing AcDbObjects.

These classes provide automatic opening and closing of AcDbObjects upon construction and destruction. The constructor provides the necessary arguments to open the object, and the destructor closes the object. During the lifetime of the object, clients use operator->() to manipulate the opened object.

AcDbObjectPointerBase provides the basic services of opening and closing objects given object IDs and defines the basic contracts for using the smart pointers derived from it. Derived classes provide the real interface to open objects of various types derived from AcDbObject. Derived classes usually provide additional constructors that know about the particular ways of opening an object.

You normally don't use AcDbObjectPointerBase directly, but may use it to define a derived class to add constructors that know how to open an object derived from AcDbObject in alternate forms. Template argument T_OBJECT should be AcDbObject or a class derived from AcDbObject that can be opened via acdbOpenObject().

Contracts

All derived classes must abide by and enforce the following contracts.

  1. Copying and assignment are prohibited. Derived classes must also prohibit copying and assignment by declaring those functions private. These classes contain a pointer to the real object, so the default constructors provided by the compiler must not be used. Copying and assignment do not have obvious semantics of whether you own the object or just the pointer. You can pass AcDbObjectIds and use these classes to simplify opening the objects by their ID.
  2. Clients must not close the objects themselves by using the close() member function. The destructor will close the object. These pointer classes are meant to keep the object open for the lifetime of the pointer object. Note that an upgradeOpen() may fail, but is compatible with the semantics of the pointer classes. A failure to upgrade will leave the object opened in its original mode. A consequence of this contract is that passing the pointers returned by operator->() to other functions may lead to unexpected problems if the other functions close the object through the pointer.
  1. Derived classes should provide the following constructors:
  2. All clients will call the openStatus() member function to determine if the object was successfully opened before using operator->().

The default constructor provided by AcDbObjectPointerBase sets the open status to Acad::eNullObjectPointer.

Links

AcDbObjectPointerBase Constructor, AcDbObjectPointerBase Methods, AcDbObjectPointerBase Operators

See Also

AcDbObjectPointer, AcDbSymbolTablePointer, AcDbSymbolTableRecordPointer

Was this information helpful?