Exiv2::MakerNoteFactory Class Reference

Factory for MakerNote objects. More...

#include <makernote.hpp>

List of all members.

Static Public Member Functions

void cleanup ()
 Destructor.

void registerMakerNote (const std::string &make, const std::string &model, CreateFct createMakerNote)
 Register a MakerNote create function for a camera make and model.

void registerMakerNote (IfdId ifdId, MakerNote::AutoPtr makerNote)
 Register a MakerNote prototype in the IFD id registry.

MakerNote::AutoPtr create (const std::string &make, const std::string &model, bool alloc, const byte *buf, long len, ByteOrder byteOrder, long offset)
 Create the appropriate MakerNote based on camera make and model and possibly the contents of the makernote itself, return an auto-pointer to the newly created MakerNote instance. Return 0 if no MakerNote is defined for the camera model.

MakerNote::AutoPtr create (IfdId ifdId, bool alloc=true)
 Create a MakerNote for an IFD id.

int match (const std::string &regEntry, const std::string &key)
 Match a registry entry with a key (used for make and model).


Detailed Description

Factory for MakerNote objects.

Maintains an associative list (tree) of camera makes/models and corresponding MakerNote create functions. Creates an instance of the MakerNote for one camera make/model. The factory is implemented as a static class.


Member Function Documentation

MakerNote::AutoPtr Exiv2::MakerNoteFactory::create const std::string &  make,
const std::string &  model,
bool  alloc,
const byte buf,
long  len,
ByteOrder  byteOrder,
long  offset
[static]
 

Create the appropriate MakerNote based on camera make and model and possibly the contents of the makernote itself, return an auto-pointer to the newly created MakerNote instance. Return 0 if no MakerNote is defined for the camera model.

The method searches the make-model tree for a make and model combination in the registry that matches the search key. The search is case insensitive (Todo: implement case-insensitive comparisons) and wildcards in the registry entries are supported. First the best matching make is searched, then the best matching model for this make is searched. If there is no matching make or no matching model within the models registered for the best matching make, then no makernote is created and the function returns 0. If a match is found, the function invokes the registered create function and returns an auto-pointer to the newly created MakerNote. The makernote pointed to is owned by the caller of the function and the auto-pointer ensures that it is deleted. The best match is an exact match, then a match is rated according to the number of matching characters. The makernote buffer is passed on to the create function, which can based on its content, automatically determine the correct version or flavour of the makernote required. This is used, e.g., to determine which of the three Nikon makernotes to create.

Parameters:
make Camera manufacturer. (Typically the string from the Exif make tag.)
model Camera model. (Typically the string from the Exif model tag.)
alloc Memory management model for the new MakerNote. Determines if memory required to store data should be allocated and deallocated (true) or not (false). If false, only pointers to the buffer provided to read() will be kept. See Ifd for more background on this concept.
buf Pointer to the makernote character buffer.
len Length of the makernote character buffer.
byteOrder Byte order in which the Exif data (and possibly the makernote) is encoded.
offset Offset from the start of the TIFF header of the makernote buffer.
Returns:
An auto-pointer that owns a MakerNote for the camera model. If the camera is not supported, the pointer is 0.

int Exiv2::MakerNoteFactory::match const std::string &  regEntry,
const std::string &  key
[static]
 

Match a registry entry with a key (used for make and model).

The matching algorithm is case insensitive and wildcards ('*') in the registry entry are supported. The best match is an exact match, then a match is rated according to the number of matching characters.

Returns:
A score value indicating how good the key and registry entry match. 0 means no match, values greater than 0 indicate a match, larger values are better matches:
0: key and registry entry do not match
1: a pure wildcard match, i.e., the registry entry is just a wildcard.
Score values greater than 1 are computed by adding 1 to the number of matching characters, except for an exact match, which scores 2 plus the number of matching characters.

void Exiv2::MakerNoteFactory::registerMakerNote const std::string &  make,
const std::string &  model,
CreateFct  createMakerNote
[static]
 

Register a MakerNote create function for a camera make and model.

Registers a create function for a MakerNote for a given make and model combination with the factory. Both the make and model strings may contain wildcards ('*', e.g., "Canon*"). If the make already exists in the registry, then a new branch for the model is added. If the model also already exists, then the new create function replaces the old one.

Parameters:
make Camera manufacturer. (Typically the string from the Exif make tag.)
model Camera model. (Typically the string from the Exif model tag.)
createMakerNote Pointer to a function to create a new MakerNote of a particular type.


The documentation for this class was generated from the following file:
Generated on Wed Jul 11 11:26:31 2007 for Exiv2 by doxygen 1.3.5