ifddir.h
00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022 #ifndef _OPENRAW_INTERNALS_IFDDIR_H
00023 #define _OPENRAW_INTERNALS_IFDDIR_H
00024
00025 #include <map>
00026
00027 #include <boost/config.hpp>
00028 #include <boost/shared_ptr.hpp>
00029 #include "ifdentry.h"
00030 #include "debug.h"
00031
00032 namespace OpenRaw {
00033 namespace Internals {
00034
00035 class IFDFileContainer;
00036
00037 class IFDDir
00038 {
00039 public:
00040 typedef boost::shared_ptr<IFDDir> Ref;
00041 typedef std::vector<Ref> RefVec;
00042 struct isPrimary
00043 {
00044 bool operator()(const Ref &dir);
00045 };
00046 struct isThumbnail
00047 {
00048 bool operator()(const Ref &dir);
00049 };
00050
00051 IFDDir(off_t _offset, IFDFileContainer & _container);
00052 virtual ~IFDDir();
00053
00055 off_t offset() const
00056 {
00057 return m_offset;
00058 }
00059
00061 bool load();
00063 int numTags()
00064 {
00065 return m_entries.size();
00066 }
00067 IFDEntry::Ref getEntry(uint16_t id) const ;
00068
00074 template <typename T>
00075 bool getValue(uint16_t id, T &v) const
00076 {
00077 bool success = false;
00078 IFDEntry::Ref e = getEntry(id);
00079 if (e != NULL) {
00080 try {
00081 v = IFDTypeTrait<T>::get(*e);
00082 success = true;
00083 }
00084 catch(const std::exception & ex) {
00085 Debug::Trace(ERROR) << "Exception raised " << ex.what()
00086 << " fetch value for " << id << "\n";
00087 }
00088 }
00089 return success;
00090 }
00091
00100 bool getIntegerValue(uint16_t id, uint32_t &v);
00101
00105 off_t nextIFD();
00106
00110 Ref getSubIFD(uint32_t idx = 0) const;
00115 bool getSubIFDs(std::vector<IFDDir::Ref> & ifds);
00116
00120 Ref getExifIFD();
00121 private:
00122 off_t m_offset;
00123 IFDFileContainer & m_container;
00124 std::map<uint16_t, IFDEntry::Ref> m_entries;
00125 };
00126
00127
00128 }
00129 }
00130
00131
00132 #endif
00133