MFC Grid manual

CField Class Reference

Presets and describes a field in a class derived from CDataObject. More...

#include <Dapfor/Common/CField.h>

List of all members.


Public Member Functions

 CField ()
 Constructor.
 CField (const CField &field)
 Copy constructor.
 CField (FID fid, const TCHAR *name, EnType fieldType, CFormat *format)
 Constructor.
 CField (FID fid, const TCHAR *name, CDataObject::pfnGetMfcString getMethod, CDataObject::pfnSetMfcString setMethod, CFormat *format, const TCHAR *getMethodName=0, const TCHAR *setMethodName=0)
 Constructor for the STL string-type field.
 CField (FID fid, const TCHAR *name, CDataObject::pfnGetStlString getMethod, CDataObject::pfnSetStlString setMethod, CFormat *format, const TCHAR *getMethodName=0, const TCHAR *setMethodName=0)
 Constructor for the STL string-type field.
 CField (FID fid, const TCHAR *name, CDataObject::pfnGetChar getMethod, CDataObject::pfnSetChar setMethod, CFormat *format, const TCHAR *getMethodName=0, const TCHAR *setMethodName=0)
 Constructor for the char-type field.
 CField (FID fid, const TCHAR *name, CDataObject::pfnGetUChar getMethod, CDataObject::pfnSetUChar setMethod, CFormat *format, const TCHAR *getMethodName=0, const TCHAR *setMethodName=0)
 Constructor for the unsigned char-type field.
 CField (FID fid, const TCHAR *name, CDataObject::pfnGetShort getMethod, CDataObject::pfnSetShort setMethod, CFormat *format, const TCHAR *getMethodName=0, const TCHAR *setMethodName=0)
 Constructor for the short-type field.
 CField (FID fid, const TCHAR *name, CDataObject::pfnGetUShort getMethod, CDataObject::pfnSetUShort setMethod, CFormat *format, const TCHAR *getMethodName=0, const TCHAR *setMethodName=0)
 Constructor for the unsigned short-type field.
 CField (FID fid, const TCHAR *name, CDataObject::pfnGetLong getMethod, CDataObject::pfnSetLong setMethod, CFormat *format, const TCHAR *getMethodName=0, const TCHAR *setMethodName=0)
 Constructor for the long-type field.
 CField (FID fid, const TCHAR *name, CDataObject::pfnGetULong getMethod, CDataObject::pfnSetULong setMethod, CFormat *format, const TCHAR *getMethodName=0, const TCHAR *setMethodName=0)
 Constructor for the unsigned short-type field.
 CField (FID fid, const TCHAR *name, CDataObject::pfnGetInt64 getMethod, CDataObject::pfnSetInt64 setMethod, CFormat *format, const TCHAR *getMethodName=0, const TCHAR *setMethodName=0)
 Constructor for the int64-type field.
 CField (FID fid, const TCHAR *name, CDataObject::pfnGetBool getMethod, CDataObject::pfnSetBool setMethod, CFormat *format, const TCHAR *getMethodName=0, const TCHAR *setMethodName=0)
 Constructor for the bool-type field.
 CField (FID fid, const TCHAR *name, CDataObject::pfnGetFloat getMethod, CDataObject::pfnSetFloat setMethod, CFormat *format, const TCHAR *getMethodName=0, const TCHAR *setMethodName=0)
 Constructor for the float-type field.
 CField (FID fid, const TCHAR *name, CDataObject::pfnGetDouble getMethod, CDataObject::pfnSetDouble setMethod, CFormat *format, const TCHAR *getMethodName=0, const TCHAR *setMethodName=0)
 Constructor for the double-type field.
 CField (FID fid, const TCHAR *name, CDataObject::pfnGetObjectPtr getMethod, CDataObject::pfnSetObjectPtr setMethod, CFormat *format, const TCHAR *getMethodName=0, const TCHAR *setMethodName=0)
 Constructor for the pointer to CDataObject - type field.
virtual ~CField ()
 Virtual destructor.
virtual CFieldClone () const
FID GetFid () const
 Gets a field identifier.
TString GetName () const
 Gets a field name.
EnType GetType () const
 Gets a field type.
CFormatGetFormat () const
 Gets a textual format.
TString GetPfnGetName () const
 Gets the name of Get-methos.
TString GetPfnSetName () const
 Gets the name of Set-methos.
bool HasGetMethod () const
 Returns the value, indicating whether the field contains Get-method.
bool HasSetMethod () const
 Returns the value, indicating whether the field contains Set-method.
CDataObject::pfnGetMfcString PfnGetMfcString () const
 Returns MFC string-type Get-method.
CDataObject::pfnGetStlString PfnGetStlString () const
 Returns STL string-type Get-method.
CDataObject::pfnGetChar PfnGetChar () const
 Returns char-type Get-method.
CDataObject::pfnGetUChar PfnGetUChar () const
 Returns unsigned char-type Get-method.
CDataObject::pfnGetShort PfnGetShort () const
 Returns short-type Get-method.
CDataObject::pfnGetUShort PfnGetUShort () const
 Returns unsigned short-type Get-method.
CDataObject::pfnGetLong PfnGetLong () const
 Returns long-type Get-method.
CDataObject::pfnGetULong PfnGetULong () const
 Returns unsigned long-type Get-method.
CDataObject::pfnGetInt64 PfnGetInt64 () const
 Returns __int64 type Get-method.
CDataObject::pfnGetBool PfnGetBool () const
 Returns bool-type Get-method.
CDataObject::pfnGetFloat PfnGetFloat () const
 Returns float-type Get-method.
CDataObject::pfnGetDouble PfnGetDouble () const
 Returns double-type Get-method.
CDataObject::pfnGetObjectPtr PfnGetObjectPtr () const
 Returns pointer to CDataObject type Get-method.
CDataObject::pfnSetMfcString PfnSetMfcString () const
 Returns MFC string-type Set-method.
CDataObject::pfnSetStlString PfnSetStlString () const
 Returns STL string-type Set-method.
CDataObject::pfnSetChar PfnSetChar () const
 Returns char-type Set-method.
CDataObject::pfnSetUChar PfnSetUChar () const
 Returns unsigned char-type Set-method.
CDataObject::pfnSetShort PfnSetShort () const
 Returns short-type Set-method.
CDataObject::pfnSetUShort PfnSetUShort () const
 Returns unsigned short-type Set-method.
CDataObject::pfnSetLong PfnSetLong () const
 Returns long-type Set-method.
CDataObject::pfnSetULong PfnSetULong () const
 Returns unsigned long-type Set-method.
CDataObject::pfnSetInt64 PfnSetInt64 () const
 Returns __int64 type Set-method.
CDataObject::pfnSetBool PfnSetBool () const
 Returns boolean-type Set-method.
CDataObject::pfnSetFloat PfnSetFloat () const
 Returns float-type Set-method.
CDataObject::pfnSetDouble PfnSetDouble () const
 Returns double-type Set-method.
CDataObject::pfnSetObjectPtr PfnSetObjectPtr () const
 Returns pointer to CDataObject type Set-method.

Detailed Description

Presets and describes a field in a class derived from CDataObject.

C++ doesn't provide language possibilities to describe properties like Visual Basic. This class is equivalent to a property in Visual Basic and includes:
1. Integer identifier that can't be equal to Common::allFields(-1) or Common::fieldNotSpecified(-2).
2. Field name
3. Pointer to Get- method of the class derived from CDataObject
4. Pointer to Set- method of the class derived from CDataObject
5. Pointer to CFormat object which converts the value returned by Get-method to a formatted string and vice versa.

The field can be either single-sided or double-sided, i.e. it can have either Get or Set methods separately or combined. Each field has its type that depends on the type of Set and Get methods. The field is also used by CDataObject to call the methods of the derived classes by its identifiers.

Life time of formats

The life time of the format is handled by this class. So, if the format, passed to the constructor is not zero, then it will be destroyed in the destructor of this class. Generally, for the static declarations the 'new' operator is used:
DF_BEGIN_FIELD_MAP(COrder)
    ...
    DF_DOUBLE_ID(FidUnitPrice,  "UnitPrice", &COrder::GetUnitPrice, 0, new CDoubleFormat(3, false, false, _T('$')))
    ...
DF_END_FIELD_MAP()

Nevertheless, if you want to handle the format yourself, you can clone it:

class CMyFormatCollection
{
    static Dapfor::Common::CFormat& GetSomeFormat();
    ...
};

//In the static declaration you can use something like this:
    DF_DOUBLE_ID(FidUnitPrice,  "UnitPrice", &COrder::GetUnitPrice, 0, CMyFormatCollection::GetSomeFormat().Clone())

Example:
Declaration of a C++ class that has to be inserted into the grid

Constructor & Destructor Documentation

CField (  ) 

Constructor.

See also:
Life time of formats

CField ( const CField field  ) 

Copy constructor.

Parameters:
[in] field Field to be copied. If there is a format, it will be cloned.
See also:
Life time of formats

CField ( FID  fid,
const TCHAR *  name,
EnType  fieldType,
CFormat format 
)

Constructor.

Parameters:
[in] fid Field identifier
[in] name Field name
[in] fieldType Field type
[in] format Textual format to convert unformatted value to a string and vice versa. If this parameter is not zero, then the destructor of this class will destroy it.
See also:
Life time of formats

CField ( FID  fid,
const TCHAR *  name,
CDataObject::pfnGetMfcString  getMethod,
CDataObject::pfnSetMfcString  setMethod,
CFormat format,
const TCHAR *  getMethodName = 0,
const TCHAR *  setMethodName = 0 
)

Constructor for the STL string-type field.

Parameters:
[in] fid Field identifier
[in] name Field name
[in] getMethod Pointer to Get-method in CDataObject. It may be zero.
[in] setMethod Pointer to Set-method in CDataObject. It may be zero.
[in] format Textual format to convert unformatted value to a string and vice versa. If this parameter is not zero, then the destructor of this class will destroy it.
[in] getMethodName Name of Get-method.
[in] setMethodName Name of Set-method.
See also:
Life time of formats

CField ( FID  fid,
const TCHAR *  name,
CDataObject::pfnGetStlString  getMethod,
CDataObject::pfnSetStlString  setMethod,
CFormat format,
const TCHAR *  getMethodName = 0,
const TCHAR *  setMethodName = 0 
)

Constructor for the STL string-type field.

Parameters:
[in] fid Field identifier
[in] name Field name
[in] getMethod Pointer to Get-method in CDataObject. It may be zero.
[in] setMethod Pointer to Set-method in CDataObject. It may be zero.
[in] format Textual format to convert unformatted value to a string and vice versa. If this parameter is not zero, then the destructor of this class will destroy it.
[in] getMethodName Name of Get-method.
[in] setMethodName Name of Set-method.
See also:
Life time of formats

CField ( FID  fid,
const TCHAR *  name,
CDataObject::pfnGetChar  getMethod,
CDataObject::pfnSetChar  setMethod,
CFormat format,
const TCHAR *  getMethodName = 0,
const TCHAR *  setMethodName = 0 
)

Constructor for the char-type field.

Parameters:
[in] fid Field identifier
[in] name Field name
[in] getMethod Pointer to Get-method in CDataObject. It may be zero.
[in] setMethod Pointer to Set-method in CDataObject. It may be zero.
[in] format Textual format to convert unformatted value to a string and vice versa. If this parameter is not zero, then the destructor of this class will destroy it.
[in] getMethodName Name of Get-method.
[in] setMethodName Name of Set-method.
See also:
Life time of formats

CField ( FID  fid,
const TCHAR *  name,
CDataObject::pfnGetUChar  getMethod,
CDataObject::pfnSetUChar  setMethod,
CFormat format,
const TCHAR *  getMethodName = 0,
const TCHAR *  setMethodName = 0 
)

Constructor for the unsigned char-type field.

Parameters:
[in] fid Field identifier
[in] name Field name
[in] getMethod Pointer to Get-method in CDataObject. It may be zero.
[in] setMethod Pointer to Set-method in CDataObject. It may be zero.
[in] format Textual format to convert unformatted value to a string and vice versa. If this parameter is not zero, then the destructor of this class will destroy it.
[in] getMethodName Name of Get-method.
[in] setMethodName Name of Set-method.
See also:
Life time of formats

CField ( FID  fid,
const TCHAR *  name,
CDataObject::pfnGetShort  getMethod,
CDataObject::pfnSetShort  setMethod,
CFormat format,
const TCHAR *  getMethodName = 0,
const TCHAR *  setMethodName = 0 
)

Constructor for the short-type field.

Parameters:
[in] fid Field identifier
[in] name Field name
[in] getMethod Pointer to Get-method in CDataObject. It may be zero.
[in] setMethod Pointer to Set-method in CDataObject. It may be zero.
[in] format Textual format to convert unformatted value to a string and vice versa. If this parameter is not zero, then the destructor of this class will destroy it.
[in] getMethodName Name of Get-method.
[in] setMethodName Name of Set-method.
See also:
Life time of formats

CField ( FID  fid,
const TCHAR *  name,
CDataObject::pfnGetUShort  getMethod,
CDataObject::pfnSetUShort  setMethod,
CFormat format,
const TCHAR *  getMethodName = 0,
const TCHAR *  setMethodName = 0 
)

Constructor for the unsigned short-type field.

Parameters:
[in] fid Field identifier
[in] name Field name
[in] getMethod Pointer to Get-method in CDataObject. It may be zero.
[in] setMethod Pointer to Set-method in CDataObject. It may be zero.
[in] format Textual format to convert unformatted value to a string and vice versa. If this parameter is not zero, then the destructor of this class will destroy it.
[in] getMethodName Name of Get-method.
[in] setMethodName Name of Set-method.
See also:
Life time of formats

CField ( FID  fid,
const TCHAR *  name,
CDataObject::pfnGetLong  getMethod,
CDataObject::pfnSetLong  setMethod,
CFormat format,
const TCHAR *  getMethodName = 0,
const TCHAR *  setMethodName = 0 
)

Constructor for the long-type field.

Parameters:
[in] fid Field identifier
[in] name Field name
[in] getMethod Pointer to Get-method in CDataObject. It may be zero.
[in] setMethod Pointer to Set-method in CDataObject. It may be zero.
[in] format Textual format to convert unformatted value to a string and vice versa. If this parameter is not zero, then the destructor of this class will destroy it.
[in] getMethodName Name of Get-method.
[in] setMethodName Name of Set-method.
See also:
Life time of formats

CField ( FID  fid,
const TCHAR *  name,
CDataObject::pfnGetULong  getMethod,
CDataObject::pfnSetULong  setMethod,
CFormat format,
const TCHAR *  getMethodName = 0,
const TCHAR *  setMethodName = 0 
)

Constructor for the unsigned short-type field.

Parameters:
[in] fid Field identifier
[in] name Field name
[in] getMethod Pointer to Get-method in CDataObject. It may be zero.
[in] setMethod Pointer to Set-method in CDataObject. It may be zero.
[in] format Textual format to convert unformatted value to a string and vice versa. If this parameter is not zero, then the destructor of this class will destroy it.
[in] getMethodName Name of Get-method.
[in] setMethodName Name of Set-method.
See also:
Life time of formats

CField ( FID  fid,
const TCHAR *  name,
CDataObject::pfnGetInt64  getMethod,
CDataObject::pfnSetInt64  setMethod,
CFormat format,
const TCHAR *  getMethodName = 0,
const TCHAR *  setMethodName = 0 
)

Constructor for the int64-type field.

Parameters:
[in] fid Field identifier
[in] name Field name
[in] getMethod Pointer to Get-method in CDataObject. It may be zero.
[in] setMethod Pointer to Set-method in CDataObject. It may be zero.
[in] format Textual format to convert unformatted value to a string and vice versa. If this parameter is not zero, then the destructor of this class will destroy it.
[in] getMethodName Name of Get-method.
[in] setMethodName Name of Set-method.
See also:
Life time of formats

CField ( FID  fid,
const TCHAR *  name,
CDataObject::pfnGetBool  getMethod,
CDataObject::pfnSetBool  setMethod,
CFormat format,
const TCHAR *  getMethodName = 0,
const TCHAR *  setMethodName = 0 
)

Constructor for the bool-type field.

Parameters:
[in] fid Field identifier
[in] name Field name
[in] getMethod Pointer to Get-method in CDataObject. It may be zero.
[in] setMethod Pointer to Set-method in CDataObject. It may be zero.
[in] format Textual format to convert unformatted value to a string and vice versa. If this parameter is not zero, then the destructor of this class will destroy it.
[in] getMethodName Name of Get-method.
[in] setMethodName Name of Set-method.
See also:
Life time of formats

CField ( FID  fid,
const TCHAR *  name,
CDataObject::pfnGetFloat  getMethod,
CDataObject::pfnSetFloat  setMethod,
CFormat format,
const TCHAR *  getMethodName = 0,
const TCHAR *  setMethodName = 0 
)

Constructor for the float-type field.

Parameters:
[in] fid Field identifier
[in] name Field name
[in] getMethod Pointer to Get-method in CDataObject. It may be zero.
[in] setMethod Pointer to Set-method in CDataObject. It may be zero.
[in] format Textual format to convert unformatted value to a string and vice versa. If this parameter is not zero, then the destructor of this class will destroy it.
[in] getMethodName Name of Get-method.
[in] setMethodName Name of Set-method.
See also:
Life time of formats

CField ( FID  fid,
const TCHAR *  name,
CDataObject::pfnGetDouble  getMethod,
CDataObject::pfnSetDouble  setMethod,
CFormat format,
const TCHAR *  getMethodName = 0,
const TCHAR *  setMethodName = 0 
)

Constructor for the double-type field.

Parameters:
[in] fid Field identifier
[in] name Field name
[in] getMethod Pointer to Get-method in CDataObject. It may be zero.
[in] setMethod Pointer to Set-method in CDataObject. It may be zero.
[in] format Textual format to convert unformatted value to a string and vice versa. If this parameter is not zero, then the destructor of this class will destroy it.
[in] getMethodName Name of Get-method.
[in] setMethodName Name of Set-method.
See also:
Life time of formats

CField ( FID  fid,
const TCHAR *  name,
CDataObject::pfnGetObjectPtr  getMethod,
CDataObject::pfnSetObjectPtr  setMethod,
CFormat format,
const TCHAR *  getMethodName = 0,
const TCHAR *  setMethodName = 0 
)

Constructor for the pointer to CDataObject - type field.

Parameters:
[in] fid Field identifier
[in] name Field name
[in] getMethod Pointer to Get-method in CDataObject. It may be zero.
[in] setMethod Pointer to Set-method in CDataObject. It may be zero.
[in] format Textual format to convert unformatted value to a string and vice versa. If this parameter is not zero, then the destructor of this class will destroy it.
[in] getMethodName Name of Get-method.
[in] setMethodName Name of Set-method.
See also:
Life time of formats

~CField (  )  [virtual]

Virtual destructor.

Frees all resources. Destroys the textual format if it exists.

See also:
Life time of formats


Member Function Documentation

CField * Clone (  )  const [virtual]

Returns:
Clone of the object.

TString GetName (  )  const

Gets a field name.

Returns:
Field name

TString GetPfnGetName (  )  const

Gets the name of Get-methos.

Returns:
Name of Get-method of CDataObject

TString GetPfnSetName (  )  const

Gets the name of Set-methos.

Returns:
Name of Set-method of CDataObject