Dapfor home  

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 allows creating CFormat object by a string. Mainly, the factory was designed for serialization purpose, but 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 placed in different namespaces, an ambiguous situation can 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.

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

Member Function Documentation

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

Registers a new format.

Parameters:
[in] formatName Name of the format
[in] f Pointer to the function, that creates a format of the specified class.
Returns:
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.

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


Copyright Dapfor 2007-2009
Generated on Sat Jan 30 15:01:24 2010 for MFCGrid by doxygen 1.5.5