cxWidgets 1.0
Public Member Functions | List of all members
cx::cxFunction2 Class Reference

A more intelligent function pointer, which can run a function with. More...

#include <cxFunction.h>

Inheritance diagram for cx::cxFunction2:
Inheritance graph
Collaboration diagram for cx::cxFunction2:
Collaboration graph

Public Member Functions

 cxFunction2 (funcPtr2 pFuncPtr=nullptr, void *pParam1=nullptr, void *pParam2=nullptr, bool pUseReturnVal=false, bool pExitAfterRun=false, bool pRunOnLeaveFunction=true)
 Default constructor. All parameters have default values.
 
virtual ~cxFunction2 ()
 
virtual bool functionIsSet () const override
 
void setFunction (funcPtr2 pFuncPtr)
 
funcPtr2 getFunction () const
 Accessor for the internal function pointer.
 
void setParams (void *pParam1, void *pParam2)
 
void setParam1 (void *pParam)
 
void setParam2 (void *pParam)
 
void * getParam1 () const
 
void * getParam2 () const
 
virtual std::string runFunction () const override
 
virtual void * getFuncPtr () const override
 
virtual std::string cxTypeStr () const override
 Returns the name of the cxWidgets class, "cxFunction2". This can be.
 
- Public Member Functions inherited from cx::cxFunction
 cxFunction (bool pUseReturnVal, bool pExitAfterRun, bool pRunOnLeaveFunction)
 Constructor.
 
virtual ~cxFunction ()
 
virtual bool getUseReturnVal () const
 Accessor for whether the caller should use the return value.
 
virtual void setUseReturnVal (bool pUseReturnVal)
 Setter for whether or not the caller should make use of the return value.
 
virtual bool getExitAfterRun () const
 Accessor for whether the caller should exit after the function.
 
virtual void setExitAfterRun (bool pExitAfterRun)
 Setter for whether or not the caller should quit what.
 
virtual bool getRunOnLeaveFunction () const
 Accessor for whether the caller should run its onLeave function.
 
virtual void setRunOnLeaveFunction (bool pRunOnLeaveFunction)
 Setter for whether or not the caller should run its.
 

Detailed Description

A more intelligent function pointer, which can run a function with.

2 parameters. This is used for running external code for an event

(such as a keypress, etc.). This class also stores whether the

function's return value should be used. Note that the function must

have the following signature:

string func(void*, void*)
The parameters are void pointers because it can't be known by this class what types of objects your functions will need. This class lets you set the function pointer, a boolean to signify whether the caller should make use of the return value, and also set the parameters to be passed to the function. This class was originally intended for use with cxInput and cxMultiLineInput, so this class also has a boolean to specify whether the input should exit its input upon exit of the function.

Constructor & Destructor Documentation

◆ cxFunction2()

cx::cxFunction2::cxFunction2 ( funcPtr2  pFuncPtr = nullptr,
void *  pParam1 = nullptr,
void *  pParam2 = nullptr,
bool  pUseReturnVal = false,
bool  pExitAfterRun = false,
bool  pRunOnLeaveFunction = true 
)
explicit

Default constructor. All parameters have default values.

available. Note that function must have this signature:

string func(void*, void*)

Parameters
pFuncPtrPointer to the function to be run. Defaults to nullptr.
pParam1The first parameter to pass to the function when it's run - This is a void pointer.
pParam2The second parameter to pass to the function when it's run - This is a void pointer.
pUseReturnValIndicates whether caller will make use of return value. Defaults to false
pExitAfterRunWhether or not the caller should exit from its input loop once the function is done. Defaults to false.
pRunOnLeaveFunctionWhether or not the caller should run its onLeave function when it exits (useful if pExitAfterRun is true). This defaults to true.

◆ ~cxFunction2()

cx::cxFunction2::~cxFunction2 ( )
virtual

Destructor

Member Function Documentation

◆ cxTypeStr()

string cx::cxFunction2::cxTypeStr ( ) const
overridevirtual

Returns the name of the cxWidgets class, "cxFunction2". This can be.

used to determine the type of cxWidgets object that deriving

classes derive from in applications.

Returns
The name of the cxWidgets class ("cxFunction2").

Implements cx::cxFunction.

◆ functionIsSet()

bool cx::cxFunction2::functionIsSet ( ) const
overridevirtual

Returns whether the internal funtion pointer is set.

Returns
Returns true if the internal function pointer is set (not null), or false otherwise.

Implements cx::cxFunction.

◆ getFuncPtr()

void * cx::cxFunction2::getFuncPtr ( ) const
overridevirtual

Implements cx::cxFunction.

◆ getFunction()

funcPtr2 cx::cxFunction2::getFunction ( ) const

Accessor for the internal function pointer.

Returns
The internal function pointer

Referenced by cx::cxMultiLineInput::usingBuiltInOnKeyFunction(), and cx::cxMultiLineInput::usingBuiltInValidator().

◆ getParam1()

void * cx::cxFunction2::getParam1 ( ) const

Accessor for the first function parameter

Returns
Returns pointer to first parameter

◆ getParam2()

void * cx::cxFunction2::getParam2 ( ) const

Accessor for the second function pointer

Returns
Returns pointer to second parameter

◆ runFunction()

string cx::cxFunction2::runFunction ( ) const
overridevirtual

If function pointer is not null, runs the function and returns its return value; If function pointer is nullptr, returns empty string

Returns
Returns return value of function pointed to if pointer is not null, otherwise returns empty string

Implements cx::cxFunction.

◆ setFunction()

void cx::cxFunction2::setFunction ( funcPtr2  pFuncPtr)

Sets the internal function pointer

Parameters
pFuncPtrThe function to which to point

◆ setParam1()

void cx::cxFunction2::setParam1 ( void *  pParam)

Sets the first parameter

Parameters
pParamFirst parameter to pass to function

◆ setParam2()

void cx::cxFunction2::setParam2 ( void *  pParam)

Sets the second parameter

Parameters
pParamSecond parameter to pass to function

◆ setParams()

void cx::cxFunction2::setParams ( void *  pParam1,
void *  pParam2 
)

Sets the parameters to pass to the function.

Parameters
pParam1First parameter to pass to function
pParam2Second parameter to pass to function

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