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

Base command. More...

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

Inheritance diagram for datatools::ui::base_command:
datatools::enriched_base datatools::i_serializable datatools::i_tree_dumpable datatools::ui::const_target_command< basic_shell > datatools::ui::const_target_command< Type > datatools::ui::target_command< Type > datatools::ui::target_command< basic_shell > datatools::ui::shell_help_command datatools::ui::shell_ls_command datatools::ui::shell_man_command datatools::ui::shell_pwd_command datatools::ui::shell_tree_command datatools::ui::reflective_command< Type > datatools::ui::shell_cd_command datatools::ui::shell_exit_command datatools::ui::shell_load_command

Public Types

typedef boost::program_options::options_description opts_type
 
typedef boost::program_options::positional_options_description args_type
 
typedef boost::program_options::variables_map vmap_type
 
- Public Types inherited from datatools::enriched_base
enum  export_config_flags {
  EXPORT_CONFIG_CLEAR = bit_mask::bit00, EXPORT_CONFIG_NAME = bit_mask::bit01, EXPORT_CONFIG_DISPLAY_NAME = bit_mask::bit02, EXPORT_CONFIG_TERSE_DESCRIPTION = bit_mask::bit03,
  EXPORT_CONFIG_LOGGING_PRIORITY = bit_mask::bit04, EXPORT_CONFIG_AUXILIARIES = bit_mask::bit05, EXPORT_CONFIG_DEFAULT, EXPORT_CONFIG_LAST = EXPORT_CONFIG_AUXILIARIES
}
 Flags for export to a container of properties. More...
 
- 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

virtual bool is_name_valid (const std::string &candidate_name_) const
 Check if a name is valid. More...
 
 base_command ()
 Default constructor. More...
 
 base_command (const std::string &name_, const std::string &description_="", const version_id &vid_=version_id::invalid())
 Constructor. More...
 
virtual ~base_command ()
 Destructor. More...
 
bool has_generic_opts () const
 Check if some generic options are described. More...
 
const opts_typeget_generic_opts () const
 Return the description of generic options. More...
 
bool use_generic_options () const
 Check if generic options are used. More...
 
bool use_generic_help () const
 Check if generic help are used. More...
 
bool has_opts () const
 Check if some options are described. More...
 
const opts_typeget_opts () const
 Return the description of options. More...
 
bool has_args () const
 Check if some positional options are set. More...
 
bool has_short_ui_options () const
 Check if short UI options are allowed. More...
 
bool has_version () const
 Check if the version is available. More...
 
const datatools::version_idget_version () const
 Return the version of the command. More...
 
void set_version (const datatools::version_id &)
 Set the version of the command. More...
 
virtual bool is_valid () const
 Check validity. More...
 
bool has_parent_interface () const
 Check is the parent interface is set. More...
 
base_command_interfacegrab_parent_interface ()
 Return the parent interface. More...
 
void set_parent_interface (base_command_interface &)
 Set the parent interface. More...
 
const base_command_interfaceget_parent_interface () const
 Return the parent interface. More...
 
bool is_initialized () const
 Check if the command is initialized. More...
 
void initialize_simple ()
 Initialize. More...
 
void initialize (const properties &config_)
 Initialize. More...
 
void reset ()
 Reset. More...
 
bool is_disabled () const
 Check if the command is disabled. More...
 
int operator() (const std::vector< std::string > &argv_, datatools::command::returned_info &cri_, uint32_t flags_=0)
 Main execution operator. More...
 
datatools::command::returned_info operator() (const std::vector< std::string > &argv_, uint32_t flags_=0)
 Execution operator. More...
 
void call (const std::vector< std::string > &argv_, datatools::command::returned_info &cri_, uint32_t flags_=0)
 Call. More...
 
void print_usage (std::ostream &out_, uint32_t flags_=0) const
 Print usage. More...
 
void print_version (std::ostream &out_, uint32_t flags_=0) const
 Print version. More...
 
virtual void tree_dump (std::ostream &out_=std::clog, const std::string &title_="", const std::string &indent_="", bool inherit_=false) const
 Smart print. More...
 
- Public Member Functions inherited from datatools::enriched_base
 enriched_base ()
 Default constructor. More...
 
 enriched_base (const std::string &name_, const std::string &display_name_="", const std::string &terse_description_="", logger::priority lp_=logger::PRIO_FATAL)
 Constructor. More...
 
virtual ~enriched_base ()
 Destructor. More...
 
bool has_name () const
 Check if the name is not empty. More...
 
void set_name (const std::string &name_)
 Set the name. More...
 
enriched_baseset_name_c (const std::string &name_)
 Set the name. More...
 
const std::string & get_name () const
 Return the name. More...
 
void reset_name ()
 Reset the name. More...
 
bool has_display_name () const
 Check if the display name is empty. More...
 
void set_display_name (const std::string &display_name_)
 Set the display name. More...
 
enriched_baseset_display_name_c (const std::string &display_name_)
 Set the display name. More...
 
const std::string & get_display_name () const
 Return the display name. More...
 
bool has_terse_description () const
 Check if the description is empty. More...
 
void set_terse_description (const std::string &terse_description_)
 Set the description. More...
 
enriched_baseset_terse_description_c (const std::string &terse_description_)
 Set the description. More...
 
const std::string & get_terse_description () const
 Return the description. More...
 
bool has_auxiliaries () const
 Check if the container of auxiliary properties is empty. More...
 
const datatools::propertiesget_auxiliaries () const
 Return a reference to the non mutable container of auxiliary properties. More...
 
datatools::propertiesgrab_auxiliaries ()
 Return a reference to the mutable container of auxiliary properties. More...
 
void reset_auxiliaries ()
 Remove all auxiliary properties. More...
 
bool is_debug () const
 Check the debug status. More...
 
void set_logging_priority (logger::priority lp_)
 Set the logging priority threshold. More...
 
enriched_baseset_logging_priority_c (logger::priority lp_)
 Set the logging priority threshold. More...
 
void set_logging (const std::string &label_)
 Set the logging priority threshold from a string. More...
 
logger::priority get_logging_priority () const
 Return the logging priority threshold. More...
 
void clear ()
 Clear. More...
 
void reset ()
 Clear. More...
 
void print_tree (std::ostream &out_=std::clog, const boost::property_tree::ptree &options_=empty_options()) const override
 Smart print. More...
 
void initialize (const datatools::properties &config_, bool clear_=false)
 Initialization from a container of properties. More...
 
void export_to_config (datatools::properties &config_, uint32_t flags_=EXPORT_CONFIG_DEFAULT, const std::string &prefix_="") const
 Export to a container of properties. More...
 
- Public Member Functions inherited from datatools::i_serializable
 i_serializable ()
 Default constructor. More...
 
virtual ~i_serializable ()
 Destructor. More...
 
virtual const std::string & get_serial_tag () const =0
 Return the serialization string identifier of the class. More...
 
- Public Member Functions inherited from datatools::i_tree_dumpable
 i_tree_dumpable ()
 Constructor. More...
 
virtual ~i_tree_dumpable ()
 Destructor. 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
 

Protected Member Functions

void _set_version (const datatools::version_id &)
 
virtual void _init (const properties &config_)
 
virtual void _fini ()
 
virtual void _run (datatools::command::returned_info &, uint32_t flags_=0)=0
 
virtual bool _is_valid () const
 Check the validity (this can be overloaded) More...
 
virtual bool _is_disabled () const
 Check the disabled status (default: false) More...
 
void _base_run (datatools::command::returned_info &, uint32_t flags_=0)
 
opts_type_grab_generic_opts ()
 
void _alloc_generic_opts ()
 
void _free_generic_opts ()
 
opts_type_grab_opts ()
 
void _alloc_opts (const std::string &opts_title_="Allowed options")
 
void _free_opts ()
 
args_type_grab_args ()
 
void _alloc_args ()
 
void _free_args ()
 
vmap_type_grab_vmap ()
 
void _alloc_vmap ()
 
void _free_vmap ()
 
void _forbid_short_ui_options ()
 

Protected Attributes

bool _initialized_ = false
 Initialization flag. More...
 
bool _no_short_ui_options_ = false
 
bool _no_generic_options_ = false
 
bool _no_generic_help_ = false
 
boost::optional< datatools::version_id_version_
 Optional version. More...
 
boost::scoped_ptr< opts_type_generic_opts_
 Description of generic options. More...
 
boost::scoped_ptr< opts_type_opts_
 Description of options. More...
 
boost::scoped_ptr< args_type_args_
 Description of positional options. More...
 
base_command_interface_parent_interface_ = nullptr
 Reference to the parent interface (optional) More...
 
std::unique_ptr< vmap_type_vmap_
 Description of variables map. More...
 

Additional Inherited Members

- Static Public Member Functions inherited from datatools::enriched_base
static bool validate_name (const std::string &candidate_name_)
 Validate a name. More...
 
static logger::priority default_logging_priority ()
 Return the default logging priority threshold. More...
 
static void init_ocd (datatools::object_configuration_description &)
 OCD support. 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_)
 

Detailed Description

Base command.

Member Typedef Documentation

◆ args_type

typedef boost::program_options::positional_options_description datatools::ui::base_command::args_type

◆ opts_type

typedef boost::program_options::options_description datatools::ui::base_command::opts_type

◆ vmap_type

typedef boost::program_options::variables_map datatools::ui::base_command::vmap_type

Constructor & Destructor Documentation

◆ base_command() [1/2]

datatools::ui::base_command::base_command ( )

Default constructor.

◆ base_command() [2/2]

datatools::ui::base_command::base_command ( const std::string &  name_,
const std::string &  description_ = "",
const version_id vid_ = version_id::invalid() 
)

Constructor.

◆ ~base_command()

virtual datatools::ui::base_command::~base_command ( )
virtual

Destructor.

Member Function Documentation

◆ _alloc_args()

void datatools::ui::base_command::_alloc_args ( )
protected

◆ _alloc_generic_opts()

void datatools::ui::base_command::_alloc_generic_opts ( )
protected

◆ _alloc_opts()

void datatools::ui::base_command::_alloc_opts ( const std::string &  opts_title_ = "Allowed options")
protected

◆ _alloc_vmap()

void datatools::ui::base_command::_alloc_vmap ( )
protected

◆ _base_run()

void datatools::ui::base_command::_base_run ( datatools::command::returned_info ,
uint32_t  flags_ = 0 
)
protected

◆ _fini()

virtual void datatools::ui::base_command::_fini ( )
protectedvirtual

◆ _forbid_short_ui_options()

void datatools::ui::base_command::_forbid_short_ui_options ( )
protected

◆ _free_args()

void datatools::ui::base_command::_free_args ( )
protected

◆ _free_generic_opts()

void datatools::ui::base_command::_free_generic_opts ( )
protected

◆ _free_opts()

void datatools::ui::base_command::_free_opts ( )
protected

◆ _free_vmap()

void datatools::ui::base_command::_free_vmap ( )
protected

◆ _grab_args()

args_type& datatools::ui::base_command::_grab_args ( )
protected

◆ _grab_generic_opts()

opts_type& datatools::ui::base_command::_grab_generic_opts ( )
protected

◆ _grab_opts()

opts_type& datatools::ui::base_command::_grab_opts ( )
protected

◆ _grab_vmap()

vmap_type& datatools::ui::base_command::_grab_vmap ( )
protected

◆ _init()

virtual void datatools::ui::base_command::_init ( const properties config_)
protectedvirtual

◆ _is_disabled()

virtual bool datatools::ui::base_command::_is_disabled ( ) const
protectedvirtual

Check the disabled status (default: false)

◆ _is_valid()

virtual bool datatools::ui::base_command::_is_valid ( ) const
protectedvirtual

Check the validity (this can be overloaded)

◆ _run()

virtual void datatools::ui::base_command::_run ( datatools::command::returned_info ,
uint32_t  flags_ = 0 
)
protectedpure virtual

◆ _set_version()

void datatools::ui::base_command::_set_version ( const datatools::version_id )
protected

◆ call()

void datatools::ui::base_command::call ( const std::vector< std::string > &  argv_,
datatools::command::returned_info cri_,
uint32_t  flags_ = 0 
)

Call.

◆ get_generic_opts()

const opts_type& datatools::ui::base_command::get_generic_opts ( ) const

Return the description of generic options.

◆ get_opts()

const opts_type& datatools::ui::base_command::get_opts ( ) const

Return the description of options.

◆ get_parent_interface()

const base_command_interface& datatools::ui::base_command::get_parent_interface ( ) const

Return the parent interface.

◆ get_version()

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

Return the version of the command.

◆ grab_parent_interface()

base_command_interface& datatools::ui::base_command::grab_parent_interface ( )

Return the parent interface.

◆ has_args()

bool datatools::ui::base_command::has_args ( ) const

Check if some positional options are set.

◆ has_generic_opts()

bool datatools::ui::base_command::has_generic_opts ( ) const

Check if some generic options are described.

◆ has_opts()

bool datatools::ui::base_command::has_opts ( ) const

Check if some options are described.

◆ has_parent_interface()

bool datatools::ui::base_command::has_parent_interface ( ) const

Check is the parent interface is set.

◆ has_short_ui_options()

bool datatools::ui::base_command::has_short_ui_options ( ) const

Check if short UI options are allowed.

◆ has_version()

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

Check if the version is available.

◆ initialize()

void datatools::ui::base_command::initialize ( const properties config_)

Initialize.

◆ initialize_simple()

void datatools::ui::base_command::initialize_simple ( )

Initialize.

◆ is_disabled()

bool datatools::ui::base_command::is_disabled ( ) const

Check if the command is disabled.

◆ is_initialized()

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

Check if the command is initialized.

◆ is_name_valid()

virtual bool datatools::ui::base_command::is_name_valid ( const std::string &  candidate_name_) const
virtual

Check if a name is valid.

Reimplemented from datatools::enriched_base.

◆ is_valid()

virtual bool datatools::ui::base_command::is_valid ( ) const
virtual

◆ operator()() [1/2]

int datatools::ui::base_command::operator() ( const std::vector< std::string > &  argv_,
datatools::command::returned_info cri_,
uint32_t  flags_ = 0 
)

Main execution operator.

◆ operator()() [2/2]

datatools::command::returned_info datatools::ui::base_command::operator() ( const std::vector< std::string > &  argv_,
uint32_t  flags_ = 0 
)

Execution operator.

◆ print_usage()

void datatools::ui::base_command::print_usage ( std::ostream &  out_,
uint32_t  flags_ = 0 
) const

Print usage.

◆ print_version()

void datatools::ui::base_command::print_version ( std::ostream &  out_,
uint32_t  flags_ = 0 
) const

Print version.

◆ reset()

void datatools::ui::base_command::reset ( )

Reset.

◆ set_parent_interface()

void datatools::ui::base_command::set_parent_interface ( base_command_interface )

Set the parent interface.

◆ set_version()

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

Set the version of the command.

◆ tree_dump()

virtual void datatools::ui::base_command::tree_dump ( std::ostream &  out_ = std::clog,
const std::string &  title_ = "",
const std::string &  indent_ = "",
bool  inherit_ = false 
) const
virtual

◆ use_generic_help()

bool datatools::ui::base_command::use_generic_help ( ) const

Check if generic help are used.

◆ use_generic_options()

bool datatools::ui::base_command::use_generic_options ( ) const

Check if generic options are used.

Member Data Documentation

◆ _args_

boost::scoped_ptr<args_type> datatools::ui::base_command::_args_
protected

Description of positional options.

◆ _generic_opts_

boost::scoped_ptr<opts_type> datatools::ui::base_command::_generic_opts_
protected

Description of generic options.

◆ _initialized_

bool datatools::ui::base_command::_initialized_ = false
protected

Initialization flag.

◆ _no_generic_help_

bool datatools::ui::base_command::_no_generic_help_ = false
protected

◆ _no_generic_options_

bool datatools::ui::base_command::_no_generic_options_ = false
protected

◆ _no_short_ui_options_

bool datatools::ui::base_command::_no_short_ui_options_ = false
protected

◆ _opts_

boost::scoped_ptr<opts_type> datatools::ui::base_command::_opts_
protected

Description of options.

◆ _parent_interface_

base_command_interface* datatools::ui::base_command::_parent_interface_ = nullptr
protected

Reference to the parent interface (optional)

◆ _version_

boost::optional<datatools::version_id> datatools::ui::base_command::_version_
protected

Optional version.

◆ _vmap_

std::unique_ptr<vmap_type> datatools::ui::base_command::_vmap_
protected

Description of variables map.


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