OWLNext    7.0
Borland's Object Windows Library for the modern age
Loading...
Searching...
No Matches
ocf::TOleFactoryBase< T, Obj > Class Template Reference

A template class, TOleFactoryBase<> creates callback code for ObjectWindows classes. More...

#include <ocf/olefacto.h>

Public Member Functions

 operator TComponentFactory ()
 Converts the object into a pointer to the factory.
 

Static Public Member Functions

static IUnknown * Create (IUnknown *outer, owl::uint32 options, owl::uint32 id)
 A TComponentFactory callback function that creates or destroys the application or creates objects.
 

Detailed Description

template<class T, class Obj>
class ocf::TOleFactoryBase< T, Obj >

A template class, TOleFactoryBase<> creates callback code for ObjectWindows classes.

The main purpose of the factory code is to provide a callback function, Create, that ObjectComponents calls to create objects.

Just as a recipe consists of a list of instructions about how to make a particular kind of food, a template, such as TOleFactoryBase<>, contains instructions about how to make an object, in this case, a factory object. TOleFactoryBase<> includes two public member functions. The three additional functions are passed as template arguments. Although these template arguments actually belong to the class that is instantiated when you fill in the arguments to TOleFactoryBase<>, they are described here for convenience.

Use TOleFactoryBase<> to manufacture objects in general, whether or not they are embedded, OLE-enabled, or use the Doc/View model. These objects might or might not be connected to OLE.

The callouts are supplied through the arguments passed to the template class. The factory base class takes three template parameters: the application type, a set of functions to create the object, and a set of functions to create an automation object. Depending on the arguments passed, you can make the following OLE-enabled components:

  • Doc/View components that are automated
  • Doc/View components that are not automated
  • Non-Doc/View components that are automated
  • Non-Doc/View components that are not automated

ObjectWindows provides a standard implementation for object creation and automation. Factory Template Classes gives an overview of these classes.

By using TOleFactoryBase<> to obtain an OLE interface for your application, you can make objects that are accessible to OLE. That is, TOleFactoryBase<> handles any relationships with IUnknown, a standard OLE interface.

Definition at line 227 of file olefacto.h.

Member Function Documentation

◆ Create()

template<class T , class Obj >
IUnknown * ocf::TOleFactoryBase< T, Obj >::Create ( IUnknown * outer,
owl::uint32 options,
owl::uint32 id )
static

A TComponentFactory callback function that creates or destroys the application or creates objects.

If an application object does not already exist, Create creates a new one. The outer argument points to the OLE 2 IUnknown interface with which this object aggregates itself. If outer is 0, If outer is 0, the object will become an independent object. The options argument indicates the application's mode while it is running. The values for options are either set from the command line or set by ObjectComponents. They are passed in by the Registrar to this callback. The application looks at these flags in order to know how to operate, and the factory callback looks at them in order to know what to do. For example, a value of amExeMode indicates that the server is running as an .EXE either because it was built as an .EXE or because it is a .DLL that was launched by an .EXE stub and is now running as an executable program. The TOcAppMode enum description shows the possible values for the options argument. If the application already exists and the object ID (id) equals 0, Create returns the application's OLE interface. Otherwise, it calls OCInit to create a new TOcApp and register the options from TOcAppMode enum, which contains OLE-related flags used in the application's command line. (These flags tell the application whether it has been run as a server, whether it needs to register itself, and so on.) If a component ID was passed, that becomes the component; otherwise, Create runs the application itself based on the values of the TOcAppMode enum and returns the OLE interface.

Definition at line 272 of file olefacto.h.

References ocf::amEmbedding, ocf::amRun, ocf::amServedApp, ocf::amShutdown, owl::TAppDictionary::GetApplication(), owl::OWLGetAppDictionary(), ocf::TUnknown::SetOuter(), and TYPESAFE_DOWNCAST.

◆ operator TComponentFactory()

Converts the object into a pointer to the factory.

ObjectComponents uses this pointer to create the object.

Definition at line 231 of file olefacto.h.

References ocf::TOleFactoryBase< T, Obj >::Create().


The documentation for this class was generated from the following file: