RAD Studio VCL Reference
TContainedObject Class

System::TContainedObject implements the IInterface interface as an inner object in an aggregate.

TContainedObject = class(TAggregatedObject, IInterface);
class TContainedObject : public TAggregatedObject, public IInterface;

System::TContainedObject can be used as a base for classes that create inner, or contained, objects of an aggregate. In Delphi, use TComObject or its descendants to instantiate an outer object that supports aggregation.

  • The following implementation rules apply to aggregatable (inner or contained) objects, and are supported by System::TContainedObject:
  • When an object of its type is created, the creation succeeds only for a requested interface of type IInterface.
  • The IInterface methods _AddRef and _Release delegate to the controlling IInterface.
  • QueryInterface is implemented in System::TContainedObject only for interfaces implemented in the contained object.
  • The reference count on the inner object is incremented in the containing object.

Note: In Delphi, System::TContainedObject is used as a base class for a connection point that must be an inner object in an aggregate.
Note: An aggregated object is an object that is composed of several interfaced objects. Each object implements its own behavior and interfaces, but all of the objects share the same reference count, which is that of the controller object. In the container pattern, the controller is the container object.

Copyright(C) 2009 Embarcadero Technologies, Inc. All Rights Reserved.
What do you think about this topic? Send feedback!