ifddir.h

00001 /*
00002  * libopenraw - ifddir.h
00003  *
00004  * Copyright (C) 2006-2007 Hubert Figuiere
00005  *
00006  * This library is free software; you can redistribute it and/or
00007  * modify it under the terms of the GNU Lesser General Public
00008  * License as published by the Free Software Foundation; either
00009  * version 2.1 of the License, or (at your option) any later version.
00010  *
00011  * This library is distributed in the hope that it will be useful,
00012  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00013  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00014  * Lesser General Public License for more details.
00015  *
00016  * You should have received a copy of the GNU Lesser General Public
00017  * License along with this library; if not, write to the Free Software
00018  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA
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 

Generated on Sun Mar 23 09:30:49 2008 for libopenraw by  doxygen 1.5.5