MFC Grid manual

CFormatFactory Class Reference

Singleton which realizes a format factory. More...

#include <Dapfor/Common/FormatFactory.h>

List of all members.

Public Types

typedef CFormat *(* pfnCreate )()
 Function prototype to create a format object.

Static Public Member Functions

static bool RegisterFormat (const TString &formatName, pfnCreate f)
 Registers a new format.
static CFormatCreate (const TString &formatName)
 Creates a new format object by a string.

Detailed Description

Singleton which realizes a format factory.

The factory enables creating CFormat object by a string. The factory was designed for serialization purpose, however it can be used in another way. To make format registration easier, DF_DECLARE_FORMAT() macro can be used. If there are two formats with the same name, but in different namespaces, an ambiguous situation may occur during the registration. To avoid this, it is recommended to use a full name together with a namespace name. All the formats, included in this library can be created by CFormatFactory.

 //You can get a format of CLongFormat type, by making the following:
 Common::CFormat* format = CFormatFactory::Create("Common::CLongFormat");
1.0.0 Initial version

Member Function Documentation

bool RegisterFormat ( const TString &  formatName,
pfnCreate  f 
) [inline, static]

Registers a new format.

[in] formatName Name of the format
[in] f Pointer to the function, that creates a format of the specified class.
True if the format has been successfully registered, otherwise false.
Thread safety:
The function is thread safe

CFormat * Create ( const TString &  formatName  )  [static]

Creates a new format object by a string.

[in] formatName Format name used at registration.
A new format object, if the class of the format has been registered. Otherwise zero.
Thread safety:
The function is thread safe