LibPkg
Public Types | Public Member Functions | List of all members
pkg::trigger Class Reference

class to represent a trigger action from a script More...

#include <trigger.h>

Public Types

enum  action_type {
  pre_remove, pre_install, post_install, post_remove,
  abort_pre_remove, abort_pre_install
}
 
enum  state_type { state_none, state_running, state_success, state_error }
 

Public Member Functions

 trigger (pkgbase &pb, const std::string &pkgname, trigger::action_type action, const std::string &old_version, const std::string &new_version, trigger_run *runner)
 Construct a new trigger. More...
 
void log_to (log *log)
 
void run ()
 Run the trigger. More...
 
bool finished () const
 Check if the triggers has finished running. More...
 
const std::string & pkgname () const
 
action_type action () const
 
state_type state () const
 
const std::string & message () const
 
void trigger_start_failed (const std::string &reason)
 Callback from trigger_run if the trigger could not be started. More...
 
void trigger_log (const std::string &text)
 Log any output from the trigger. More...
 
void trigger_finished ()
 Callback from trigger_run when the trigger finished. More...
 

Detailed Description

class to represent a trigger action from a script

Member Enumeration Documentation

◆ action_type

Enumerator
pre_remove 
pre_install 
post_install 
post_remove 
abort_pre_remove 
abort_pre_install 

◆ state_type

Enumerator
state_none 
state_running 
state_success 
state_error 

Constructor & Destructor Documentation

◆ trigger()

pkg::trigger::trigger ( pkgbase pb,
const std::string &  pkgname,
trigger::action_type  action,
const std::string &  old_version,
const std::string &  new_version,
trigger_run runner 
)

Construct a new trigger.

Parameters
pbpackage base
pkgnamename of package with trigger
actionwhen the trigger is being run
old_versionold version of the package or "" if not already installed
new_versionnew version of the package or "" if removing
runnerinterface to start the trigger in the front end

References abort_pre_install, abort_pre_remove, pkg::control::components(), pkg::pkgbase::control(), pkg::parse_component_list(), pkg::pkgbase::paths(), post_install, post_remove, pre_install, pre_remove, and src_pathname.

Member Function Documentation

◆ log_to()

void pkg::trigger::log_to ( log log)
inline

References run().

Referenced by pkg::unpack::poll().

◆ run()

void pkg::trigger::run ( )

◆ finished()

bool pkg::trigger::finished ( ) const
inline

Check if the triggers has finished running.

References state_error, and state_success.

Referenced by pkg::unpack::poll().

◆ pkgname()

const std::string& pkg::trigger::pkgname ( ) const
inline

◆ action()

action_type pkg::trigger::action ( ) const
inline

Referenced by run().

◆ state()

state_type pkg::trigger::state ( ) const
inline

Referenced by pkg::unpack::poll().

◆ message()

const std::string& pkg::trigger::message ( ) const
inline

◆ trigger_start_failed()

void pkg::trigger::trigger_start_failed ( const std::string &  reason)

Callback from trigger_run if the trigger could not be started.

Parameters
reasondescription of why the trigger could not be run

References state_error, and trigger_log().

Referenced by message().

◆ trigger_log()

void pkg::trigger::trigger_log ( const std::string &  text)

Log any output from the trigger.

This is usuall any text displayed during the execution of the trigger.

Parameters
textoutput from the trigger run

References pkg::LOG_INFO_TRIGGER_OUTPUT, and pkg::log::message().

Referenced by message(), trigger_finished(), and trigger_start_failed().

◆ trigger_finished()

void pkg::trigger::trigger_finished ( )

Callback from trigger_run when the trigger finished.

References state_error, state_success, and trigger_log().

Referenced by message().


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

Reference Manual LibPkg Version 0.6.1 (28 Jan 2015)