Mobile API Reference  MicroStrategy 2019
WriteableFile.h
Go to the documentation of this file.
1 //==============================================================================================
2 // FILENAME : WriteableFile.h
3 // AUTHOR : vovechkin
4 // CREATION : 2004-09-28
5 // Copyright (C) MicroStrategy Incorporated 2004
6 // All Rights Reserved
7 //==============================================================================================
8 #ifndef MFileSystem_WriteableFile_h
9 #define MFileSystem_WriteableFile_h
10 
11 #include "Base/Base/Timer.h"
12 
13 #include "FileSystem.h" // for FILE_SYSTEM_DLL_EXPORT
14 
15 #include "GenericFile.h"
16 
17 namespace MFileSystem
18 {
20  {
27  };
28 
33  virtual public GenericFile
34  {
35  public:
36 
39 
40  // virtual destructor is a must
41  virtual ~WriteableFile() throw()
42  {
43  }
44 
57  virtual void Write(const char* ipString, size_t iLength = 0) = 0;
58 
62  virtual void Write(const void* ipData, size_t iByteLength) = 0;
63 
67  virtual void WriteLittleEndian(const unsigned Int32& irValue) = 0;
68 
72  virtual void Flush() = 0;
73 
78  virtual void Truncate() = 0;
79 
85  virtual void CommitAndClose() = 0;
86 
90  virtual const MBase::TotalTimer& GetWriteTimer() const = 0;
91 
95  virtual const MBase::TotalTimer& GetWriteLockTimer() const = 0;
96 
101  {
102  public:
103  WriteSmartLock(WriteableFile& irWriteableFile);
104  ~WriteSmartLock() throw();
105 
106  void Unlock() throw();
107 
108  protected:
109 
110  WriteSmartLock();
111 
113  bool mIsLocked;
114  };
115 
133  public WriteSmartLock
134  {
135  public:
136 
137  WriteSmartLock_NoWait(WriteableFile& irWriteableFile);
138 
139  bool IsLocked() const throw()
140  {
141  return mIsLocked;
142  }
143  };
144 
145  protected:
146 
147  friend class WriteSmartLock;
148  friend class WriteSmartLock_NoWait;
149 
150  virtual bool WriteLock(bool iNoWait) = 0;
151  virtual void WriteUnlock() throw() = 0;
152  };
153 
160  const char* ipPath,
161  IF_COMMIT_AND_CLOSE_WAS_NOT_CALLED iWhatToDoIfCommitAndCloseWasNotCalled);
162 }
163 
164 #endif // MFileSystem_WriteableFile_h
DLL_FILE_SYSTEM_EXIM WriteableFile::ReturnPtr OpenWriteableFile(const char *ipPath, IF_COMMIT_AND_CLOSE_WAS_NOT_CALLED iWhatToDoIfCommitAndCloseWasNotCalled)
Definition: Timer.h:91
virtual void Truncate()=0
bool mIsLocked
Definition: WriteableFile.h:113
Definition: WriteableFile.h:32
virtual void WriteLittleEndian(const unsigned Int32 &irValue)=0
virtual void Flush()=0
Definition: WriteableFile.h:100
friend class WriteSmartLock_NoWait
Definition: WriteableFile.h:148
virtual bool WriteLock(bool iNoWait)=0
WriteableFile * mpWriteableFile
Definition: WriteableFile.h:112
virtual const MBase::TotalTimer & GetWriteTimer() const =0
friend class WriteSmartLock
Definition: WriteableFile.h:147
virtual void WriteUnlock()=0
#define Int32
Definition: BasicTypes.h:20
virtual const MBase::TotalTimer & GetWriteLockTimer() const =0
virtual void Write(const char *ipString, size_t iLength=0)=0
IF_COMMIT_AND_CLOSE_WAS_NOT_CALLED
Definition: WriteableFile.h:19
Definition: GenericFile.h:22
virtual void CommitAndClose()=0
MBase::ReturnPtr< WriteableFile > ReturnPtr
Definition: WriteableFile.h:38
virtual ~WriteableFile()
Definition: WriteableFile.h:41
MBase::StrongPtr< WriteableFile > Ptr
Definition: WriteableFile.h:37
Definition: StrongObjects.h:21
bool IsLocked() const
Definition: WriteableFile.h:139
Definition: ReturnPtr.h:22
#define DLL_FILE_SYSTEM_EXIM
Definition: FileSystem.h:11