Mobile API Reference  MicroStrategy 2019
UpdateableFileImpl.h
Go to the documentation of this file.
1 //==============================================================================================
2 // FILENAME : UpdateableFileImpl.h
3 // AUTHOR : vovechkin
4 // CREATION : 2004-10-04
5 // Copyright (C) MicroStrategy Incorporated 2004
6 // All Rights Reserved
7 //==============================================================================================
8 #ifndef MFileSystem_UpdateableFileImpl_h
9 #define MFileSystem_UpdateableFileImpl_h
10 
11 #include "Base/Base/String.h"
12 
13 #include "../UpdateableFile.h"
14 #include "FileImpl.h"
15 
16 #ifndef WIN32
17 #include "InprocessFileLocker.h"
18 #endif // WIN32
19 
20 namespace MFileSystem
21 {
23  virtual public UpdateableFile
24  {
25  public:
26 
28  const char* ipPath,
29  IF_COMMIT_AND_CLOSE_WAS_NOT_CALLED iWhatToDoIfCommitAndCloseWasNotCalled);
30 
31  virtual ~UpdateableFileImpl() throw();
32 
33  protected:
34 
36  virtual const char* GetPath() const;
37 
39  virtual bool IsAccessibleViaPath() const;
40 
42  virtual Int64 GetSize() const;
43 
45  virtual Int64 GetPosition() const;
46 
48  virtual void MovePosition(Int64 iOffset);
49 
51  virtual void SetPosition(Int64 iOffset);
52 
54  virtual Int64 SetPositionToEnd();
55 
56  protected:
57 
59  virtual void Read(void* ipBuffer, size_t iBufferSize);
60 
62  virtual void Read(MDataType::Binary& irBinary, size_t iMaxSize);
63 
65  virtual void ReadLittleEndian(unsigned Int32& orValue);
66 
68  virtual void ReadLine(MDataType::Binary& irBinary);
69 
71  virtual const MBase::TotalTimer& GetReadTimer() const;
72 
74  virtual const MBase::TotalTimer& GetReadLockTimer() const;
75 
77  virtual bool ReadLock(bool iNoWait);
78 
80  virtual void ReadUnlock() throw();
81 
82  protected:
83 
85  virtual void Write(const char* ipString, size_t iLength);
86 
88  virtual void Write(const void* ipData, size_t iByteLength);
89 
91  virtual void WriteLittleEndian(const unsigned Int32& irValue);
92 
94  virtual void Flush();
95 
97  virtual void Truncate();
98 
100  virtual void CommitAndClose();
101 
103  virtual const MBase::TotalTimer& GetWriteTimer() const;
104 
106  virtual const MBase::TotalTimer& GetWriteLockTimer() const;
107 
109  virtual bool WriteLock(bool iNoWait);
110 
112  virtual void WriteUnlock() throw();
113 
114  private:
115 
116  const IF_COMMIT_AND_CLOSE_WAS_NOT_CALLED mWhatToDoIfCommitAndCloseWasNotCalled;
117 
118  const std::string mPath;
119 
120  MFileSystem::FileHandle mFileHandle;
121 
122  // flags
123  bool mPendingFlush;
124  bool mPositionUndefined;
125  bool mReadLocked;
126  bool mWriteLocked;
127 
128  MBase::TotalTimer mReadTimer;
129  MBase::TotalTimer mReadLockTimer;
130 
131  MBase::TotalTimer mWriteTimer;
132  MBase::TotalTimer mWriteLockTimer;
133 
134 #ifndef WIN32
135  InprocessFileLocker::LockPtr mInprocessFileLockerPtr;
136 #endif // WIN32
137  };
138 }
139 
140 #endif // MFileSystem_UpdateableFileImpl_h
virtual void WriteLittleEndian(const unsigned Int32 &irValue)
Definition: Timer.h:91
virtual void SetPosition(Int64 iOffset)
MDataType::Binary represents binary data.
Definition: Binary.h:33
virtual Int64 GetPosition() const
virtual const MBase::TotalTimer & GetReadTimer() const
virtual Int64 GetSize() const
Definition: UpdateableFile.h:19
UpdateableFileImpl(const char *ipPath, IF_COMMIT_AND_CLOSE_WAS_NOT_CALLED iWhatToDoIfCommitAndCloseWasNotCalled)
#define Int64
Definition: BasicTypes.h:36
virtual void ReadLine(MDataType::Binary &irBinary)
Definition: UpdateableFileImpl.h:22
virtual const MBase::TotalTimer & GetWriteLockTimer() const
virtual bool IsAccessibleViaPath() const
virtual bool ReadLock(bool iNoWait)
Definition: InprocessFileLocker.h:41
#define Int32
Definition: BasicTypes.h:20
virtual const MBase::TotalTimer & GetReadLockTimer() const
virtual void Write(const char *ipString, size_t iLength)
virtual bool WriteLock(bool iNoWait)
IF_COMMIT_AND_CLOSE_WAS_NOT_CALLED
Definition: WriteableFile.h:19
virtual void MovePosition(Int64 iOffset)
virtual void ReadLittleEndian(unsigned Int32 &orValue)
virtual void Read(void *ipBuffer, size_t iBufferSize)
virtual const char * GetPath() const
int FileHandle
Definition: FileImpl.h:21
virtual const MBase::TotalTimer & GetWriteTimer() const
Definition: StrongObjects.h:21