Critical Link MityCam SoC Firmware  1.0
Critical Link MityCam SoC Firmware
tcCommandExecutiveBase Class Reference

#include <tcCommandExecutiveBase.h>

Inheritance diagram for tcCommandExecutiveBase:
Collaboration diagram for tcCommandExecutiveBase:

Classes

struct  tsCmndFunc
 

Public Member Functions

 tcCommandExecutiveBase (const char *appname)
 Constructor, Create an input thread and then populate the menu and the help menu. More...
 
void start ()
 

Protected Types

typedef void(* tpVoidFunc) (void *)
 

Protected Member Functions

void add_cmnd (const char *cmnd, tpVoidFunc func, const char *desc)
 
void add_seperator ()
 
 MENU_FUNCTION_DECL (process_help)
 
void conditionalRead (unsigned int anTabs, const char *apMessage)
 
bool ask_on_off (const char *prompt, bool allowempty=false, bool dflt=false)
 Generic "on/off" asker. More...
 
bool ask_yes_no (const char *prompt, bool allowempty=false, bool dflt=false)
 Generic "yes/no" asker. More...
 
double ask_double (const char *prompt, bool allowempty=false, double dflt=0)
 
float ask_float (const char *prompt, bool allowempty=false, float dflt=0)
 
uint32_t ask_uint (const char *prompt, bool allowempty=false, uint32_t dflt=0)
 
int32_t ask_int (const char *prompt, bool allowempty=false, int32_t dflt=0)
 
std::string ask_string (const char *prompt, bool allowempty=false, const char *dflt="")
 
void ReadUserInput ()
 
void UserInputLoop ()
 
tpVoidFunc get_func (const char *cmnd)
 
tsCmndFuncget_cmndfunc (const char *cmnd)
 
void printHelp (const char *cmnd)
 Prints either a single command, all commands, or an error, depending on the help string. More...
 
void printHelpGeneric (const tsCmndFunc *tcf) const
 Prints generic formatted help for the specfied command and info. More...
 
void printHelpAll () const
 

Protected Attributes

std::vector< tsCmndFuncm_cmnd_func_list
 
tcUIThreadm_ConsoleListenerThread
 Thread handle for User Input. More...
 
bool m_continue
 Tells the UI thread when QUIT command has been given. More...
 
std::list< std::string > m_cmnd_list
 
std::string m_appname
 

Friends

class tcUIThread
 

Detailed Description

This class forms the basis of ARM input operations, allowing the programmer to easily write a generic set of commands which will be performed as guided by a parent tpVoidFunc container method. By initializing the command map to translate the desired command into this function call, the new parent tpVoidFunc will automatically be called within the input thread when the user types the corresponding command. Please note that this map will NOT automatically generate the Help Menu in any way, and therefore the programmer must add the command and its description to the corresponding HelpMap. As a final note, to those unfamiliar with the standard map: this is a tree-based container, and string comparisons are based on an integral translation of each string. In other words, COMMAND differs from command, and again, this must be considered in both this and the help map.

Member Typedef Documentation

◆ tpVoidFunc

typedef void(* tcCommandExecutiveBase::tpVoidFunc) (void *)
protected

Function pointer to be used within the command map and executed by each command

Constructor & Destructor Documentation

◆ tcCommandExecutiveBase()

tcCommandExecutiveBase::tcCommandExecutiveBase ( const char *  appname)

Constructor, Create an input thread and then populate the menu and the help menu.

Member Function Documentation

◆ add_cmnd()

void tcCommandExecutiveBase::add_cmnd ( const char *  cmnd,
tpVoidFunc  func,
const char *  desc 
)
protected

Create the command map by corresponding all lower case strings with function pointers to be executed when these strings are entered Major program controls for help and general control Also pass help info off to the help object.

◆ add_seperator()

void tcCommandExecutiveBase::add_seperator ( )
protected

◆ ask_double()

double tcCommandExecutiveBase::ask_double ( const char *  prompt,
bool  allowempty = false,
double  dflt = 0 
)
protected

◆ ask_float()

float tcCommandExecutiveBase::ask_float ( const char *  prompt,
bool  allowempty = false,
float  dflt = 0 
)
protected

◆ ask_int()

int32_t tcCommandExecutiveBase::ask_int ( const char *  prompt,
bool  allowempty = false,
int32_t  dflt = 0 
)
protected

◆ ask_on_off()

bool tcCommandExecutiveBase::ask_on_off ( const char *  prompt,
bool  allowempty = false,
bool  dflt = false 
)
protected

Generic "on/off" asker.

◆ ask_string()

std::string tcCommandExecutiveBase::ask_string ( const char *  prompt,
bool  allowempty = false,
const char *  dflt = "" 
)
protected

◆ ask_uint()

uint32_t tcCommandExecutiveBase::ask_uint ( const char *  prompt,
bool  allowempty = false,
uint32_t  dflt = 0 
)
protected

◆ ask_yes_no()

bool tcCommandExecutiveBase::ask_yes_no ( const char *  prompt,
bool  allowempty = false,
bool  dflt = false 
)
protected

Generic "yes/no" asker.

◆ conditionalRead()

void tcCommandExecutiveBase::conditionalRead ( unsigned int  anTabs,
const char *  apMessage 
)
protected

◆ get_cmndfunc()

tcCommandExecutiveBase::tsCmndFunc * tcCommandExecutiveBase::get_cmndfunc ( const char *  cmnd)
protected

◆ get_func()

tcCommandExecutiveBase::tpVoidFunc tcCommandExecutiveBase::get_func ( const char *  cmnd)
protected

◆ MENU_FUNCTION_DECL()

tcCommandExecutiveBase::MENU_FUNCTION_DECL ( process_help  )
protected

◆ printHelp()

void tcCommandExecutiveBase::printHelp ( const char *  cmnd)
protected

Prints either a single command, all commands, or an error, depending on the help string.

◆ printHelpAll()

void tcCommandExecutiveBase::printHelpAll ( ) const
protected

Prints out a help summary of all the commands available. Iterates through the map and prints all COMMAND help items

◆ printHelpGeneric()

void tcCommandExecutiveBase::printHelpGeneric ( const tsCmndFunc tcf) const
protected

Prints generic formatted help for the specfied command and info.

◆ ReadUserInput()

void tcCommandExecutiveBase::ReadUserInput ( )
protected

◆ start()

void tcCommandExecutiveBase::start ( )

Starts the UI thread, which will simply take user input and perform some operation given a user command (if it is found within the command map)

This function starts up the command executive iff it has not already been started. A thread is created and launched to monitor user input through stdin.

◆ UserInputLoop()

void tcCommandExecutiveBase::UserInputLoop ( )
protected

Runs a loop which accepts user input, and when that input is received, the appropriate method is called using the command map

Friends And Related Function Documentation

◆ tcUIThread

friend class tcUIThread
friend

Member Data Documentation

◆ m_appname

std::string tcCommandExecutiveBase::m_appname
protected

◆ m_cmnd_func_list

std::vector<tsCmndFunc> tcCommandExecutiveBase::m_cmnd_func_list
protected

◆ m_cmnd_list

std::list<std::string> tcCommandExecutiveBase::m_cmnd_list
protected

◆ m_ConsoleListenerThread

tcUIThread* tcCommandExecutiveBase::m_ConsoleListenerThread
protected

Thread handle for User Input.

◆ m_continue

bool tcCommandExecutiveBase::m_continue
protected

Tells the UI thread when QUIT command has been given.


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