LibPkg
Classes | Public Types | Public Member Functions | Static Public Attributes | Protected Member Functions | List of all members
pkg::unpack Class Reference

A class for unpacking and removing sets of packages. More...

#include <unpack.h>

Inheritance diagram for pkg::unpack:
pkg::thread

Classes

class  cannot_process
 An exception class for reporting that one or more packages cannot be processed. More...
 
class  file_conflict
 An exception class for reporting that one or more files conflict with those already on the system. More...
 
class  file_info_not_found
 An exception class for reporting that a file information record could not be found. More...
 

Public Types

enum  state_type {
  state_pre_unpack, state_pre_remove, state_unpack, state_replace,
  state_remove, state_post_remove, state_post_unpack, state_done,
  state_unwind_remove, state_unwind_replace, state_unwind_unpack, state_unwind_pre_remove,
  state_unwind_pre_unpack, state_fail
}
 An enumeration for describing the state of the unpack operation. More...
 
typedef unsigned long long size_type
 A type for representing byte counts. More...
 

Public Member Functions

 unpack (pkgbase &pb, const std::set< string > &packages)
 Construct unpack object. More...
 
virtual ~unpack ()
 Destroy unpack object. More...
 
state_type state () const
 Get current state of the unpack operation. More...
 
size_type files_done () const
 Get number of files processed. More...
 
size_type files_total () const
 Get total number of files to process. More...
 
size_type bytes_done () const
 Get number of bytes processed. More...
 
size_type bytes_total () const
 Get total number of bytes to process. More...
 
string message () const
 Get error message. More...
 
const std::set< string > & packages_cannot_process () const
 Get the set of packages that cannot be processed. More...
 
const std::set< string,
case_insensitive_cmp > & 
files_that_conflict () const
 Get the set of destination pathnames that conflict with files already on the system. More...
 
void log_to (pkg::log *use_log)
 Set the log to add the unpack messages to. More...
 
- Public Member Functions inherited from pkg::thread
 thread ()
 Construct thread. More...
 
virtual ~thread ()
 Destroy thread. More...
 

Static Public Attributes

static const size_type npos =static_cast<size_type>(-1)
 A null value for use in place of a byte count. More...
 

Protected Member Functions

void poll ()
 Poll this thread. More...
 

Additional Inherited Members

- Static Public Member Functions inherited from pkg::thread
static void poll_all ()
 Poll all threads. More...
 

Detailed Description

A class for unpacking and removing sets of packages.

Member Typedef Documentation

typedef unsigned long long pkg::unpack::size_type

A type for representing byte counts.

Member Enumeration Documentation

An enumeration for describing the state of the unpack operation.

Enumerator
state_pre_unpack 

The state in which the states of packages to be unpacked are changed to status::state_half_unpacked.

state_pre_remove 

The state in which the states of packages to be removed are changed to status::state_half_unpacked.

state_unpack 

The state in which files are unpacked from their zip archives and moved to temporary locations.

state_replace 

The state in which old versions of files are backed up and replaced with new versions.

state_remove 

The state in which old versions of files that do not have replacements are backed up then removed.

state_post_remove 

The state in which backups are deleted, and the states of packages to be removed are changed to status::state_removed.

state_post_unpack 

The state in which the states of packages to be unpacked are changed to status::state_unpacked.

state_done 

The state in which all operations have been successfully completed.

state_unwind_remove 

The state in which state_remove is being backed out.

state_unwind_replace 

The state in which state_replace is being backed out.

state_unwind_unpack 

The state in which state_unpack is being backed out.

state_unwind_pre_remove 

The state in which state_pre_remove is being backed out.

state_unwind_pre_unpack 

The state in which state_pre_unpack is being backed out.

state_fail 

The state in which an error has occurred and an attempt has been made to back out changes.

Constructor & Destructor Documentation

pkg::unpack::unpack ( pkgbase pb,
const std::set< string > &  packages 
)

Construct unpack object.

Parameters
pbthe package database
packagesthe set of packages to process

References pkg::pkgbase::curstat(), pkg::remove_req(), pkg::pkgbase::selstat(), and pkg::unpack_req().

pkg::unpack::~unpack ( )
virtual

Destroy unpack object.

Member Function Documentation

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

Get current state of the unpack operation.

Returns
the current state

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

size_type pkg::unpack::files_done ( ) const
inline

Get number of files processed.

Returns
the number of files processed (in current stage)

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

size_type pkg::unpack::files_total ( ) const
inline

Get total number of files to process.

Returns
the total number of files to process (in current stage)

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

size_type pkg::unpack::bytes_done ( ) const
inline

Get number of bytes processed.

Returns
the number of bytes processed (in current stage)

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

size_type pkg::unpack::bytes_total ( ) const
inline

Get total number of bytes to process.

Returns
the total number of bytes to process (in current stage)

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

string pkg::unpack::message ( ) const
inline

Get error message.

When state()==state_fail, this function returns a human-readable description of what went wrong.

Returns
the error message

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

const std::set<string>& pkg::unpack::packages_cannot_process ( ) const
inline

Get the set of packages that cannot be processed.

When state()==state_fail, this function returns a list of packages that cannot be processed until the package manager has been upgraded.

Returns
the set of packages that cannot be processed
const std::set<string, case_insensitive_cmp>& pkg::unpack::files_that_conflict ( ) const
inline

Get the set of destination pathnames that conflict with files already on the system.

When state()==state_fail, this function returns a list of files that must be deleted before the given set of packages can be processed.

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

void pkg::unpack::log_to ( pkg::log use_log)

Set the log to add the unpack messages to.

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

void pkg::unpack::poll ( )
protectedvirtual

Poll this thread.

This function will be called repeatedly until the thread ceases to exist. The amount of work done per invokation should be kept small, in order that multithreading (within the application) and multitasking (across RISC OS as a whole) operate smoothly.

Reimplemented from pkg::thread.

References pkg::pkgbase::curstat(), pkg::LOG_ERROR_UNPACK_EXCEPTION, pkg::LOG_INFO_UNWIND_REPLACED_FILES, pkg::LOG_INFO_UNWIND_UNPACK_FILES, pkg::log::message(), pkg::status_table::rollback(), state_fail, state_pre_remove, state_pre_unpack, state_remove, state_replace, state_unpack, state_unwind_replace, and state_unwind_unpack.

Member Data Documentation

const size_type pkg::unpack::npos =static_cast<size_type>(-1)
static

A null value for use in place of a byte count.


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

Reference Manual LibPkg Version 0.6.1 (28 Jan 2015)