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

Loading...
Searching...
No Matches
Public Member Functions | Private Member Functions | Private Attributes | List of all members
libdar::semaphore Class Reference
Private

class semaphore More...

`#include <semaphore.hpp>`

Inherits libdar::mem_ui.

## Public Member Functions
| semaphore (const std::shared_ptr< user_interaction > &dialog, const std::string &backup_hook_file_execute, const mask &backup_hook_file_mask)
| constructor
| semaphore (const semaphore &ref)
| copy constructor
| semaphore (semaphore &&ref) noexcept
| move constructor
semaphore & | operator= (const semaphore &ref)
| assignment operator
semaphore & | operator= (semaphore &&ref) noexcept
| move operator
| ~semaphore ()
| destructor
void | raise (const std::string &path, const cat_entree *object, bool data_to_save)
| to prepare a file for backup
void | lower ()
| to tell that the backup is completed for the last "raised" entry.
Public Member Functions inherited from libdar::mem_ui
| mem_ui (const std::shared_ptr< user_interaction > &dialog)
| constructor
| mem_ui (const mem_ui &ref)=default
| the copy constructor
| mem_ui (mem_ui &&ref) noexcept=default
| the move constructor
mem_ui & | operator= (const mem_ui &ref)=default
| assignement operator
mem_ui & | operator= (mem_ui &&ref) noexcept=default
| move operator
virtual | ~mem_ui () noexcept(false)
| destructor

## Private Member Functions
void | nullifyptr () noexcept
std::string | build_string (const std::string &context)
void | copy_from (const semaphore &ref)
void | move_from (semaphore &&ref) noexcept
void | detruit ()

## Private Attributes
infinint | count
| is the number of subdirectories currently saved in the last directory that matched the mask
std::string | chem
| path of the file that has to be call in the "end" context when count will drop to zero
std::string | filename
| filename of that same file
infinint | uid
| UID of that same file.
infinint | gid
| GID of that same file.
unsigned char | sig
| object type
std::string | execute
| command to execute
const mask * | match
| for which file to run the execute command

## Additional Inherited Members
Protected Member Functions inherited from libdar::mem_ui
user_interaction & | get_ui () const
| get access to the user_interaction object
std::shared_ptr< user_interaction > | get_pointer () const
| get access to the shared_ptr pointing to the user_interaction
void | change_ui (const std::shared_ptr< user_interaction > &new_dialog)
| change the user_interaction object

## Detailed Description

class semaphore

Its action is to invoke the execute hook for each file that match the given mask Each file to backup has to be "raised()", which, if it matches the mask, leads to the execution of the execute hook with the proper substitution for that file in the "start" context. Then the backup can take place. When the backup is finished, the lower() method has to be called to trigger the execution of the hook with the proper substitution but in the "end" context. but, things are a bit complicated due to the handle of directories: If a directory is "raised()" and matches the mask, next calls to raise() do not trigger any hook execution even if the file match the mask, while saving into the directory that matched first. Instead, each new call to raise() increments an internal counter when a new directory is met, which is decremented when an "eod" is given to raised(). So it is important to feed raise() with any entry may it has to be saved or not. while lower() has only to be called when a file has been saved. This is only when this internal counters reaches zero, that the lower() call will trigger the execution for this first matched directory, of the hook in the "end" context.

So the expected use is to give each file to be saved (including eod) to the raise() method, before eventually saving the file, and call the lower() method only for files that had to be saved once the backup is completed, may it be normally or due to an exception being thrown.

Definition at line 63 of file semaphore.hpp.

## Constructor & Destructor Documentation

## ◆ semaphore() [1/3]

libdar::semaphore::semaphore | ( | const std::shared_ptr< user_interaction > & | dialog,
|  | const std::string & | backup_hook_file_execute,
|  | const mask & | backup_hook_file_mask )

constructor

Parameters

  [in] | dialog | for user interaction
  [in] | backup_hook_file_execute | is the string to execute, it can contains macros to be substitued, f by filename, p by path, u by uid, g by gid, and c by the context, which is either "start" or "end".
  [in] | backup_hook_file_mask | defines the path+filename of entry that need to have the hook executed before and after their backup

Referenced by operator=(), operator=(), semaphore(), and semaphore().

## ◆ semaphore() [2/3]

libdar::semaphore::semaphore | ( | const semaphore & | ref | ) |
| inline

copy constructor

Definition at line 80 of file semaphore.hpp.

References libdar::mem_ui::mem_ui(), and semaphore().

## ◆ semaphore() [3/3]

libdar::semaphore::semaphore | ( | semaphore && | ref | ) |
| inline noexcept

move constructor

Definition at line 83 of file semaphore.hpp.

References semaphore().

## ◆ ~semaphore()

libdar::semaphore::~semaphore | ( |  | ) |
| inline

destructor

Definition at line 92 of file semaphore.hpp.

## Member Function Documentation

## ◆ nullifyptr()

void libdar::semaphore::nullifyptr | ( |  | ) |
| inline private noexcept

Definition at line 122 of file semaphore.hpp.

## ◆ operator=() [1/2]

semaphore & libdar::semaphore::operator= | ( | const semaphore & | ref | ) |
| inline

assignment operator

Definition at line 86 of file semaphore.hpp.

References semaphore().

## ◆ operator=() [2/2]

semaphore & libdar::semaphore::operator= | ( | semaphore && | ref | ) |
| inline noexcept

move operator

Definition at line 89 of file semaphore.hpp.

References semaphore().

## ◆ raise()

void libdar::semaphore::raise | ( | const std::string & | path,
|  | const cat_entree * | object,
|  | bool | data_to_save )

to prepare a file for backup

all file has to be given to this call, even the eod objects

Parameters

  [in] | path | is the full path to the object
  [in] | object | is the object about to be saved
  [in] | data_to_save | tells whether this entry will have to be saved or just recursed into (directory for example)

Note
  , if data_to_save is true, the lower() method is expected to be used before a next call to raise. For a directory this is only the call to lower() of the matching EOD that will trigger the hook execution in the "end" context. If instead data_to_save if false, no lower() call has to be done.

## Member Data Documentation

## ◆ chem

std::string libdar::semaphore::chem
| private

path of the file that has to be call in the "end" context when count will drop to zero

Definition at line 114 of file semaphore.hpp.

## ◆ count

infinint libdar::semaphore::count
| private

is the number of subdirectories currently saved in the last directory that matched the mask

Definition at line 113 of file semaphore.hpp.

## ◆ execute

std::string libdar::semaphore::execute
| private

command to execute

Definition at line 119 of file semaphore.hpp.

## ◆ filename

std::string libdar::semaphore::filename
| private

filename of that same file

Definition at line 115 of file semaphore.hpp.

## ◆ gid

infinint libdar::semaphore::gid
| private

GID of that same file.

Definition at line 117 of file semaphore.hpp.

## ◆ match

const mask* libdar::semaphore::match
| private

for which file to run the execute command

Definition at line 120 of file semaphore.hpp.

## ◆ sig

unsigned char libdar::semaphore::sig
| private

object type

Definition at line 118 of file semaphore.hpp.

## ◆ uid

infinint libdar::semaphore::uid
| private

UID of that same file.

Definition at line 116 of file semaphore.hpp.

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

- semaphore.hpp