Disk ARchive: libdar::user_interaction Class Reference

| Disk ARchive 2.8.1 Full featured and portable backup and archiving tool

Loading...
Searching...
No Matches
Public Member Functions | Protected Member Functions | List of all members
libdar::user_interaction Class Referenceabstract
API

This is a pure virtual class that is used by libdar when interaction with the user is required. More...

`#include <user_interaction.hpp>`

Inherited by , and libdar::user_interaction_blind.

## Public Member Functions
| user_interaction (const user_interaction &ref)=default
| user_interaction (user_interaction &&ref) noexcept=default
user_interaction & | operator= (const user_interaction &ref)=default
user_interaction & | operator= (user_interaction &&ref) noexcept=default
void | message (const std::string &message)
void | pause (const std::string &message)
std::string | get_string (const std::string &message, bool echo)
secu_string | get_secu_string (const std::string &message, bool echo)
virtual void | printf (const char *format,...)
| libdar uses this call to format output before sending to the message() method.
bool | cancellation_requested () const
| known whether cancellation was requested for the current thread or an added thread
void | add_thread_to_monitor (pthread_t tid)
| add a thread to monitor
void | remove_thread_from_monitor (pthread_t tid)
| remove a thread from monitoring

## Protected Member Functions
virtual void | inherited_message (const std::string &message)=0
virtual bool | inherited_pause (const std::string &message)=0
| method used to ask a boolean question to the user.
virtual std::string | inherited_get_string (const std::string &message, bool echo)=0
| method used to ask a question that needs an arbitrary answer.
virtual secu_string | inherited_get_secu_string (const std::string &message, bool echo)=0
| same a get_string() but uses libdar::secu_string instead of std::string

## Detailed Description

This is a pure virtual class that is used by libdar when interaction with the user is required.

You can base your own class on it using C++ inheritance or use the predifined inherited classes user_interaction_callback which implements the interaction based on callback functions.

Definition at line 57 of file user_interaction.hpp.

## Constructor & Destructor Documentation

## ◆ user_interaction()

libdar::user_interaction::user_interaction | ( |  | ) |
| inline

Definition at line 60 of file user_interaction.hpp.

## Member Function Documentation

## ◆ add_thread_to_monitor()

void libdar::user_interaction::add_thread_to_monitor | ( | pthread_t | tid | ) |

add a thread to monitor

when a thread cancellation is requested for a thread libdar do no more pause() but assume negative answer and invoke message() with the context and question. However the user_interaction object may run in a different thread than a libdar thread, it is thus necessary to inform the user interaction object of the additional thread_id to monitor for thread cancellation request and adapt the behavior of this object. This is the purpose of this call, in addition to the thread the user_interaction is running in, at the time of any pause() request the user_interaction will call message() if the current thread or any of the added thread_id are under a cancellation request

## ◆ inherited_get_secu_string()

virtual secu_string libdar::user_interaction::inherited_get_secu_string | ( | const std::string & | message,
|  | bool | echo )
| protectedpure virtual

same a get_string() but uses libdar::secu_string instead of std::string

Parameters

  [in] | message | is the question to display to the user.
  [in] | echo | is set to false is the answer must not be shown while the user answers.

Returns
  the user's answer.

Note
  messages passed by libdar are not ending with a newline by default its up to the implementation to separate messages by the adequate mean

Implemented in libdar::user_interaction_blind, and libdar::user_interaction_callback.

## ◆ inherited_get_string()

virtual std::string libdar::user_interaction::inherited_get_string | ( | const std::string & | message,
|  | bool | echo )
| protectedpure virtual

method used to ask a question that needs an arbitrary answer.

Parameters

  [in] | message | is the question to display to the user.
  [in] | echo | is set to false is the answer must not be shown while the user answers.

Returns
  the user's answer.

Note
  messages passed by libdar are not ending with a newline by default its up to the implementation to separate messages by the adequate mean

Implemented in libdar::user_interaction_blind, and libdar::user_interaction_callback.

## ◆ inherited_message()

virtual void libdar::user_interaction::inherited_message | ( | const std::string & | message | ) |
| protectedpure virtual

method used to display a warning or a message to the user.

Parameters

  [in] | message | is the message to display.

Note
  messages passed by libdar are not ending with a newline by default its up to the implementation to separate messages by the adequate mean

Implemented in libdar::user_interaction_blind, and libdar::user_interaction_callback.

## ◆ inherited_pause()

virtual bool libdar::user_interaction::inherited_pause | ( | const std::string & | message | ) |
| protectedpure virtual

method used to ask a boolean question to the user.

Parameters

  [in] | message | The boolean question to ask to the user

Returns
  the answer of the user (true/yes or no/false)

Note
  messages passed by libdar are not ending with a newline by default its up to the implementation to separate messages by the adequate mean

Implemented in libdar::user_interaction_blind, and libdar::user_interaction_callback.

## ◆ printf()

virtual void libdar::user_interaction::printf | ( | const char * | format,
|  |  | ... )
| virtual

libdar uses this call to format output before sending to the message() method.

This is not a virtual method, it has not to be overwritten, it is just a sublayer over warning() Supported masks for the format string are:

- %s %c %d %% (normal behavior)
- %i (matches infinint *)
- %S (matches std::string *)

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

- user_interaction.hpp