Classes | Public Member Functions

Barry::FieldHandle< RecordT > Class Template Reference
[GenericFieldHandles]

This is a template class that handles pointers to members of multiple types of data and multiple types of records. More...

#include <record.h>

Collaboration diagram for Barry::FieldHandle< RecordT >:
Collaboration graph
[legend]

List of all members.

Classes

union  PointerUnion
struct  PostalPointer

Public Member Functions

const FieldIdentityGetIdentity () const
 Extracts FieldIdentity object from FieldHandle<>
void Value (const FieldValueHandlerBase &vh, const RecordT &rec) const
 Calls the matching virtual function in FieldValueHandlerBase, passing in the value of the field that this FieldHandle<> refers to, and a referenct to the FieldIdentity object.
template<class CallbackT >
void Member (const CallbackT &func) const
 Calls the callback functor with two arguments: the pointer to member that this FieldHandle<> contains, and the FieldIdentity object.

Detailed Description

template<class RecordT>
class Barry::FieldHandle< RecordT >

This is a template class that handles pointers to members of multiple types of data and multiple types of records.

This class contains a union of all known data pointers in all records. Therefore this class can hold a pointer to member of any record class.

To do something with the field that this FieldHandle<> class refers to, call either Value() or Member() with appropriate callback functors. Value will pass a reference to the field. You can use an object derived from FieldValueHandlerBase here. Member() will pass a pointer to member. Your functor will need to contain the record data in order to access its data via the pointer to member.

The template functor callback that you pass into member must be capable of this:

   	template <class RecordT>
   	struct Callback
   	{
   		RecordT m_rec;
   		void operator()(typename FieldHandle<RecordT>::PostalPointer pp,
   			const FieldIdentity &id) const
   		{
   			PostalAddress pa = m_rec.*(pp.m_PostalAddress);
   			std::string val = pa.*(pp.m_PostalField);
   			...
   		}
   		template <class TypeT>
   		void operator()(TypeT RecordT::* mp,
   				const FieldIdentity &id) const
   		{
   			TypeT val = m_rec.*mp;
   			...
   		}
   	};
    

You don't have to use a TypeT template, but if you don't, then you must support all field types that the record class you're processing uses.

Definition at line 846 of file record.h.


Member Function Documentation

template<class RecordT>
const FieldIdentity& Barry::FieldHandle< RecordT >::GetIdentity (  )  const [inline]

Extracts FieldIdentity object from FieldHandle<>

Definition at line 1053 of file record.h.

template<class RecordT>
template<class CallbackT >
void Barry::FieldHandle< RecordT >::Member ( const CallbackT &  func  )  const [inline]

Calls the callback functor with two arguments: the pointer to member that this FieldHandle<> contains, and the FieldIdentity object.

It is assumed that the functor will either contain or know where to find one or more records of type RecordT.

Definition at line 1124 of file record.h.

template<class RecordT>
void Barry::FieldHandle< RecordT >::Value ( const FieldValueHandlerBase vh,
const RecordT &  rec 
) const [inline]

Calls the matching virtual function in FieldValueHandlerBase, passing in the value of the field that this FieldHandle<> refers to, and a referenct to the FieldIdentity object.

Caller must pass in a RecordT object as well.

Definition at line 1059 of file record.h.

Referenced by Barry::ForEachFieldValue().

Here is the caller graph for this function:


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