Fork Vasum on GitHub Official Vasum Wiki on Tizen.org
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
vasum::cli::CommandLineInterface Class Reference

Class that implements command pattern. More...

#include <command-line-interface.hpp>

Public Types

typedef std::function< void(const
Args &argv)> 
ExecutorCallback
 
typedef std::vector< ArgSpecArgsSpec
 

Public Member Functions

 CommandLineInterface ()
 Dummy constructor (for stl usage) More...
 
 CommandLineInterface (const ExecutorCallback &executorCallback, const std::string &name, const std::string &description, const unsigned int &availability, const ArgsSpec &argsSpec)
 Construct command. More...
 
const std::string & getName () const
 Get the command name. More...
 
const std::string & getDescription () const
 Get the command description. More...
 
void printUsage (std::ostream &out) const
 Print usage to stream. More...
 
bool isAvailable (unsigned int mode) const
 Check if the command is available in specific mode. More...
 
void execute (const Args &argv) const
 Do the work. More...
 
const std::vector< std::string > buildCompletionList (const Args &argv) const
 

Static Public Member Functions

static void connect ()
 Set the class (static) in a connected state. More...
 
static void disconnect ()
 Disconnect the class from a vasum client. More...
 
static void executeCallback (const std::function< VsmStatus(VsmClient)> &fun)
 Execute a callback passing the connected VsmClient. More...
 

Private Attributes

const ExecutorCallback mExecutorCallback
 
const std::string mName
 
const std::string mDescription
 
const unsigned int mAvailability
 
const ArgsSpec mArgsSpec
 

Static Private Attributes

static VsmClient client = NULL
 

Detailed Description

Class that implements command pattern.

Member Typedef Documentation

Constructor & Destructor Documentation

vasum::cli::CommandLineInterface::CommandLineInterface ( )
inline

Dummy constructor (for stl usage)

vasum::cli::CommandLineInterface::CommandLineInterface ( const ExecutorCallback executorCallback,
const std::string &  name,
const std::string &  description,
const unsigned int &  availability,
const ArgsSpec argsSpec 
)
inline

Construct command.

Parameters
executorCallbackCallback function that will do the job
nameCommand name
descriptionCommand Description
availabilityCommand availability (bit field)
argsSpecDescription of arguments
Remarks
Possible bits for availability: MODE_COMMAND_LINE, MODE_INTERACTIVE

Member Function Documentation

const std::vector< std::string > vasum::cli::CommandLineInterface::buildCompletionList ( const Args argv) const
void vasum::cli::CommandLineInterface::connect ( )
static

Set the class (static) in a connected state.

This persistent connection to the vasum client is required for calls like lock/unlock queue to work.

void vasum::cli::CommandLineInterface::disconnect ( )
static

Disconnect the class from a vasum client.

void vasum::cli::CommandLineInterface::execute ( const Args argv) const

Do the work.

It calls the callback passed in constructor

Parameters
argvCommand line arguments
void vasum::cli::CommandLineInterface::executeCallback ( const std::function< VsmStatus(VsmClient)> &  fun)
static

Execute a callback passing the connected VsmClient.

Parameters
funA callback to execute
const std::string & vasum::cli::CommandLineInterface::getDescription ( ) const

Get the command description.

const std::string & vasum::cli::CommandLineInterface::getName ( ) const

Get the command name.

bool vasum::cli::CommandLineInterface::isAvailable ( unsigned int  mode) const

Check if the command is available in specific mode.

Parameters
modeA mode to check the command's availability in
void vasum::cli::CommandLineInterface::printUsage ( std::ostream &  out) const

Print usage to stream.

Parameters
outOutput stream

Member Data Documentation

VsmClient vasum::cli::CommandLineInterface::client = NULL
staticprivate
const ArgsSpec vasum::cli::CommandLineInterface::mArgsSpec
private
const unsigned int vasum::cli::CommandLineInterface::mAvailability
private
const std::string vasum::cli::CommandLineInterface::mDescription
private
const ExecutorCallback vasum::cli::CommandLineInterface::mExecutorCallback
private
const std::string vasum::cli::CommandLineInterface::mName
private

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