IPSDK  4_1_0_2
IPSDK : Image Processing Software Development Kit
RawImageFile.h
1 // RawImageFile.h:
3 // ---------------
4 //
13 
14 #ifndef __IPSDKIMAGEFILE_RAWIMAGEFILE_H__
15 #define __IPSDKIMAGEFILE_RAWIMAGEFILE_H__
16 
17 // suppression warnings
18 // warning C4251: 'ipsdk::image::file::RawImageFile::_stream' : class 'std::basic_fstream<_Elem,_Traits>' needs to have dll-interface to be used by clients of class 'ipsdk::image::file::RawImageFile'
19 #pragma warning (push)
20 #pragma warning (disable : 4251)
21 
23 #include <IPSDKImage/Accessor/BaseDiskImageAccessor.h>
24 #include <boost/tuple/tuple.hpp>
25 #include <boost/shared_ptr.hpp>
26 #include <boost/thread/mutex.hpp>
27 #include <boost/thread/thread.hpp>
28 #include <fstream>
29 #include <map>
30 #include <vector>
31 
32 namespace ipsdk {
33 namespace image {
34 namespace file {
35 
38 
40 {
41  // declare serial class
43 
44 public:
47  RawImageFile();
48  ~RawImageFile();
50 
51 // methods
52 public:
56  bool hasBinary8BitsStorage() const;
57 
60  BoolResult createFile(const boost::filesystem::path& filePath,
62  const std::string& headerData = std::string());
63 
66  BoolResult openFile(const boost::filesystem::path& filePath,
67  const eImageAccessMode& accessMode,
68  const ipUInt64 dataStartOffset,
70 
73  BoolResult openSharedRemoteFile(const boost::filesystem::path& filePath,
74  const eImageAccessMode& accessMode,
75  const ipUInt64 dataStartOffset,
77 
78 protected:
81  BoolResult openFileInternal(const boost::filesystem::path& filePath,
82  const eImageAccessMode& accessMode,
83  const ipUInt64 dataStartOffset,
85  const bool bSharedRemoteAccess);
86 
89  ipUInt64 processOffsets(const ipUInt64 dataStartOffset,
91 
94  BoolResult resizeData(const BaseImageGeometry& geometry);
95 
103  BoolResult readRawData(const ipUInt64 zPlanIdx,
104  const ipUInt64 cPlanIdx,
105  const ipUInt64 tPlanIdx,
106  const ipUInt64 pixelStartOffset,
107  const ipUInt64 nbPixels,
108  void* pData) const;
109 
117  BoolResult writeRawData(const ipUInt64 zPlanIdx,
118  const ipUInt64 cPlanIdx,
119  const ipUInt64 tPlanIdx,
120  const ipUInt64 pixelStartOffset,
121  const ipUInt64 nbPixels,
122  const void* pData);
123 
125  void clearDerived();
126 
128  typedef boost::shared_ptr<std::fstream> FStreamPtr;
129 
133  BoolResult findThreadFStream(FStreamPtr& pFStream) const;
134 
135 // attributes
136 protected:
138  typedef boost::tuple<ipUInt64, ipUInt64, ipUInt64> PlanIdentifier;
139 
141  typedef std::map<PlanIdentifier, ipUInt64> OffsetColl;
142 
145 
147  typedef std::map<boost::thread::id, FStreamPtr> FStreamColl;
148 
151 
153  void* _handle;
154 
156  mutable boost::mutex _mutex;
157 };
158 
161 
162 } // end of namespace file
163 } // end of namespace image
164 } // end of namespace ipsdk
165 
166 #pragma warning (pop)
167 
168 #endif // __IPSDKIMAGEFILE_RAWIMAGEFILE_H__
OffsetColl _offsetColl
collection of offset for each image plans
Definition: RawImageFile.h:144
Main namespace for IPSDK library.
Definition: AlgorithmFunctionEfficiency.h:22
Base class for image files accessors.
Definition: BaseDiskImageAccessor.h:31
uint64_t ipUInt64
Base types definition.
Definition: BaseTypes.h:55
#define IPSDKIMAGEFILE_API
Import/Export macro for library IPSDKImageFile.
Definition: IPSDKImageFileExports.h:27
Definition of import/export macro for library.
FStreamColl _fStreamColl
collection of thread file streams associated to object
Definition: RawImageFile.h:150
Base class for image geometry.
Definition: BaseImageGeometry.h:38
IPSDKIMAGE_API ImageGeometryPtr geometry(const eImageBufferType &imageBufferType, const ipUInt64 sizeX, const ipUInt64 sizeY, const VolumeGeometry &volumeGeometry, const ColorGeometry &colorGeometry, const TemporalGeometry &temporalGeometry)
create an image geometry
boost::tuple< ipUInt64, ipUInt64, ipUInt64 > PlanIdentifier
plan identifier composed of t, c and z indexes
Definition: RawImageFile.h:138
void * _handle
file handle used under windows
Definition: RawImageFile.h:153
std::map< boost::thread::id, FStreamPtr > FStreamColl
collection of file streams
Definition: RawImageFile.h:147
boost::mutex _mutex
mutex used for protection against thread concurrent accesses
Definition: RawImageFile.h:156
#define IPSDK_DECLARE_SERIAL_WITHOUT_COPY(libraryName, className)
macro enabling serialization on class
Definition: SerializationHdrMacro.h:79
boost::shared_ptr< std::fstream > FStreamPtr
shared pointer to file stream
Definition: RawImageFile.h:128
Class for raw disk image access.
Definition: RawImageFile.h:39
eImageAccessMode
Image access mode.
Definition: ImageTypes.h:110
std::map< PlanIdentifier, ipUInt64 > OffsetColl
collection of plan offsets definition
Definition: RawImageFile.h:141