Dobby 3.0
Dobby “Docker based Thingy” is a tool for managing and running OCI containers using crun
Loading...
Searching...
No Matches
Classes | Public Member Functions | Static Public Member Functions | Private Types | Private Member Functions | Static Private Member Functions | Private Attributes | Static Private Attributes | List of all members
ReadLine Class Reference
Inheritance diagram for ReadLine:
Inheritance graph
[legend]
Collaboration diagram for ReadLine:
Collaboration graph
[legend]

Classes

struct  _ReadLineCommand
 

Public Member Functions

bool isValid () const override
 Tests if the class is valid.
 
void run () override
 Run loop, blocks until quit is called.
 
bool addCommand (const std::string &name, CommandHandler handler, const std::string &desc, const std::string &help, const std::string &opts) override
 Adds a new command to the readline loop.
 
void runCommand (int argc, char *const *argv) override
 
void process (const std::shared_ptr< AICommon::IPollLoop > &pollLoop, epoll_event event) override
 Callback from the PollLoop that is listening on stdin.
 
std::shared_ptr< const IReadLineContextgetContext () const override
 Returns the print context.
 
void quit () const override
 Triggers an exit from the readline loop.
 
void printLn (const char *fmt,...) const override
 Prints out the message from the command handler.
 
void printLnError (const char *fmt,...) const override
 Prints out an error message from the command handler.
 

Static Public Member Functions

static std::shared_ptr< ReadLineinstance ()
 
- Static Public Member Functions inherited from IReadLine
static std::shared_ptr< IReadLinecreate ()
 

Private Types

typedef struct ReadLine::_ReadLineCommand ReadLineCommand
 

Private Member Functions

void initLib ()
 Initialises access to the readline library.
 
char * commandGenerator (const char *text, int state)
 Completion function for libreadline.
 
void commandLineHandler (const char *text)
 Callback handler from the readline library.
 
void commandExecute (const std::string &cmdStr, const std::vector< std::string > &args)
 Executes the given command, called from readline callback handler.
 
void helpCommand (const std::shared_ptr< const IReadLineContext > &context, const std::vector< std::string > &args)
 Called when the user types help.
 
void quitCommand (const std::shared_ptr< const IReadLineContext > &context, const std::vector< std::string > &args)
 Called when the user types quit.
 

Static Private Member Functions

static char * _commandGenerator (const char *text, int state)
 Callback handler for the tab completion callback.
 
static char ** _completionCallback (const char *text, int start, int end)
 Callback handler for the tab completion callback.
 
static void _commandLineHandler (char *text)
 Callback handler from the readline library.
 
static void signalHandler (int dummy)
 Signal handler for capturing ctrl-c and restoring the terminal state.
 

Private Attributes

std::mutex mLock
 
std::shared_ptr< AICommon::PollLoopmPollLoop
 
void * mLibHandle
 
bool mQuit
 
std::mutex mQuitLock
 
std::condition_variable mQuitConditional
 
std::vector< ReadLine::ReadLineCommandmCommands
 

Static Private Attributes

static std::mutex mInstanceLock
 
static std::shared_ptr< ReadLinemInstance
 
static rl_crlf_t _rl_crlf = nullptr
 
static rl_on_new_line_t _rl_on_new_line = nullptr
 
static rl_forced_update_display_t _rl_forced_update_display = nullptr
 
static rl_completion_matches_t _rl_completion_matches = nullptr
 
static rl_bind_key_t _rl_bind_key = nullptr
 
static rl_callback_handler_install_t _rl_callback_handler_install = nullptr
 
static rl_callback_read_char_t _rl_callback_read_char = nullptr
 
static rl_callback_handler_remove_t _rl_callback_handler_remove = nullptr
 
static add_history_t _add_history = nullptr
 

Additional Inherited Members

- Public Types inherited from IReadLine
typedef std::function< void(const std::shared_ptr< const IReadLineContext > &readLine, const std::vector< std::string > &args)> CommandHandler
 

Member Function Documentation

◆ addCommand()

bool ReadLine::addCommand ( const std::string &  name,
CommandHandler  handler,
const std::string &  desc,
const std::string &  help,
const std::string &  opts 
)
overridevirtual

Adds a new command to the readline loop.

Implements IReadLine.

◆ commandGenerator()

char * ReadLine::commandGenerator ( const char *  text,
int  state 
)
private

Completion function for libreadline.

Generator function for command completion. STATE lets us know whether to start from scratch; without any state (i.e. STATE == 0), then we start at the top of the list.

◆ getContext()

std::shared_ptr< const IReadLineContext > ReadLine::getContext ( ) const
overridevirtual

Returns the print context.

Implements IReadLine.

◆ initLib()

void ReadLine::initLib ( )
private

Initialises access to the readline library.

Because we don't have access to the readline headers of library in the SI build system, we use dlsym to try and get the symbols.

◆ isValid()

bool ReadLine::isValid ( ) const
overridevirtual

Tests if the class is valid.

Implements IReadLine.

◆ printLn()

void ReadLine::printLn ( const char *  fmt,
  ... 
) const
overridevirtual

Prints out the message from the command handler.

Reimplemented from IReadLineContext.

◆ printLnError()

void ReadLine::printLnError ( const char *  fmt,
  ... 
) const
overridevirtual

Prints out an error message from the command handler.

Reimplemented from IReadLineContext.

◆ process()

void ReadLine::process ( const std::shared_ptr< AICommon::IPollLoop > &  pollLoop,
epoll_event  event 
)
overridevirtual

Callback from the PollLoop that is listening on stdin.

Implements AICommon::IPollSource.

◆ quit()

void ReadLine::quit ( ) const
overridevirtual

Triggers an exit from the readline loop.

Implements IReadLineContext.

◆ run()

void ReadLine::run ( )
overridevirtual

Run loop, blocks until quit is called.

Implements IReadLine.

◆ runCommand()

void ReadLine::runCommand ( int  argc,
char *const *  argv 
)
overridevirtual

Implements IReadLine.


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