My Project
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Public Types | Public Member Functions | Static Public Member Functions | Static Private Member Functions | Private Attributes | List of all members
TemplateVariant::Delegate Class Reference

Helper class to create a delegate that can store a function/method call. More...

#include <template.h>

Public Types

typedef TemplateVariant(* StubType )(const void *obj, const QValueList< TemplateVariant > &args)
 

Public Member Functions

 Delegate ()
 
TemplateVariant operator() (const QValueList< TemplateVariant > &args) const
 

Static Public Member Functions

template<class T , TemplateVariant(T::*)(const QValueList< TemplateVariant > &) const TMethod>
static Delegate fromMethod (const T *objectPtr)
 
static Delegate fromFunction (const void *obj, StubType func)
 

Static Private Member Functions

template<class T , TemplateVariant(T::*)(const QValueList< TemplateVariant > &) const TMethod>
static TemplateVariant methodStub (const void *objectPtr, const QValueList< TemplateVariant > &args)
 

Private Attributes

const void * m_objectPtr
 
StubType m_stubPtr
 

Detailed Description

Helper class to create a delegate that can store a function/method call.

Definition at line 94 of file template.h.

Member Typedef Documentation

typedef TemplateVariant(* TemplateVariant::Delegate::StubType)(const void *obj, const QValueList< TemplateVariant > &args)

Callback type to use when creating a delegate from a function.

Definition at line 98 of file template.h.

Constructor & Destructor Documentation

TemplateVariant::Delegate::Delegate ( )
inline

Definition at line 100 of file template.h.

: m_objectPtr(0) , m_stubPtr(0) {}

Member Function Documentation

static Delegate TemplateVariant::Delegate::fromFunction ( const void *  obj,
StubType  func 
)
inlinestatic

Creates a delegate given an object, and a plain function.

Definition at line 112 of file template.h.

References m_objectPtr, and m_stubPtr.

Referenced by TemplateContextImpl::addIndexEntry(), and TemplateNodeTree::renderChildren().

{
d.m_objectPtr = obj;
d.m_stubPtr = func;
return d;
}
template<class T , TemplateVariant(T::*)(const QValueList< TemplateVariant > &) const TMethod>
static Delegate TemplateVariant::Delegate::fromMethod ( const T *  objectPtr)
inlinestatic

Creates a delegate given an object. The method to call is passed as a template parameter

Definition at line 104 of file template.h.

References m_objectPtr, and m_stubPtr.

{
d.m_objectPtr = objectPtr;
d.m_stubPtr = &methodStub<T, TMethod>;
return d;
}
template<class T , TemplateVariant(T::*)(const QValueList< TemplateVariant > &) const TMethod>
static TemplateVariant TemplateVariant::Delegate::methodStub ( const void *  objectPtr,
const QValueList< TemplateVariant > &  args 
)
inlinestaticprivate

Definition at line 131 of file template.h.

{
T* p = (T*)(objectPtr);
return (p->*TMethod)(args);
}
TemplateVariant TemplateVariant::Delegate::operator() ( const QValueList< TemplateVariant > &  args) const
inline

Invokes the function/method stored in the delegate

Definition at line 121 of file template.h.

References m_objectPtr, and m_stubPtr.

{
return (*m_stubPtr)(m_objectPtr, args);
}

Member Data Documentation

const void* TemplateVariant::Delegate::m_objectPtr
private

Definition at line 127 of file template.h.

Referenced by fromFunction(), fromMethod(), and operator()().

StubType TemplateVariant::Delegate::m_stubPtr
private

Definition at line 128 of file template.h.

Referenced by fromFunction(), fromMethod(), and operator()().


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