|
degate 0.1.1
|
A factory for creating image reader objects. More...
#include <ImageReaderFactory.h>
Public Member Functions | |
| ImageReaderFactory () | |
| ~ImageReaderFactory () | |
| file_format_collection const & | get_file_formats () const |
| Get a list of parseable file formats. | |
| std::tr1::shared_ptr< class ImageReaderBase< ImageType > > | get_reader (std::string const &filename) |
| Get a concrete image reader object for a file name. | |
Private Attributes | |
| file_format_collection | file_formats |
A factory for creating image reader objects.
Definition at line 46 of file ImageReaderFactory.h.
| degate::ImageReaderFactory< ImageType >::ImageReaderFactory | ( | ) | [inline] |
Definition at line 56 of file ImageReaderFactory.h.
References degate::ImageReaderFactory< ImageType >::file_formats.
{
// Tiff file format parser
file_formats.push_back("tif");
file_formats.push_back("tiff");
// Jpeg file format parser
file_formats.push_back("jpg");
file_formats.push_back("jpeg");
}
| degate::ImageReaderFactory< ImageType >::~ImageReaderFactory | ( | ) | [inline] |
Definition at line 67 of file ImageReaderFactory.h.
{}
| file_format_collection const& degate::ImageReaderFactory< ImageType >::get_file_formats | ( | ) | const [inline] |
Get a list of parseable file formats.
Definition at line 72 of file ImageReaderFactory.h.
References degate::ImageReaderFactory< ImageType >::file_formats.
{
return file_formats;
}
| std::tr1::shared_ptr<class ImageReaderBase<ImageType> > degate::ImageReaderFactory< ImageType >::get_reader | ( | std::string const & | filename | ) | [inline] |
Get a concrete image reader object for a file name.
| filename | The file name is evaluated. Depending on the file suffix an image reader is choosen. The file must not exists for the reader selection, but the reader will fail, if it can't read the image. |
| InvalidFileFormatException | This exception is thrown if the there is no reader that can read the file. |
Definition at line 87 of file ImageReaderFactory.h.
References degate::get_file_suffix().
Referenced by degate::load_image().
{
std::string suffix(get_file_suffix(filename).c_str());
/*
Convert suffix string to a lowercase string.
This comment should not be necessary, if there would be a simple
way to convert it. You may have seen other programming languages
with a simple convenient way to lowercase strings. But hey! The
transform is really generic, You can even apply it to strings. Wow!
BTW: If you omit the static cast, you will get a long error message
from your compiler. Great!
*/
std::transform(suffix.begin(), suffix.end(), suffix.begin(),
static_cast<int (*)(int)>(std::tolower));
// Ok. Enough sarcasm. Let us finish the job ...
if(suffix == "tif" || suffix == "tiff")
return std::tr1::shared_ptr<ImageReaderBase<ImageType> >
(new TIFFReader<ImageType>(filename));
else if(suffix == "jpg" || suffix == "jpeg")
return std::tr1::shared_ptr<ImageReaderBase<ImageType> >
(new JPEGReader<ImageType>(filename));
else throw InvalidFileFormatException();
}


file_format_collection degate::ImageReaderFactory< ImageType >::file_formats [private] |
Definition at line 52 of file ImageReaderFactory.h.
Referenced by degate::ImageReaderFactory< ImageType >::get_file_formats(), and degate::ImageReaderFactory< ImageType >::ImageReaderFactory().
1.7.4