Classes | Public Member Functions | Private Attributes | List of all members
PropertyMapper< T > Class Template Reference

Helper class to map a property name to a handler member function. More...

Classes

struct  PropertyFunc
 
struct  PropertyFuncIntf
 

Public Member Functions

 PropertyMapper ()
 
void addProperty (const char *name, typename PropertyFunc::Handler handle)
 
TemplateVariant get (const T *obj, const char *name) const
 

Private Attributes

QDict< PropertyFuncIntfm_map
 

Detailed Description

template<typename T>
class PropertyMapper< T >

Helper class to map a property name to a handler member function.

Definition at line 225 of file context.cpp.

Constructor & Destructor Documentation

template<typename T>
PropertyMapper< T >::PropertyMapper ( )
inline

Definition at line 245 of file context.cpp.

245 : m_map(63) { m_map.setAutoDelete(TRUE); }
QDict< PropertyFuncIntf > m_map
Definition: context.cpp:282
const bool TRUE
Definition: qglobal.h:371

Member Function Documentation

template<typename T>
void PropertyMapper< T >::addProperty ( const char *  name,
typename PropertyFunc::Handler  handle 
)
inline

Add a property to the map

Parameters
[in]nameThe name of the property to add.
[in]objThe object handling access to the property.
[in]handleThe method to call when the property is accessed.

Definition at line 252 of file context.cpp.

253  {
254  if (m_map.find(name))
255  {
256  err("Error: adding property '%s' more than once",name);
257  }
258  else
259  {
260  m_map.insert(name,new PropertyFunc(handle));
261  }
262  }
static QCString name
Definition: declinfo.cpp:673
QDict< PropertyFuncIntf > m_map
Definition: context.cpp:282
void err(const char *fmt,...)
Definition: message.cpp:226
template<typename T>
TemplateVariant PropertyMapper< T >::get ( const T *  obj,
const char *  name 
) const
inline

Gets the value of a property.

Parameters
[in]nameThe name of the property.
Returns
A variant representing the properties value or an invalid variant if it was not found.

Definition at line 269 of file context.cpp.

270  {
271  //printf("PropertyMapper::get(%s)\n",name);
273  PropertyFuncIntf *func = m_map.find(name);
274  if (func)
275  {
276  result = (*func)(obj);
277  }
278  return result;
279  }
static QCString name
Definition: declinfo.cpp:673
static QCString result
QDict< PropertyFuncIntf > m_map
Definition: context.cpp:282
Variant type which can hold one value of a fixed set of types.
Definition: template.h:90
def func()
Definition: docstring.py:7

Member Data Documentation

template<typename T>
QDict<PropertyFuncIntf> PropertyMapper< T >::m_map
private

Definition at line 282 of file context.cpp.


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