00001 /* ////////////////////////////////////////////////////////////////////////// 00002 // // 00003 // This code is Copyright (c) 2008-2010 LizardTech, Inc, 1008 Western // 00004 // Avenue, Suite 200, Seattle, WA 98104. Unauthorized use or distribution // 00005 // prohibited. Access to and use of this code is permitted only under // 00006 // license from LizardTech, Inc. Portions of the code are protected by // 00007 // US and foreign patents and other filings. All Rights Reserved. // 00008 // // 00010 /* PUBLIC */ 00011 00012 #ifndef __LIDAR_IO_H__ 00013 #define __LIDAR_IO_H__ 00014 00015 #include "lidar/Object.h" 00016 #include "lidar/Mutex.h" 00017 00018 LT_BEGIN_LIDAR_NAMESPACE 00019 00030 class IO : public Object 00031 { 00032 ABSTRACT_OBJECT(IO); 00033 public: 00037 typedef lt_int64 offset_type; 00038 00045 void open(void); 00052 void close(void); 00053 00064 virtual size_t pread(offset_type offset, 00065 void *buffer, 00066 size_t nbytes) const = 0; 00077 virtual size_t pwrite(offset_type offset, 00078 const void *buffer, 00079 size_t nbytes) const = 0; 00080 00086 virtual offset_type size(void) const = 0; 00087 00097 virtual void truncate(offset_type length) = 0; 00098 00104 virtual void unlink(void) = 0; 00105 00106 00111 struct Location 00112 { 00113 IO *io; 00114 offset_type offset; 00115 offset_type length; 00116 00117 ~Location(void); 00118 00119 Location(IO *io = NULL, offset_type offset = 0, offset_type length = 0); 00120 Location(const Location &rhs); 00121 Location &operator=(const Location &rhs); 00122 00123 void set(IO *io, offset_type offset, offset_type length); 00124 OVERRIDE_NEW; 00125 }; 00126 00127 protected: 00133 virtual void popen(void) = 0; 00139 virtual void pclose(void) = 0; 00140 00141 private: 00142 size_t m_openCount; 00143 Mutex m_mutex; 00144 }; 00145 00146 LT_END_LIDAR_NAMESPACE 00147 #endif // __LIDAR_IO_H__
LizardTech |