![]() |
appkit
1.5.1
RoadNarrows Robotics Application Kit
|
Classes | |
| struct | AnimalInfo |
| struct | AppCmdExec |
| Command description and exectuion structure. More... | |
| struct | AppCmdExec3 |
| Self-Reference command description and exectuion structure. More... | |
Macros | |
| #define | APP_EC_OK 0 |
| success exit code | |
| #define | APP_EC_ARGS 2 |
| command-line options/arguments error exit code | |
| #define | APP_EC_EXEC 4 |
| execution exit code | |
Enumerations | |
| enum | Activity { ActIdle, ActSleeping, ActEating, ActWalking } |
| Animal activities. More... | |
Functions | |
| static ostream & | operator<< (ostream &os, const char *art[]) |
| ASCII art output stream operator. More... | |
| static void | showAsciiArt (ostream &os, const char *art0[], const char *art1[], const char *art2[]=NULL, const char *art3[]=NULL) |
| Write a set of ASCII art to cout. More... | |
| static AnimalInfo * | findAnimal (const string &strCommonName) |
| Find the animal with the common name. More... | |
| const string | CliName ("Adopt-An-Animal") |
| CLI name. | |
| const string | CliPrompt ("aaa> ") |
| CLI prompt. | |
Variables | |
| static char * | Argv0 |
| the command | |
| static OptsPgmInfo_T | PgmInfo |
| Program information. More... | |
| static OptsInfo_T | OptsInfo [] |
| Command line options information. More... | |
| static const char * | AsciiAardvark [] |
| ASCII ardvaark. More... | |
| static const char * | AsciiMandrill [] |
| ASCII Mandrill. More... | |
| static const char * | AsciiNumbat [] |
| ASCII numbat. More... | |
| static const char * | AsciiZebraSmall [] |
| ASCII small zebra. More... | |
| static const char * | AsciiZebra [] |
| ASCII zebra. More... | |
| static const char * | AsciiAnt [] |
| ASCII ant. More... | |
| static const char * | AsciiGrub [] |
| ASCII grub. More... | |
| static const char * | AsciiCarrot [] |
| ASCII carrot. More... | |
| static const char * | AsciiVitamins [] |
| ASCII bottle of vitamins. More... | |
| static const char * | AsciiWalking [][2] |
| ASCII walk sequence. More... | |
| const char * | AnimalInfo::m_sCommonName |
| command name | |
| const char * | AnimalInfo::m_sScientificName |
| scientific name | |
| const char ** | AnimalInfo::m_sSelfie |
| ASCII selfie. | |
| string | AnimalInfo::m_strGivenName |
| adopted given name by owner | |
| bool | AnimalInfo::m_bIsAdopted |
| is [not] adopted | |
| Activity | AnimalInfo::m_eActivity |
| current activity | |
| double | AnimalInfo::m_fActStart |
| activity start time | |
| double | AnimalInfo::m_fActDuration |
| activitiy uninterrupted duration | |
| const char * | NoName = "No given name" |
| 'no name' name | |
| AnimalInfo | Animals [] |
| The animals. More... | |
| size_t | NumOfAnimals = arraysize(Animals) |
| number of animals | |
| Time | ActivityTime |
| activity time | |
| CommandLine | Cli (CliName, CliPrompt) |
| the CLI | |
| CmdDesc | AppCmdExec::m_desc |
| command description and syntax specification | |
| CmdExec2Func | AppCmdExec::m_fnExec |
| command execution function | |
| CmdDesc | AppCmdExec3::m_desc |
| command description and syntax specification | |
| CmdExec3Func | AppCmdExec3::m_fnExec |
| command execution function | |
| AppCmdExec | Commands [] |
| The command descriptions. | |
| const size_t | NumOfCmds = arraysize(Commands) |
| Number of commands. | |
| static const char * | CliTestCmdName = "clitest" |
| AppCmdExec3 | Command3s [] |
| The command descriptions. More... | |
| const size_t | NumOfCmd3s = arraysize(Command3s) |
| Number of commands. | |
| int | checkCmd (const CmdExtArg &argv0, int argc, const string strTgtName="") |
| Check if command input is matched correctly with the command execution. More... | |
| static int | execAdopt (const CmdExtArgVec &argv) |
| Execute 'adopt' command. More... | |
| static int | execSleep (const CmdExtArgVec &argv) |
| Execute 'sleep' command. More... | |
| static int | execNameAnimal (const CmdExtArgVec &argv) |
| Execute 'name' command. More... | |
| static int | execNamaste (const CmdExtArgVec &argv) |
| Execute 'namaste' command. More... | |
| static int | execFeedAnimal (const CmdExtArgVec &argv) |
| Execute 'feed' command. More... | |
| static int | execWalkAnimal (const CmdExtArgVec &argv) |
| Execute 'walk' command. More... | |
| static int | execListAnimals (const CmdExtArgVec &argv) |
| Execute 'list' command. More... | |
| static int | execGetPetsState (const CmdExtArgVec &argv) |
| Execute 'get' command. More... | |
| static int | execReward (const CmdExtArgVec &argv) |
| Execute 'reward' command. More... | |
| static int | execSave (const CmdExtArgVec &argv) |
| Execute 'save' command. More... | |
| static int | findCommand (const std::string &strName) |
| Find command by name. More... | |
| static int | execTAdd (CommandLine &cli, const CmdExtArgVec &argv) |
| Execute clitest tadd subcommand. More... | |
| static int | execTBt (CommandLine &cli, const CmdExtArgVec &argv) |
| Execute clitest tbt subcommand. More... | |
| static int | execTCompile (CommandLine &cli, const CmdExtArgVec &argv) |
| Execute clitest tcompile subcommand. More... | |
| static int | execTDump (CommandLine &cli, const CmdExtArgVec &argv) |
| Execute clitest tdump subcommand. More... | |
| static int | execTKbhit (CommandLine &cli, const CmdExtArgVec &argv) |
| Execute clitest tkbhit subcommand. More... | |
| static int | execTPrint (CommandLine &cli, const CmdExtArgVec &argv) |
| Execute clitest tprint subcommand. More... | |
| static int | execTPush (CommandLine &cli, const CmdExtArgVec &argv) |
| Execute clitest tpush subcommand. More... | |
| static int | execTRemove (CommandLine &cli, const CmdExtArgVec &argv) |
| Execute clitest tremove subcommand. More... | |
| static int | execCliTest (CommandLine &cli, const CmdExtArgVec &argv) |
| Execute command-line interface methods command. More... | |
| static void | mainInit (int argc, char *argv[]) |
| Main initialization. More... | |
| static void | updateAnimals () |
| Update all animals' state data. | |
| static int | loadCommands (CommandLine &cli) |
| Load commands into command line. More... | |
| static int | run (CommandLine &cli) |
| Command line interface main loop. More... | |
| int | main (int argc, char *argv[]) |
| Main. More... | |
| #define | PERROR(_err) cout << CliName << ": " << "Error: " << _err << endl |
| Error and warning printing macros. | |
| #define | PWARN(_warn) cout << CliName << ": " << _warn << endl |
| #define | PCMDERROR(_cmd, _err) cout << CliName << ": " << _cmd << ": " << "Error: " << _err << endl |
| #define | PCMDWARN(_cmd, _warn) cout << CliName << ": " << _cmd << ": " << _warn << endl |
| enum Activity |
Animal activities.
| Enumerator | |
|---|---|
| ActIdle |
idle, doing nothing |
| ActSleeping |
sleeping |
| ActEating |
eating |
| ActWalking |
walking |
Definition at line 475 of file rnr_eg_cli.cxx.
| int checkCmd | ( | const CmdExtArg & | argv0, |
| int | argc, | ||
| const string | strTgtName = "" |
||
| ) |
Check if command input is matched correctly with the command execution.
| argv0 | Input argument 0. (Any extended argument actually works). |
| argc | Number of input arguments. |
| strTgtName | Expected target name of execution. |
Definition at line 592 of file rnr_eg_cli.cxx.
References rnr::cmd::CommandLine::at(), Cli, rnr::cmd::CommandLine::numOfRequiredArgs(), PERROR, and rnr::cmd::CmdExtArg::uid().
Referenced by execAdopt(), execCliTest(), execFeedAnimal(), execGetPetsState(), execNameAnimal(), execReward(), execSave(), execSleep(), and execWalkAnimal().
|
static |
Execute 'adopt' command.
| argv | Command line arguments. |
Definition at line 625 of file rnr_eg_cli.cxx.
References checkCmd(), findAnimal(), and AnimalInfo::m_bIsAdopted.
|
static |
Execute command-line interface methods command.
| cli | Command line interface. |
| argv | Command line arguments. |
Definition at line 1760 of file rnr_eg_cli.cxx.
References checkCmd(), execTAdd(), execTBt(), execTCompile(), execTDump(), execTKbhit(), execTPrint(), execTPush(), execTRemove(), and rnr::cmd::CommandLine::popPrompt().
|
static |
Execute 'feed' command.
| argv | Command line arguments. |
Definition at line 801 of file rnr_eg_cli.cxx.
References ActEating, AsciiAnt, AsciiCarrot, AsciiGrub, AsciiVitamins, checkCmd(), findAnimal(), AnimalInfo::m_bIsAdopted, AnimalInfo::m_eActivity, AnimalInfo::m_fActDuration, AnimalInfo::m_fActStart, AnimalInfo::m_sCommonName, AnimalInfo::m_sSelfie, rnr::chronos::Time::now(), and showAsciiArt().
|
static |
Execute 'get' command.
| argv | Command line arguments. |
Definition at line 989 of file rnr_eg_cli.cxx.
References ActEating, ActIdle, ActSleeping, ActWalking, checkCmd(), findAnimal(), AnimalInfo::m_bIsAdopted, AnimalInfo::m_eActivity, AnimalInfo::m_sCommonName, AnimalInfo::m_sScientificName, AnimalInfo::m_sSelfie, and AnimalInfo::m_strGivenName.
|
static |
Execute 'list' command.
| argv | Command line arguments. |
Definition at line 968 of file rnr_eg_cli.cxx.
References AnimalInfo::m_sCommonName, and NumOfAnimals.
|
static |
Execute 'namaste' command.
| argv | Command line arguments. |
Definition at line 785 of file rnr_eg_cli.cxx.
|
static |
Execute 'name' command.
| argv | Command line arguments. |
Definition at line 737 of file rnr_eg_cli.cxx.
References checkCmd(), findAnimal(), AnimalInfo::m_bIsAdopted, and AnimalInfo::m_strGivenName.
|
static |
Execute 'reward' command.
| argv | Command line arguments. |
Definition at line 1101 of file rnr_eg_cli.cxx.
References checkCmd(), findAnimal(), AnimalInfo::m_bIsAdopted, and AnimalInfo::m_sCommonName.
|
static |
Execute 'save' command.
| argv | Command line arguments. |
Definition at line 1215 of file rnr_eg_cli.cxx.
References checkCmd(), findAnimal(), AnimalInfo::m_sCommonName, and AnimalInfo::m_sSelfie.
|
static |
Execute 'sleep' command.
| argv | Command line arguments. |
Definition at line 672 of file rnr_eg_cli.cxx.
References ActSleeping, checkCmd(), findAnimal(), AnimalInfo::m_bIsAdopted, AnimalInfo::m_eActivity, AnimalInfo::m_fActDuration, AnimalInfo::m_fActStart, AnimalInfo::m_sCommonName, and rnr::chronos::Time::now().
|
static |
Execute clitest tadd subcommand.
Add a new command to interface.
| cli | Command line interface. |
| argv | Command line arguments. |
Definition at line 1449 of file rnr_eg_cli.cxx.
References rnr::cmd::CommandLine::addCommand(), rnr::cmd::CommandLine::compile(), findCommand(), rnr::cmd::CommandLine::getErrorStr(), rnr::cmd::CommandLine::hasCmd(), AppCmdExec::m_desc, AppCmdExec::m_fnExec, and rnr::cmd::NoUid.
Referenced by execCliTest().
|
static |
Execute clitest tbt subcommand.
Print interface attribute.
| cli | Command line interface. |
| argv | Command line arguments. |
Definition at line 1505 of file rnr_eg_cli.cxx.
References rnr::cmd::CommandLine::backtrace().
Referenced by execCliTest().
|
static |
Execute clitest tcompile subcommand.
(Re)compile the interface.
| cli | Command line interface. |
| argv | Command line arguments. |
Definition at line 1522 of file rnr_eg_cli.cxx.
References rnr::cmd::CommandLine::compile(), rnr::cmd::CommandLine::getErrorStr(), and rnr::cmd::CommandLine::numOfCmds().
Referenced by execCliTest().
|
static |
Execute clitest tdump subcommand.
Dump specified command or full command-line interface.
| cli | Command line interface. |
| argv | Command line arguments. |
Definition at line 1553 of file rnr_eg_cli.cxx.
References rnr::cmd::CommandLine::at(), and rnr::cmd::NoUid.
Referenced by execCliTest().
|
static |
Execute clitest tkbhit subcommand.
Loop to check non-blocking input.
| cli | Command line interface. |
| argv | Command line arguments. |
Definition at line 1596 of file rnr_eg_cli.cxx.
Referenced by execCliTest().
|
static |
Execute clitest tprint subcommand.
Print interface attribute.
| cli | Command line interface. |
| argv | Command line arguments. |
Definition at line 1639 of file rnr_eg_cli.cxx.
References rnr::cmd::CommandLine::getErrorStr(), rnr::cmd::CommandLine::getName(), rnr::cmd::CommandLine::getPrompt(), and rnr::cmd::CommandLine::numOfCmds().
Referenced by execCliTest().
|
static |
Execute clitest tpush subcommand.
Push new prompt.
| cli | Command line interface. |
| argv | Command line arguments. |
Definition at line 1686 of file rnr_eg_cli.cxx.
References rnr::cmd::CommandLine::pushPrompt().
Referenced by execCliTest().
|
static |
Execute clitest tremove subcommand.
Remove command from the interface.
| cli | Command line interface. |
| argv | Command line arguments. |
Definition at line 1717 of file rnr_eg_cli.cxx.
References rnr::cmd::CommandLine::at(), rnr::cmd::CommandLine::getErrorStr(), rnr::cmd::NoUid, and rnr::cmd::CommandLine::removeCommand().
Referenced by execCliTest().
|
static |
Execute 'walk' command.
| argv | Command line arguments. |
Definition at line 890 of file rnr_eg_cli.cxx.
References ActWalking, AsciiWalking, checkCmd(), findAnimal(), AnimalInfo::m_bIsAdopted, AnimalInfo::m_eActivity, AnimalInfo::m_fActDuration, AnimalInfo::m_fActStart, AnimalInfo::m_sCommonName, and rnr::chronos::Time::now().
|
static |
Find the animal with the common name.
| strCommonName | Common name. |
Definition at line 536 of file rnr_eg_cli.cxx.
References NumOfAnimals.
Referenced by execAdopt(), execFeedAnimal(), execGetPetsState(), execNameAnimal(), execReward(), execSave(), execSleep(), and execWalkAnimal().
|
static |
Find command by name.
| strName | Command to find. |
Definition at line 1420 of file rnr_eg_cli.cxx.
References NumOfCmds.
Referenced by execTAdd().
|
static |
Load commands into command line.
Loading involves adding all commands and then compiling.
| cli | Command line interface. |
Definition at line 1952 of file rnr_eg_cli.cxx.
References rnr::cmd::addons::addBtEnableCommand(), rnr::cmd::CommandLine::addCommand(), rnr::cmd::addons::addHelpCommand(), rnr::cmd::addons::addQuitCommand(), rnr::cmd::CommandLine::backtrace(), rnr::cmd::CommandLine::compile(), rnr::cmd::NoUid, NumOfCmd3s, NumOfCmds, and PERROR.
Referenced by main().
| int main | ( | int | argc, |
| char * | argv[] | ||
| ) |
Main.
| argc | Command-line argument count. |
| argv | Command-line argument list. |
Definition at line 2057 of file rnr_eg_cli.cxx.
References APP_EC_EXEC, APP_EC_OK, AsciiAardvark, Cli, CliName(), loadCommands(), mainInit(), PERROR, and run().
|
static |
Main initialization.
| argc | Command-line argument count. |
| argv | Command-line argument list. |
Definition at line 1909 of file rnr_eg_cli.cxx.
References Argv0, OptsInfo, PgmInfo, and PkgInfo.
Referenced by main().
|
static |
ASCII art output stream operator.
| os | Output stream. |
| art | Art to insert. |
Definition at line 367 of file rnr_eg_cli.cxx.
|
static |
Command line interface main loop.
| cli | Command line interface. |
Definition at line 2012 of file rnr_eg_cli.cxx.
References rnr::cmd::CommandLine::addToHistory(), rnr::cmd::CommandLine::execute(), rnr::cmd::CommandLine::ok(), PERROR, rnr::cmd::CommandLine::readCommand(), and updateAnimals().
Referenced by main().
|
static |
Write a set of ASCII art to cout.
The art written left to right, bottom justified.
| os | Output stream. |
| art0 | Required art 0. |
| art1 | Required art 1. |
| art2 | Optional art 2. |
| art3 | Optional art 3. |
Definition at line 387 of file rnr_eg_cli.cxx.
Referenced by execFeedAnimal().
| AnimalInfo Animals[] |
|
static |
ASCII ardvaark.
Definition at line 125 of file rnr_eg_cli.cxx.
Referenced by main().
|
static |
ASCII ant.
Definition at line 260 of file rnr_eg_cli.cxx.
Referenced by execFeedAnimal().
|
static |
ASCII carrot.
Definition at line 298 of file rnr_eg_cli.cxx.
Referenced by execFeedAnimal().
|
static |
ASCII grub.
Definition at line 273 of file rnr_eg_cli.cxx.
Referenced by execFeedAnimal().
|
static |
ASCII Mandrill.
Definition at line 151 of file rnr_eg_cli.cxx.
|
static |
ASCII numbat.
Definition at line 178 of file rnr_eg_cli.cxx.
|
static |
ASCII bottle of vitamins.
Definition at line 325 of file rnr_eg_cli.cxx.
Referenced by execFeedAnimal().
|
static |
ASCII walk sequence.
Definition at line 351 of file rnr_eg_cli.cxx.
Referenced by execWalkAnimal().
|
static |
ASCII zebra.
Definition at line 226 of file rnr_eg_cli.cxx.
|
static |
ASCII small zebra.
Definition at line 213 of file rnr_eg_cli.cxx.
| AppCmdExec3 Command3s[] |
The command descriptions.
Definition at line 1865 of file rnr_eg_cli.cxx.
|
static |
Command line options information.
Definition at line 100 of file rnr_eg_cli.cxx.
Referenced by mainInit().
|
static |
Program information.
Definition at line 81 of file rnr_eg_cli.cxx.
Referenced by mainInit().