pflib v2.7.0-1-gd371ab6a
Polarfire Interaction Library
|
A command in the menu. More...
Public Member Functions | |
Line (const char *n, const char *d, SingleTargetCommand f) | |
define a menu line that uses a single target command | |
Line (const char *n, const char *d, MultipleTargetCommands f) | |
define a menu line that uses a multiple command function | |
Line (const char *n, const char *d, Menu *m) | |
define a menu line that enters a sub menu | |
Line (const char *n, const char *d) | |
define an empty menu line with only a name and description More... | |
Line (Line &&l) noexcept | |
noexcept move constructor allows std::vector to use it when expanding capacity | |
Line (const Line &l)=default | |
bool | execute (TargetHandle p) const |
Execute this line. More... | |
bool | empty () const |
Check if this line is an empty one. | |
void | render () |
add an exit line if this is a menu, otherwise do nothing | |
const char * | name () const |
name of this line to select it | |
const char * | desc () const |
short description to print with menu | |
Private Attributes | |
const char * | name_ |
the name of this line | |
const char * | desc_ |
short description for what this line is | |
Menu * | sub_menu_ |
pointer to sub menu (if it exists) | |
SingleTargetCommand | cmd_ |
function pointer to execute (if exists) | |
MultipleTargetCommands | mult_cmds_ |
function handling multiple commands to execute (if exists) | |
Friends | |
std::ostream & | operator<< (std::ostream &s, const Line &l) |
A command in the menu.
A menu command can do one of two tasks:
There are two ways to execute a command on the target, the user can provide a function that only does one command on the target (the function signature is SingleTargetCommand) or the user can provide a function that can do multiple commands on a target (the function signature is MultipleTargetCommands) where the first argument to that function will be the name of that Line.
|
inline |
define an empty menu line with only a name and description
empty lines are used to exit menus because they will do nothing when execute is called and will leave the do-while loop in Menu::steer
|
inline |
Execute this line.
If this line is a sub-menu, we give the target to that menu's steer function. Otherwise, we execute the function that is available for this line, perferring the single target command.
[in] | p | pointer to target |