My Project
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
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.

: m_map(63) { m_map.setAutoDelete(TRUE); }

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.

Referenced by DefinitionContext< FileContext::Private >::addBaseProperties().

{
if (m_map.find(name))
{
err("Error: adding property '%s' more than once",name);
}
else
{
m_map.insert(name,new PropertyFunc(handle));
}
}
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.

{
//printf("PropertyMapper::get(%s)\n",name);
PropertyFuncIntf *func = m_map.find(name);
if (func)
{
result = (*func)(obj);
}
return result;
}

Member Data Documentation

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

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