What is Adaptation - kaisu1986/ATF GitHub Wiki

Adaptation is the process of allowing an object of one type to behave like another type. This means the object can use the API of another type: its methods, properties, and events. You can think of adaptation as dynamic casting.

An adapter for an object A to type T is an object that has all the behavior and data of A and also behaves like an object of type T. In this case, A is the adaptee of the adapter. An object can be its own adapter.

Adapters implement the IAdapter interface. Adaptees implement the IAdaptable interface, which obtains an adapter for a given type.

Adaptation is a powerful tool used widely in ATF. Adaptation gives you the ability to extend the behavior of objects without using inheritance. To add new functionality to an object's class, you don't need to make it implement an interface or derive from another class: simply add an adapter with the new capabilities.

DOM adapters that adapt DomNodes are one of the most important kinds of adapters. For more information, see the ATF Programmer’s Guide: Document Object Model (DOM), which you can download at ATF Documentation.

You can also use adaptation with controls. AdaptableControl, and its Direct2D version D2dAdaptableControl, are base controls that can take control adapters. Classes that derive from ControlAdapter add new functions to controls without changing the controls. ATF has a large set of ControlAdapter classes, and you can create your own by deriving from ControlAdapter or one of its ancestors.

The Adaptation Framework's interfaces and classes are in two namespaces:

  • Sce.Atf.Adaptation: contains general interfaces and classes.
  • Sce.Atf.Controls.Adaptable: has the interfaces and classes for control adapters.

Topics in this section

⚠️ **GitHub.com Fallback** ⚠️