Code: Select all
http://www.ogre3d.org/tikiwiki/tiki-index.php?page=ConsoleCode&structure=Cookbook
specifically this part
Code: Select all
enum ConsoleItemType
{
CTYPE_UCHAR, CTYPE_CHAR,
CTYPE_UINT, CTYPE_INT,
CTYPE_FLOAT, CTYPE_STRING,
CTYPE_FUNCTION, CTYPE_APPSTATEFUNCTION
};
typedef void (*ConsoleFunction)(const std::vector<std::string> &);
typedef struct {
std::string name;
ConsoleItemType type;
union
{
ConsoleFunction function;
void *variablePtr;
};
} ConsoleItem;
Code: Select all
case CTYPE_FUNCTION:
(*iter).function(arguments);
return true;
break;
what if I wanted to use a non-static member function pointer?
like accessing a various interface-purposed public member functions that modifies private data ?
for example, if i designed the framework with different states : menu, pause, action, each with different scenemanager and UI elements
and I want to be able to modify settings at run time ?
I tried using "friend" on static functions, but it requires function to be declared to take object references, which wont work with the
Code: Select all
typedef void (*ConsoleFunction)(const std::vector<std::string> &);
and I tried making a custom class function pointer, which wouldn't work, because I used a framework which encapsulated states manager quite well. (there's no interface to getsingleton() that can be used by static function)
Hope i dont make it frustratingly painful to understand

Any thoughts ?