OWLNext    7.0
Borland's Object Windows Library for the modern age
Loading...
Searching...
No Matches
Creating Template Class Instances

Once you have defined a template class, you can create any number of instances of that class.

You can use template class instances to provide different descriptions of a template, search for different default file names, look in different default directories, and so on. You can affect all these things when calling the template class constructor.

The signature of a template class constructor is always the same:

TplName name(TRegList& regTable);
ElementDescription
TplNameThe class name you specified when defining the template class
nameWhatever name you want to give this instance
regTableThe name of a registration table created using the BEGIN/END_REGISTRATION macros (see Creating Document Registration Tables)"</TD></TR> </TABLE> @section example Example For example, suppose you have the following template class definition: @code DEFINE_DOC_TEMPLATE_CLASS(TPlotDocument, TPlotView, TPlotTemplate); \endcode Now suppose you want to create three instances of this template class: - One instance should have the description "Approved plots" for document files with the extension .PLT. Allow only a single view of the document and automatically delete the document when the view is closed. - Another instance should have the description "In progress" for document files with the extension .PLT. Automatically delete the document when the last view is closed. - Another instance should have the description "Proposals" for document files with the extensions .PLT or .TMP, but with the default extension of .PLT. Keep this template hidden until the user has entered a password and delete the document object when the last view is closed. The code for these instances would look something like this: @code BEGIN_REGISTRATION(aReg) REGDATA(description, "Approved plots") REGDATA(docfilter, "*.PLT") REGDATA(extension, "PLT") REGDOCFLAGS(dtSingleView | dtAutoDelete) END_REGISTRATION TPlotTemplate atpl(aReg); BEGIN_REGISTRATION(bReg) REGDATA(description, "In progress") REGDATA(docfilter,"*.PLT") REGDATA(extension, "PLT") REGDOCFLAGS(dtAutoDelete) END_REGISTRATION TPlotTemplate btpl(bReg); BEGIN_REGISTRATION(cReg) REGDATA(description, "Proposals") REGDATA(docfilter, "*.PLT; *.TMP") REGDATA(extension, "PLT") REGDOCFLAGS(dtHidden | dtAutoDelete) END_REGISTRATION TPlotTemplate *ctpl = new TPlotTemplate(cReg); \endcode Note that, as with any other class, you can create both static and dynamic instances of a document template. @section seealso See Also - \ref designingdocumenttemplateclasses "Designing Document Template Classes" - \ref creatingdocumentregistrationtables "Creating Document Registration Tables" - \ref modifyingexistingtemplates "Modifying Existing Templates"