TObject Branch

From RAD Studio
Jump to: navigation, search

Go Up to Objects, Components, and Controls


The TObject branch includes all VCL classes that descend from TObject but not from TPersistent. Much of the powerful capability of the component library is established by the methods that TObject introduces. TObject encapsulates the fundamental behavior common to all classes in the component library by introducing methods that provide:

  • The ability to respond when object instances are created or destroyed.
  • Class type and instance information on an object, and runtime type information (RTTI) about its published properties.
  • Support for handling messages (VCL applications).

TObject is the immediate ancestor of many simple classes. Classes in the TObject branch have one common, important characteristic: they are transitory. This means that these classes do not have a method to save the state that they are in prior to destruction; they are not persistent.

One of the main groups of classes in this branch is the Exception class. This class provides a large set of built-in exception classes for automatically handling divide-by-zero errors, file I/O errors, invalid typecasts, and many other exception conditions.

Another group in the TObject branch is classes that encapsulate data structures, such as:

  • TBits, a class that stores an "array" of Boolean values.
  • TList, a linked list class.
  • TStack, a class that maintains a last-in first-out array of pointers.
  • TQueue, a class that maintains a first-in first-out array of pointers.

Another group in the TObject branch are wrappers for external objects like TPrinter, which encapsulates a printer interface, and TIniFile, which lets a program read from or write to an ini file.

TStream is a good example of another type of class in this branch. TStream is the base class type for stream objects that can read from or write to various kinds of storage media, such as disk files, dynamic memory, and so on (see Using streams for information on streams).

See Also