Disk ARchive  2.5.12
Full featured and portable backup and archiving tool
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Modules
Public Member Functions | List of all members
libdar::semaphore Class Reference

class semaphore More...

#include <semaphore.hpp>

Inherits libdar::mem_ui, and libdar::on_pool.

Public Member Functions

 semaphore (user_interaction &dialog, const std::string &backup_hook_file_execute, const mask &backup_hook_file_mask)
 constructor More...
 
 semaphore (const semaphore &ref)
 copy constructor
 
semaphoreoperator= (const semaphore &ref)
 assignment operator
 
 ~semaphore ()
 destructor
 
void raise (const std::string &path, const cat_entree *object, bool data_to_save)
 to prepare a file for backup More...
 
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 user_interaction &dialog)
 constructor More...
 
 mem_ui (user_interaction *dialog)
 
 mem_ui (const mem_ui &ref)
 the copy constructor More...
 
virtual ~mem_ui () throw (Ebug)
 destructor More...
 
const mem_uioperator= (const mem_ui &ref)
 assignement operator More...
 
- Public Member Functions inherited from libdar::on_pool
void * operator new (size_t n_byte)
 
void * operator new (size_t n_byte, const std::nothrow_t &nothrow_value)
 
void * operator new[] (size_t n_byte)
 
void * operator new[] (size_t n_byte, const std::nothrow_t &nothrow_value)
 
void * operator new (size_t n_byte, memory_pool *p)
 
void * operator new[] (size_t n_byte, memory_pool *p)
 
void operator delete (void *ptr, memory_pool *p)
 this operator is called by the compiler if an exception is throw from the constructor of the allocated object
 
void operator delete[] (void *ptr, memory_pool *p)
 this operator is called by the compiler if an exception is throw from the constructor of the allocated objects
 
void operator delete (void *ptr)
 this is the usual delete operator, modified to handle allocated objects allocated on a memory pool or not
 
void operator delete[] (void *ptr)
 this is the usual delete[] operator, modified to handle allocated objects allocated on a memory pool or not
 

Additional Inherited Members

- Protected Member Functions inherited from libdar::mem_ui
user_interactionget_ui () const
 get access to the user_interaction cloned object More...
 
- Protected Member Functions inherited from libdar::on_pool
memory_pool * get_pool () const
 
template<class T >
void meta_new (T *&ptr, size_t num)
 
template<class T >
void meta_delete (T *ptr)
 

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 66 of file semaphore.hpp.

Constructor & Destructor Documentation

libdar::semaphore::semaphore ( user_interaction dialog,
const std::string &  backup_hook_file_execute,
const mask backup_hook_file_mask 
)

constructor

Parameters
[in]dialogfor user interaction
[in]backup_hook_file_executeis 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_maskdefines the path+filename of entry that need to have the hook executed before and after their backup

Member Function Documentation

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]pathis the full path to the object
[in]objectis the object about to be saved
[in]data_to_savetells 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.

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