![]() |
VR-Vantage 2.3 API Documentation
|
The Factory pattern allows creation of specializations on a single base class within the scope of a root object.
The Abstract Factory pattern creates an instance of an object from a family of objects without having to specify the concrete class to be created. Our Factory pattern extends this to include Rooted Singleton support, meaning each root object (display engine) will have its own factory and there can be multiple root objects in an application.
VR-Vantage uses the Factory pattern a lot. From creating different kinds of windows, to creating different types of file parsers, it is an important pattern to understand.
Here is an example Factory pattern:
Suppose your program needs to be able to parse different types of terrain files and determine the coordinate system of each one.
Write the base class header parser. This provides the API that all your derived file format parsers would conform to. For example, you will need an OpenFlight parser, a DTED parser, 3DS parser, and so on.
Create the file parser factory:
There is also the base class file parser creator class:
Derive the file format parsers and their creators, and register them with the creator:
The Factory pattern has the following requirements and behavior:
[<< The Signaler Pattern ] [Home] [Top of Page] [The Creator Pattern >>]