NitfResource.h

Go to the documentation of this file.
00001 /*
00002  * The information in this file is
00003  * Copyright(c) 2007 Ball Aerospace & Technologies Corporation
00004  * and is subject to the terms and conditions of the
00005  * GNU Lesser General Public License Version 2.1
00006  * The license text is available from   
00007  * http://www.gnu.org/licenses/lgpl.html
00008  */
00009 
00010 #ifndef NITFRESOURCE_H
00011 #define NITFRESOURCE_H
00012 
00013 #include "MessageLogResource.h"
00014 
00015 #include <string>
00016 
00017 class ossimNitfFile;
00018 class ossimImageHandler;
00019 class Progress;
00020 
00021 namespace Nitf
00022 {
00023    /**
00024     *  \cond INTERNAL
00025     * The %OssimFileObject is a trait object for use with the %Resource template.
00026     *
00027     * It provides capability for opening and closing NITF files with OSSIM.
00028     *
00029     * @see OssimFileResource
00030     */
00031    class OssimFileObject
00032    {
00033    public:
00034       struct Args
00035       {
00036          Args(std::string filename, std::string access = "r") :
00037             mFilename(filename),
00038             mAccess(access) {}
00039 
00040          std::string mFilename;
00041          std::string mAccess;
00042       };
00043 
00044       ossimNitfFile* obtainResource(const Args &args) const;
00045       void releaseResource(const Args& args, ossimNitfFile* pFile) const;
00046    };
00047    /// \endcond
00048 
00049    /**
00050     * This is a %Resource class that opens and closes NITF files with OSSIM.
00051    */
00052    class OssimFileResource : public Resource<ossimNitfFile, Nitf::OssimFileObject>
00053    {
00054    public:
00055       /**
00056        * Construct an object to represent a file to be opened with OSSIM.
00057        *
00058        * @param   filename
00059        *          The name of the file to open.
00060        * @param   args
00061        *          The access mode to open the file with.  These match the modes
00062        *          used with fopen().
00063        */
00064       OssimFileResource(const std::string& filename, const std::string& args = "r") :
00065          Resource<ossimNitfFile, Nitf::OssimFileObject>(OssimFileObject::Args(filename.c_str(), args.c_str())) {}
00066    };
00067 
00068    /**
00069     *  \cond INTERNAL
00070     * The %OssimImageHandlerObject is a trait object for use with the %Resource template.
00071     *
00072     * It provides capability for handling images with OSSIM.
00073     *
00074     * @see OssimFileResource
00075     */
00076    class OssimImageHandlerObject
00077    {
00078    public:
00079       struct Args
00080       {
00081          Args(const std::string& filename) :
00082             mFilename(filename) {}
00083 
00084          std::string mFilename;
00085       };
00086 
00087       ossimImageHandler* obtainResource(const Args& args) const;
00088       void releaseResource(const Args& args, ossimImageHandler* pHandler);
00089    };
00090    /// \endcond
00091 
00092    /**
00093     * This is a %Resource class that opens and closes images with OSSIM.
00094     */
00095    class OssimImageHandlerResource : public Resource<ossimImageHandler, Nitf::OssimImageHandlerObject>
00096    {
00097    public:
00098       /**
00099        * Construct an object to represent images within a file to be opened with OSSIM.
00100        *
00101        * @param   filename
00102        *          The name of the file to open.
00103        */
00104       OssimImageHandlerResource(const std::string& filename = "") : 
00105          Resource<ossimImageHandler, Nitf::OssimImageHandlerObject>(OssimImageHandlerObject::Args(filename)) {}
00106    };
00107 }
00108 #endif

Software Development Kit - Opticks 4.9.0 Build 16218