| TerraLib 4.1

- Main Page
- Related Pages
- Modules
- Namespaces
- Classes
- Files
- Examples

- File List
- File Members

E:/Projetos_Primeiro_Semestre_2012/TerraView/terralib/src/terralib/kernel/TeMappedMemory.h
Go to the documentation of this file.

    00001 /************************************************************************************
    00002 TerraLib - a library for developing GIS applications.
    00003 Copyright � 2001-2007 INPE and Tecgraf/PUC-Rio.
    00004
    00005 This code is part of the TerraLib library.
    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 You should have received a copy of the GNU Lesser General Public
    00012 License along with this library.
    00013
    00014 The authors reassure the license terms regarding the warranties.
    00015 They specifically disclaim any warranties, including, but not limited to,
    00016 the implied warranties of merchantability and fitness for a particular purpose.
    00017 The library provided hereunder is on an "as is" basis, and the authors have no
    00018 obligation to provide maintenance, support, updates, enhancements, or modifications.
    00019 In no event shall INPE and Tecgraf / PUC-Rio be held liable to any party for direct,
    00020 indirect, special, incidental, or consequential damages arising out of the use
    00021 of this library and its documentation.
    00022 *************************************************************************************/
    00027 #ifndef TEMAPPEDMEMORY_H
    00028   #define TEMAPPEDMEMORY_H
    00029
    00030   #include "TeSharedPtr.h"
    00031   #include "TeDefines.h"
    00032
    00033   #include <string>
    00034
    00035   #if TePLATFORM == TePLATFORMCODE_MSWINDOWS
    00036     #include <windows.h>
    00037     #include <winbase.h>
    00038   #elif TePLATFORM == TePLATFORMCODE_LINUX || TePLATFORM == TePLATFORMCODE_AIX || TePLATFORM == TePLATFORMCODE_APPLE
    00039     #include <sys/mman.h>
    00040   #else
    00041     #error "ERROR: Unsupported platform"
    00042   #endif
    00043
    00049   class TL_DLL TeMappedMemory {
    00050     public :
    00051       typedef TeSharedPtr< TeMappedMemory > pointer;
    00052       typedef const TeSharedPtr< TeMappedMemory > const_pointer;
    00053
    00057       TeMappedMemory();
    00058
    00062       ~TeMappedMemory();
    00063
    00067       void reset();
    00068
    00076       bool reset( unsigned long int size, bool enabled );
    00077
    00089       bool reset( const std::string& filename, unsigned long int size,
    00090         bool keep_disk_file, bool enabled );
    00091
    00099       bool reset( const std::string& filename, bool enabled );
    00100
    00106       bool toggle( bool enabled );
    00107
    00113       void* getPointer() const;
    00114
    00120       std::string getFileName() const;
    00121
    00127       unsigned long int size() const;
    00128
    00129     protected :
    00130
    00131       #if TePLATFORM == TePLATFORMCODE_MSWINDOWS
    00132
    00136         HANDLE m_hFile_;
    00137
    00141         HANDLE m_hMapping_;
    00142
    00146         LPVOID m_lpszFile_;
    00147
    00148       #elif TePLATFORM == TePLATFORMCODE_LINUX || TePLATFORM == TePLATFORMCODE_AIX || TePLATFORM == TePLATFORMCODE_APPLE
    00149
    00153         int m_hFile_;
    00154
    00158         void* m_lpszFile_;
    00159
    00160       #else
    00161         #error "Unsuported platform"
    00162       #endif
    00163
    00168       bool mapping_is_active_;
    00169
    00175       std::string disk_file_name_;
    00176
    00181       unsigned long int curr_size_;
    00182
    00187       bool must_delete_file_;
    00188
    00193       void init();
    00194
    00201       bool createNewDiskFile( const std::string& filename,
    00202         unsigned long int size ) const;
    00203
    00208       std::string getLastErrorStr();
    00209
    00210     private :
    00211
    00216       TeMappedMemory( const TeMappedMemory& ) {};
    00217
    00222       const TeMappedMemory& operator=( const TeMappedMemory& )
    00223       {
    00224         return *this;
    00225       };
    00226   };
    00227
    00232 #endif

All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines