ome-files 0.1.0

- Main Page
- Related Pages
- Namespaces
- Classes
- Files

- Class List
- Class Index
- Class Hierarchy
- Class Members

Public Member Functions | Private Member Functions | Static Private Member Functions | Private Attributes | Static Private Attributes | List of all members
ome::files::tiff::Sentry Class Reference

Sentry for saving and restoring libtiff state. More...

`#include <ome/files/tiff/Sentry.h>`

Collaboration diagram for ome::files::tiff::Sentry:
[legend]

## Public Member Functions
| Sentry ()
| Constructor.
| ~Sentry ()
| Destructor.
std::string const & | getMessage () const
| Get the latest error message. More...
void | error (const std::string &message) const
| Throw an Exception. More...
void | error () const
| Throw an Exception. More...

## Private Member Functions
void | setMessage (std::string const &message)
| Set the latest error message. More...

## Static Private Member Functions
static void | errorHandler (const char *module, const char *fmt, va_list ap)
| libtiff error handler. More...

## Private Attributes
boost::lock_guard< boost::recursive_mutex > | lock
| Acquired lock on tiff_lock.
std::string | message
| Last error message.

## Static Private Attributes
static boost::recursive_mutex | tiff_mutex
| Mutex to lock libtiff access.

## Detailed Description

Sentry for saving and restoring libtiff state.

This acts primarily to save the state of the global error and warning handlers, which are configured to work with the currently active TIFF/IFD. The original state is restored when destroyed. Note that this exclusively locks all TIFF and IFD methods calling into libtiff, so will potentially block other threads.

This class also hooks into the global libtiff error handling to capture any errors which occur. The latest error will be available using getMessage().

This class should be used at block scope so that instances will only exist transiently until the block ends.

## Member Function Documentation

void ome::files::tiff::Sentry::error | ( | const std::string & | message | ) | const

Throw an Exception.

The latest error message will be set as the message. If no error message has been set, the provided message will be used. This is to cater for the cases where libtiff fails but does not provide any indication of why.

Parameters

  message | the message to set.

Exceptions

  an | Exception.

Referenced by ome::files::tiff::TIFF::Impl::close(), ome::files::tiff::TIFF::getDirectoryByIndex(), ome::files::tiff::TIFF::getDirectoryByOffset(), ome::files::tiff::IFD::getRawField(), ome::files::tiff::TIFF::Impl::Impl(), ome::files::tiff::IFD::makeCurrent(), ome::files::tiff::IFD::openIndex(), ome::files::tiff::TIFF::registerImageJTags(), ome::files::tiff::IFD::setRawField(), and ome::files::tiff::TIFF::writeCurrentDirectory().

Here is the caller graph for this function:

void ome::files::tiff::Sentry::error | ( |  | ) | const

Throw an Exception.

The latest error message will be set as the message.

Exceptions

  an | Exception.

void ome::files::tiff::Sentry::errorHandler | ( | const char * | module,
|  | const char * | fmt,
|  | va_list | ap
| ) |  |
| static private

libtiff error handler.

The error message received will be converted to a string and saved in the current Sentry for later retrieval with getMessage().

Parameters

  module | the module or file emitting the error.
  fmt | the format string for the error.
  ap | additional parameters.

References message.

Referenced by Sentry().

Here is the caller graph for this function:

std::string const & ome::files::tiff::Sentry::getMessage | ( |  | ) | const

Get the latest error message.

If no error has occured, the message will be empty.

Returns
  the message.

References message.

Referenced by ome::files::tiff::TIFF::Impl::close().

Here is the caller graph for this function:

void ome::files::tiff::Sentry::setMessage | ( | std::string const & | message | ) |
| private

Set the latest error message.

Any previously stored message will be replaced.

Parameters

  message | the message to set.

References message.

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

- ome/files/tiff/Sentry.h
- ome/files/tiff/Sentry.cpp