SourceForge.net Logo
Main Page   Class Hierarchy   Alphabetical List   Compound List   File List   Compound Members   File Members  

PmtAccessor Class Reference

The PmtAccessor is the base class for accessor implementations. More...

#include <PmtAccessor.h>

Inheritance diagram for PmtAccessor:

[legend]
Collaboration diagram for PmtAccessor:
[legend]
List of all members.

Public Methods

virtual ~PmtAccessor ()
const bool & throwErrors () const
 This function returns the throwError flag. More...

bool & throwErrors ()
 Provides the application control over how metadata access errors are handled. More...

bool isErrorThrown () const
 Check if any error is thrown and suppressed. More...

void printErrorsSuppressed (ostream &c=cout) const
 Print the messages of the suppressed errors. More...

const PmtImageFileFormatNameformatName () const
 Return the format name of the file to be accessed. More...

virtual PmtMetadataPtr readMetadata (const SPmtString &nsURI="")
 Read all existing metadata and return a root metadata. More...

virtual PmtMetadataPtr readMetadata (PmtMetadataPtr &md)
 Read the specified metadata from the storage format. More...

PmtMetadataIteratorreadMetadata (PmtMetadataIterator &mdIter)
 Read the specified metadata from the storage format. More...

virtual bool open (const char *name, PmtOpenMode mode=PMT_READONLY)=0
 Open a file. More...

virtual void close ()
 Close the file. More...

virtual PmtAccessorPtr clone () const=0
 This method returns a copy of the accessor. More...

virtual void writeMetadata (const PmtMetadataPtr &md, bool bWriteValid=false)
void writeMetadata (PmtMetadataIterator &md, bool bWriteValid=false)

Static Public Methods

PmtAccessorFactoryTypefactory ()
 Return the factory object. More...

PmtAccessorPtr create (const PmtImageFileFormatName &accrId)
 create an instance of the specified accessor. More...

PmtAccessorPtr getAccessor (const char *fileName, PmtOpenMode mode=PMT_READONLY)
 This method creates and returns the proper accessor implementation for the given file. More...


Protected Methods

 PmtAccessor (const PmtImageFileFormatName &fName)
 The constructor is protected to ensure that only derived classes can call it. More...

void load ()
 Initializes the translation table from the compiled in default. More...

void load (const SPmtString &filename)
 Initializes the translation table from the supplied file. More...

void loadMemory (const char *translationTable)
 Initialized the translation table from the supplied in-memory argument. More...

void loadCommon (DOMParser *parser)
 Common code for parsing and loading translation tables. More...

virtual void getMdValue (PmtMetadataPtr &md)=0
virtual void setMdValue (const PmtMetadataPtr &md)=0
virtual bool recognize (const SPmtString &name) const=0
 Used by the getAccessor() method to determine the file type. More...

void loadIfAny ()

Static Protected Methods

void erase ()

Protected Attributes

PmtImageFileFormatName mFormatName
SPmtString mFileName
bool mThrowErrors
vector< PmtErrormErrors

Static Protected Attributes

PmtTranslationTableMap msTranslationTable
PmtParserFactory msParserFactory
const char *const msDefaultTranslationTableArray []
EK_DEFAULT_MUTEX msLock

Detailed Description

The PmtAccessor is the base class for accessor implementations.

An Accessor's primary responsibility is to provide applications with read / write access to stored metadata. The metadata may be stored in an image file, in a file system through the metadata persistence mechanism, in a database (relational or object), etc. Initial considerations have been limited to image file access. PmtAccessor is the base class from which all other accessors will be derived. Prior to using an accessor, the application must ensure that the metadata definitions have been loaded via the LogicalDefinitionInterpreter.

The PmtAccessor class keeps a factory object where all derived accessors are registered. It provides a static factory method getAccessor() for creating a specific accessor to access the given file. All derived accessors must use the EkFactory mechanism (EK_PROVIDE, EK_REQUIRE) to register itself in the factory object.


Constructor & Destructor Documentation

virtual PmtAccessor::~PmtAccessor   [inline, virtual]
 

PmtAccessor::PmtAccessor const PmtImageFileFormatName   fName [inline, protected]
 

The constructor is protected to ensure that only derived classes can call it.


Member Function Documentation

virtual PmtAccessorPtr PmtAccessor::clone   const [pure virtual]
 

This method returns a copy of the accessor.

Implemented in PmtExifAccessor.

virtual void PmtAccessor::close   [inline, virtual]
 

Close the file.

This is a pure virtual function that is to be implemented by the derived classes.

Reimplemented in PmtExifAccessor.

PmtAccessorPtr PmtAccessor::create const PmtImageFileFormatName   accrId [static]
 

create an instance of the specified accessor.

Allows the instantiation of a specific accessor implementation without needing the include the implementations header file.

void PmtAccessor::erase   [static, protected]
 

PmtAccessorFactoryType & PmtAccessor::factory   [static]
 

Return the factory object.

This method is for the purpose of registering accessor. The user of PMT normally never call it.

const PmtImageFileFormatName& PmtAccessor::formatName   const [inline]
 

Return the format name of the file to be accessed.

PmtAccessorPtr PmtAccessor::getAccessor const char *    fileName,
PmtOpenMode    mode = PMT_READONLY
[static]
 

This method creates and returns the proper accessor implementation for the given file.

virtual void PmtAccessor::getMdValue PmtMetadataPtr   md [protected, pure virtual]
 

Implemented in PmtExifAccessor.

bool PmtAccessor::isErrorThrown   const [inline]
 

Check if any error is thrown and suppressed.

void PmtAccessor::load const SPmtString   filename [protected]
 

Initializes the translation table from the supplied file.

void PmtAccessor::load   [protected]
 

Initializes the translation table from the compiled in default.

void PmtAccessor::loadCommon DOMParser *    parser [protected]
 

Common code for parsing and loading translation tables.

void PmtAccessor::loadIfAny   [protected]
 

void PmtAccessor::loadMemory const char *    translationTable [protected]
 

Initialized the translation table from the supplied in-memory argument.

virtual bool PmtAccessor::open const char *    name,
PmtOpenMode    mode = PMT_READONLY
[pure virtual]
 

Open a file.

This is a pure virtual function that is to be implemented by the derived classes.

Implemented in PmtExifAccessor.

void PmtAccessor::printErrorsSuppressed ostream &    c = cout const
 

Print the messages of the suppressed errors.

PmtMetadataIterator & PmtAccessor::readMetadata PmtMetadataIterator   mdIter
 

Read the specified metadata from the storage format.

PmtMetadataPtr PmtAccessor::readMetadata PmtMetadataPtr   md [virtual]
 

Read the specified metadata from the storage format.

Reimplemented in PmtXmlAccessor.

PmtMetadataPtr PmtAccessor::readMetadata const SPmtString   nsURI = "" [virtual]
 

Read all existing metadata and return a root metadata.

Reimplemented in PmtExifAccessor.

virtual bool PmtAccessor::recognize const SPmtString   name const [protected, pure virtual]
 

Used by the getAccessor() method to determine the file type.

The derived accessor classes that want to be created from the getAccessor() method should provide an implementation for this method.

Implemented in PmtExifAccessor.

virtual void PmtAccessor::setMdValue const PmtMetadataPtr   md [protected, pure virtual]
 

Implemented in PmtExifAccessor.

bool& PmtAccessor::throwErrors   [inline]
 

Provides the application control over how metadata access errors are handled.

If throwErrors is set true, then an error will be thrown if there is any problem accessing the requested metadata. If set false, no errors will be thrown. The default setting is false.

const bool& PmtAccessor::throwErrors   const [inline]
 

This function returns the throwError flag.

void PmtAccessor::writeMetadata PmtMetadataIterator   md,
bool    bWriteValid = false
 

Request the accessor to write the given metadata to the storage media.

The argument is a pointer to an instance of either an PmtMetadata (for a single metadata item) or an PmtCompositeMetadata (for multiple metadata items). If throwErrors() is set to false and an error occurs, one of two things will happen. First, if the write is for a single metadata, then the write will just be aborted. Second, if the write is for a composite, then the write of the current metadatum is aborted and the writing of the composite contiues with the next element. If throwErrors() is set to true, then the write operation is always aborted by throwing the error. If bWriteValid is false then only the given metadata (including its childern) will be written; otherwise, the whole metadata tree starting from the out-most parent will be written.

void PmtAccessor::writeMetadata const PmtMetadataPtr   md,
bool    bWriteValid = false
[virtual]
 

Request the accessor to write the given metadata to the storage media.

The argument is a pointer to an instance of either an PmtMetadata (for a single metadata item) or an PmtCompositeMetadata (for multiple metadata items). If throwErrors() is set to false and an error occurs, one of two things will happen. First, if the write is for a single metadata, then the write will just be aborted. Second, if the write is for a composite, then the write of the current metadatum is aborted and the writing of the composite contiues with the next element. If throwErrors() is set to true, then the write operation is always aborted by throwing the error. If bWriteValid is false then only the given metadata (including its childern) will be written; otherwise, the whole metadata tree starting from the out-most parent will be written.

Reimplemented in PmtXmlAccessor.


Member Data Documentation

vector<PmtError> PmtAccessor::mErrors [protected]
 

SPmtString PmtAccessor::mFileName [protected]
 

PmtImageFileFormatName PmtAccessor::mFormatName [protected]
 

const char *const PmtAccessor::msDefaultTranslationTableArray [static, protected]
 

EK_DEFAULT_MUTEX PmtAccessor::msLock [static, protected]
 

PmtParserFactory PmtAccessor::msParserFactory [static, protected]
 

PmtTranslationTableMap PmtAccessor::msTranslationTable [static, protected]
 

bool PmtAccessor::mThrowErrors [protected]
 


The documentation for this class was generated from the following files:
Last Updated: March 12, 2003 (rlr)
Copyright © 2003 Eastman Kodak Company All Rights Reserved.