Bayeux  3.4.1
Core Foundation library for SuperNEMO
Public Types | Public Member Functions | Static Public Member Functions | Static Public Attributes | Protected Member Functions | List of all members
datatools::ui::basic_shell Class Reference

Command line shell interface. More...

#include <bayeux/datatools/ui/basic_shell.h>

Inheritance diagram for datatools::ui::basic_shell:
datatools::i_tree_dumpable

Public Types

enum  run_core_flags { RC_NONE = 0, RC_INHIBIT_HISTORY = datatools::bit_mask::bit00, RC_INHIBIT_READLINE = datatools::bit_mask::bit01, RC_EXIT_ON_ERROR = datatools::bit_mask::bit02 }
 Special flags for run core. More...
 
typedef target_command_interface< basic_shellshell_command_interface_type
 
- Public Types inherited from datatools::i_tree_dumpable
enum  ostream_type { OSTREAM_COUT = 1, OSTREAM_CERR = 2, OSTREAM_CLOG = 3 }
 Enumeration for standard output streams. More...
 

Public Member Functions

 basic_shell (const std::string &name_="")
 Default constructor. More...
 
virtual ~basic_shell ()
 Destructor. More...
 
datatools::logger::priority get_logging () const
 Return the logging priority threshold. More...
 
void set_logging (datatools::logger::priority)
 Set the logging priority threshold. More...
 
bool has_name () const
 Check is the name is set. More...
 
void set_name (const std::string &)
 Set the name: More...
 
const std::string & get_name () const
 Return the name. More...
 
bool has_title () const
 Check is the title is set. More...
 
void set_title (const std::string &)
 Set the title: More...
 
const std::string & get_title () const
 Return the title. More...
 
bool has_version () const
 Check if version identifier is set. More...
 
void set_version (const ::datatools::version_id &)
 Set the version. More...
 
const ::datatools::version_idget_version () const
 Return the version. More...
 
void set_prompt (const std::string &)
 
const std::string & get_prompt () const
 Return the prompt. More...
 
void set_continuation_prompt (const std::string &)
 
const std::string & get_continuation_prompt () const
 Return the continuation prompt. More...
 
std::string get_effective_prompt () const
 Return the current effective prompt. More...
 
std::string get_effective_continuation_prompt () const
 Return the current effective prompt. More...
 
bool has_user () const
 Check if the user identifier is set. More...
 
void set_user (const std::string &)
 Set the user identifier. More...
 
const std::string & get_user () const
 Return the user identifier. More...
 
bool has_host () const
 Check if the host identifier is set. More...
 
void set_host (const std::string &)
 Set the host identifier. More...
 
const std::string & get_host () const
 Return the host identifier. More...
 
void set_exit_on_error (bool)
 Set the abort-on-error flag. More...
 
bool is_exit_on_error () const
 Return the abort-on-error flag. More...
 
void set_using_splash (bool)
 Set the using splash. More...
 
bool is_using_splash () const
 Return the using splash flag. More...
 
void set_using_readline (bool)
 Set the using readline. More...
 
bool is_using_readline () const
 Return the using readline flag. More...
 
void set_using_history (bool)
 Set the using history. More...
 
bool is_using_history () const
 Return the using history flag. More...
 
void set_history_filename (const std::string &)
 Set the history filename. More...
 
const std::string & get_history_filename () const
 Return the history filename. More...
 
void set_history_truncate (unsigned int)
 Set the history truncate. More...
 
unsigned int get_history_truncate ()
 Return the history truncate. More...
 
void set_history_add_only_on_success (bool)
 Set the flag to add only valid command line in history. More...
 
bool is_history_add_only_on_success () const
 Return the flag to add only valid command line in history. More...
 
bool has_default_path () const
 Check if the default path is set. More...
 
void set_default_path (const std::string &)
 Set the default path. More...
 
const std::string & get_default_path () const
 Return the default path. More...
 
bool has_current_path () const
 Check if the current path is set. More...
 
void set_current_path (const std::string &p_)
 Set the current path. More...
 
const std::string & get_current_path () const
 Return the current path. More...
 
bool has_services () const
 Check if services are defined. More...
 
void set_services (::datatools::service_manager &services_)
 Set the handle to an external service manager. More...
 
::datatools::service_managergrab_services ()
 Return a mutable reference to the service manager. More...
 
const ::datatools::service_managerget_services () const
 Return a non mutable reference to the service manager. More...
 
void reset_services ()
 Reset the handle. More...
 
bool has_ihs () const
 Check if IHS is set. More...
 
void set_ihs (ihs &ihs_)
 Set the handle to an external IHS. More...
 
ihsgrab_ihs ()
 Return a mutable reference to the IHS. More...
 
const ihsget_ihs () const
 Return a non mutable reference to the IHS. More...
 
void builtin_command_names (std::vector< std::string > &cmd_names_) const
 Build the list of builtin commands. More...
 
bool has_builtin_command (const std::string &cmd_name_) const
 Check if a builtin command is available. More...
 
const base_commandget_builtin_command (const std::string &cmd_name_) const
 Return a const reference to a builtin command. More...
 
bool is_initialized () const
 Check initialization. More...
 
void initialize_simple ()
 Initialization. More...
 
void initialize (const datatools::properties &)
 Initialization. More...
 
void reset ()
 Reset. More...
 
int run (std::istream *in_=nullptr)
 Main run loop. More...
 
std::string canonical_path (const std::string &path_) const
 Build the canonical full path associated to a given relative or absolute path. More...
 
bool is_absolute_path (const std::string &path_) const
 Check if a path is an absolute existing path. More...
 
bool is_stop_requested () const
 Check if stop is requested. More...
 
void set_stop_requested ()
 Set the stop requested flag. More...
 
void load_macro (const std::string &macro_, uint32_t flags_=0)
 Load a macro file. More...
 
void build_current_list_of_interfaces (std::vector< std::string > &names_, uint32_t flags_=0, std::size_t depth_=0) const
 Build list of interfaces. More...
 
bool has_system_interface () const
 Check if system interface is set. More...
 
void set_system_interface (shell_command_interface_type &)
 Set an external system interface. More...
 
virtual void print_tree (std::ostream &out_=std::clog, const boost::property_tree::ptree &options_=datatools::i_tree_dumpable::empty_options()) const
 
- Public Member Functions inherited from datatools::i_tree_dumpable
 i_tree_dumpable ()
 Constructor. More...
 
virtual ~i_tree_dumpable ()
 Destructor. More...
 
virtual void tree_dump (std::ostream &out_=std::clog, const std::string &title_="", const std::string &indent_="", bool inherit_=false) const
 Main old interface method for printing. More...
 
void print_tree_json (std::ostream &out_=std::clog, const std::string &json_options_="") const
 Printing with jsonized options. More...
 
void print_tree_json (std::ostream &out_=std::clog, const char *json_options_=nullptr) const
 Printing with jsonized options. More...
 
void tree_dump_id (const int out_type_=OSTREAM_CLOG, const std::string &title_="", const std::string &indent_="", const bool inherit_=false) const
 
void tree_print_id (const int out_type_=OSTREAM_CLOG, const std::string &title_="") const
 
void smart_print_id (const int out_type_=OSTREAM_CLOG, const std::string &title_="", const std::string &indent_="") const
 

Static Public Member Functions

static const std::string & system_interface_name ()
 Retour the name of the builtin system interface. More...
 
static const std::string & default_prompt ()
 Retour the default prompt. More...
 
static const std::string & default_continuation_prompt ()
 Retour the default continuation prompt. More...
 
static void make_title_upper (const std::string &title_, std::string &upper_)
 Build a upper and spaced title. More...
 
- Static Public Member Functions inherited from datatools::i_tree_dumpable
static const boost::property_tree::ptree & empty_options ()
 
static boost::property_tree::ptree make_base_print_options (const std::string &title_, const std::string &indent_="", const bool inherit_=false)
 
static std::ostream & last_skip_tag (std::ostream &out_)
 
static std::ostream & skip_tag (std::ostream &out_)
 
static std::ostream & last_tag (std::ostream &out_)
 
static std::ostream & tag (std::ostream &out_)
 

Static Public Attributes

static const unsigned int DEFAULT_HISTORY_TRUNCATE = 200
 

Protected Member Functions

void _set_defaults ()
 Set default values to attributes. More...
 
void _expand_prompt (const std::string &, std::string &) const
 Update the effective prompt. More...
 
void _print_splash (std::ostream &out_=std::cout)
 Print the splash screen. More...
 
void _print_help (std::ostream &out_=std::cout)
 Print online help. More...
 
virtual void _at_init (const datatools::properties &config_)
 At initialization. More...
 
virtual void _at_reset ()
 At reset. More...
 
virtual void _at_run_start ()
 At run start. More...
 
datatools::command::returned_info _run_core (std::istream *in_=nullptr, uint32_t flags_=RC_NONE)
 At run loop. More...
 
datatools::command::returned_info _run_command (const std::string &command_line_)
 Run command. More...
 
virtual void _at_run_stop ()
 At run stop. More...
 
shell_command_interface_type_grab_system_interface ()
 Return the system interface. More...
 
const shell_command_interface_type_get_system_interface () const
 Return the system interface. More...
 
virtual bool _compute_continue_condition ()
 

Detailed Description

Command line shell interface.

Member Typedef Documentation

◆ shell_command_interface_type

Member Enumeration Documentation

◆ run_core_flags

Special flags for run core.

Enumerator
RC_NONE 

Normal run.

RC_INHIBIT_HISTORY 

Inhibit the history.

RC_INHIBIT_READLINE 

Inhibit readline (only interactive session)

RC_EXIT_ON_ERROR 

Force the shell to exit when an error is met.

Constructor & Destructor Documentation

◆ basic_shell()

datatools::ui::basic_shell::basic_shell ( const std::string &  name_ = "")

Default constructor.

◆ ~basic_shell()

virtual datatools::ui::basic_shell::~basic_shell ( )
virtual

Destructor.

Member Function Documentation

◆ _at_init()

virtual void datatools::ui::basic_shell::_at_init ( const datatools::properties config_)
protectedvirtual

At initialization.

◆ _at_reset()

virtual void datatools::ui::basic_shell::_at_reset ( )
protectedvirtual

At reset.

◆ _at_run_start()

virtual void datatools::ui::basic_shell::_at_run_start ( )
protectedvirtual

At run start.

◆ _at_run_stop()

virtual void datatools::ui::basic_shell::_at_run_stop ( )
protectedvirtual

At run stop.

◆ _compute_continue_condition()

virtual bool datatools::ui::basic_shell::_compute_continue_condition ( )
protectedvirtual

Compute continuation condition

Returns
false if the shell should stop at the end of a loop

◆ _expand_prompt()

void datatools::ui::basic_shell::_expand_prompt ( const std::string &  ,
std::string &   
) const
protected

Update the effective prompt.

◆ _get_system_interface()

const shell_command_interface_type& datatools::ui::basic_shell::_get_system_interface ( ) const
protected

Return the system interface.

◆ _grab_system_interface()

shell_command_interface_type& datatools::ui::basic_shell::_grab_system_interface ( )
protected

Return the system interface.

◆ _print_help()

void datatools::ui::basic_shell::_print_help ( std::ostream &  out_ = std::cout)
protected

Print online help.

◆ _print_splash()

void datatools::ui::basic_shell::_print_splash ( std::ostream &  out_ = std::cout)
protected

Print the splash screen.

◆ _run_command()

datatools::command::returned_info datatools::ui::basic_shell::_run_command ( const std::string &  command_line_)
protected

Run command.

◆ _run_core()

datatools::command::returned_info datatools::ui::basic_shell::_run_core ( std::istream *  in_ = nullptr,
uint32_t  flags_ = RC_NONE 
)
protected

At run loop.

◆ _set_defaults()

void datatools::ui::basic_shell::_set_defaults ( )
protected

Set default values to attributes.

◆ build_current_list_of_interfaces()

void datatools::ui::basic_shell::build_current_list_of_interfaces ( std::vector< std::string > &  names_,
uint32_t  flags_ = 0,
std::size_t  depth_ = 0 
) const

Build list of interfaces.

◆ builtin_command_names()

void datatools::ui::basic_shell::builtin_command_names ( std::vector< std::string > &  cmd_names_) const

Build the list of builtin commands.

◆ canonical_path()

std::string datatools::ui::basic_shell::canonical_path ( const std::string &  path_) const

Build the canonical full path associated to a given relative or absolute path.

◆ default_continuation_prompt()

static const std::string& datatools::ui::basic_shell::default_continuation_prompt ( )
static

Retour the default continuation prompt.

◆ default_prompt()

static const std::string& datatools::ui::basic_shell::default_prompt ( )
static

Retour the default prompt.

◆ get_builtin_command()

const base_command& datatools::ui::basic_shell::get_builtin_command ( const std::string &  cmd_name_) const

Return a const reference to a builtin command.

◆ get_continuation_prompt()

const std::string& datatools::ui::basic_shell::get_continuation_prompt ( ) const

Return the continuation prompt.

◆ get_current_path()

const std::string& datatools::ui::basic_shell::get_current_path ( ) const

Return the current path.

◆ get_default_path()

const std::string& datatools::ui::basic_shell::get_default_path ( ) const

Return the default path.

◆ get_effective_continuation_prompt()

std::string datatools::ui::basic_shell::get_effective_continuation_prompt ( ) const

Return the current effective prompt.

◆ get_effective_prompt()

std::string datatools::ui::basic_shell::get_effective_prompt ( ) const

Return the current effective prompt.

◆ get_history_filename()

const std::string& datatools::ui::basic_shell::get_history_filename ( ) const

Return the history filename.

◆ get_history_truncate()

unsigned int datatools::ui::basic_shell::get_history_truncate ( )

Return the history truncate.

◆ get_host()

const std::string& datatools::ui::basic_shell::get_host ( ) const

Return the host identifier.

◆ get_ihs()

const ihs& datatools::ui::basic_shell::get_ihs ( ) const

Return a non mutable reference to the IHS.

◆ get_logging()

datatools::logger::priority datatools::ui::basic_shell::get_logging ( ) const

Return the logging priority threshold.

◆ get_name()

const std::string& datatools::ui::basic_shell::get_name ( ) const

Return the name.

◆ get_prompt()

const std::string& datatools::ui::basic_shell::get_prompt ( ) const

Return the prompt.

◆ get_services()

const ::datatools::service_manager& datatools::ui::basic_shell::get_services ( ) const

Return a non mutable reference to the service manager.

◆ get_title()

const std::string& datatools::ui::basic_shell::get_title ( ) const

Return the title.

◆ get_user()

const std::string& datatools::ui::basic_shell::get_user ( ) const

Return the user identifier.

◆ get_version()

const ::datatools::version_id& datatools::ui::basic_shell::get_version ( ) const

Return the version.

◆ grab_ihs()

ihs& datatools::ui::basic_shell::grab_ihs ( )

Return a mutable reference to the IHS.

◆ grab_services()

::datatools::service_manager& datatools::ui::basic_shell::grab_services ( )

Return a mutable reference to the service manager.

◆ has_builtin_command()

bool datatools::ui::basic_shell::has_builtin_command ( const std::string &  cmd_name_) const

Check if a builtin command is available.

◆ has_current_path()

bool datatools::ui::basic_shell::has_current_path ( ) const

Check if the current path is set.

◆ has_default_path()

bool datatools::ui::basic_shell::has_default_path ( ) const

Check if the default path is set.

◆ has_host()

bool datatools::ui::basic_shell::has_host ( ) const

Check if the host identifier is set.

◆ has_ihs()

bool datatools::ui::basic_shell::has_ihs ( ) const

Check if IHS is set.

◆ has_name()

bool datatools::ui::basic_shell::has_name ( ) const

Check is the name is set.

◆ has_services()

bool datatools::ui::basic_shell::has_services ( ) const

Check if services are defined.

◆ has_system_interface()

bool datatools::ui::basic_shell::has_system_interface ( ) const

Check if system interface is set.

◆ has_title()

bool datatools::ui::basic_shell::has_title ( ) const

Check is the title is set.

◆ has_user()

bool datatools::ui::basic_shell::has_user ( ) const

Check if the user identifier is set.

◆ has_version()

bool datatools::ui::basic_shell::has_version ( ) const

Check if version identifier is set.

◆ initialize()

void datatools::ui::basic_shell::initialize ( const datatools::properties )

Initialization.

◆ initialize_simple()

void datatools::ui::basic_shell::initialize_simple ( )

Initialization.

◆ is_absolute_path()

bool datatools::ui::basic_shell::is_absolute_path ( const std::string &  path_) const

Check if a path is an absolute existing path.

◆ is_exit_on_error()

bool datatools::ui::basic_shell::is_exit_on_error ( ) const

Return the abort-on-error flag.

◆ is_history_add_only_on_success()

bool datatools::ui::basic_shell::is_history_add_only_on_success ( ) const

Return the flag to add only valid command line in history.

◆ is_initialized()

bool datatools::ui::basic_shell::is_initialized ( ) const

Check initialization.

◆ is_stop_requested()

bool datatools::ui::basic_shell::is_stop_requested ( ) const

Check if stop is requested.

◆ is_using_history()

bool datatools::ui::basic_shell::is_using_history ( ) const

Return the using history flag.

◆ is_using_readline()

bool datatools::ui::basic_shell::is_using_readline ( ) const

Return the using readline flag.

◆ is_using_splash()

bool datatools::ui::basic_shell::is_using_splash ( ) const

Return the using splash flag.

◆ load_macro()

void datatools::ui::basic_shell::load_macro ( const std::string &  macro_,
uint32_t  flags_ = 0 
)

Load a macro file.

◆ make_title_upper()

static void datatools::ui::basic_shell::make_title_upper ( const std::string &  title_,
std::string &  upper_ 
)
static

Build a upper and spaced title.

◆ print_tree()

virtual void datatools::ui::basic_shell::print_tree ( std::ostream &  out_ = std::clog,
const boost::property_tree::ptree &  options_ = datatools::i_tree_dumpable::empty_options() 
) const
virtual

Smart print

Supported options:

{
"title" : "My title: ",
"indent" : "[debug] ",
"inherit" : true,
"ihs" : false
}

Reimplemented from datatools::i_tree_dumpable.

◆ reset()

void datatools::ui::basic_shell::reset ( )

Reset.

◆ reset_services()

void datatools::ui::basic_shell::reset_services ( )

Reset the handle.

◆ run()

int datatools::ui::basic_shell::run ( std::istream *  in_ = nullptr)

Main run loop.

◆ set_continuation_prompt()

void datatools::ui::basic_shell::set_continuation_prompt ( const std::string &  )

Set the continuation prompt

See also
set_prompt

◆ set_current_path()

void datatools::ui::basic_shell::set_current_path ( const std::string &  p_)

Set the current path.

◆ set_default_path()

void datatools::ui::basic_shell::set_default_path ( const std::string &  )

Set the default path.

◆ set_exit_on_error()

void datatools::ui::basic_shell::set_exit_on_error ( bool  )

Set the abort-on-error flag.

◆ set_history_add_only_on_success()

void datatools::ui::basic_shell::set_history_add_only_on_success ( bool  )

Set the flag to add only valid command line in history.

◆ set_history_filename()

void datatools::ui::basic_shell::set_history_filename ( const std::string &  )

Set the history filename.

◆ set_history_truncate()

void datatools::ui::basic_shell::set_history_truncate ( unsigned int  )

Set the history truncate.

◆ set_host()

void datatools::ui::basic_shell::set_host ( const std::string &  )

Set the host identifier.

◆ set_ihs()

void datatools::ui::basic_shell::set_ihs ( ihs ihs_)

Set the handle to an external IHS.

◆ set_logging()

void datatools::ui::basic_shell::set_logging ( datatools::logger::priority  )

Set the logging priority threshold.

◆ set_name()

void datatools::ui::basic_shell::set_name ( const std::string &  )

Set the name:

◆ set_prompt()

void datatools::ui::basic_shell::set_prompt ( const std::string &  )

Set the prompt

Supported syntax: n is replaced by the name of the shell w is replaced by the current working interface path W is replaced by the basename of the current working interface path

Example:

◆ set_services()

void datatools::ui::basic_shell::set_services ( ::datatools::service_manager services_)

Set the handle to an external service manager.

◆ set_stop_requested()

void datatools::ui::basic_shell::set_stop_requested ( )

Set the stop requested flag.

◆ set_system_interface()

void datatools::ui::basic_shell::set_system_interface ( shell_command_interface_type )

Set an external system interface.

◆ set_title()

void datatools::ui::basic_shell::set_title ( const std::string &  )

Set the title:

◆ set_user()

void datatools::ui::basic_shell::set_user ( const std::string &  )

Set the user identifier.

◆ set_using_history()

void datatools::ui::basic_shell::set_using_history ( bool  )

Set the using history.

◆ set_using_readline()

void datatools::ui::basic_shell::set_using_readline ( bool  )

Set the using readline.

◆ set_using_splash()

void datatools::ui::basic_shell::set_using_splash ( bool  )

Set the using splash.

◆ set_version()

void datatools::ui::basic_shell::set_version ( const ::datatools::version_id )

Set the version.

◆ system_interface_name()

static const std::string& datatools::ui::basic_shell::system_interface_name ( )
static

Retour the name of the builtin system interface.

Member Data Documentation

◆ DEFAULT_HISTORY_TRUNCATE

const unsigned int datatools::ui::basic_shell::DEFAULT_HISTORY_TRUNCATE = 200
static

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