source: box/trunk/lib/raidfile/RaidFileWrite.h @ 2543

Revision 2543, 1.9 KB checked in by chris, 3 years ago (diff)

Allow RaidFileWrite? to test that the reference count of an object is
correct before overwriting or deleting it.

  • Property svn:eol-style set to native
Line 
1// --------------------------------------------------------------------------
2//
3// File
4//              Name:    RaidFileWrite.h
5//              Purpose: Writing RAID like files
6//              Created: 2003/07/10
7//
8// --------------------------------------------------------------------------
9
10#ifndef RAIDFILEWRITE__H
11#define RAIDFILEWRITE__H
12
13#include <string>
14
15#include "IOStream.h"
16
17class RaidFileDiscSet;
18
19// --------------------------------------------------------------------------
20//
21// Class
22//              Name:    RaidFileWrite
23//              Purpose: Writing RAID like files
24//              Created: 2003/07/10
25//
26// --------------------------------------------------------------------------
27class RaidFileWrite : public IOStream
28{
29public:
30        RaidFileWrite(int SetNumber, const std::string &Filename);
31        RaidFileWrite(int SetNumber, const std::string &Filename, int refcount);
32        ~RaidFileWrite();
33private:
34        RaidFileWrite(const RaidFileWrite &rToCopy);
35
36public:
37        // IOStream interface
38        virtual int Read(void *pBuffer, int NBytes, int Timeout = IOStream::TimeOutInfinite);   // will exception
39        virtual void Write(const void *pBuffer, int NBytes);
40        virtual pos_type GetPosition() const;
41        virtual void Seek(pos_type Offset, int SeekType);
42        virtual void Close();           // will discard the file! Use commit instead.
43        virtual bool StreamDataLeft();
44        virtual bool StreamClosed();
45
46        // Extra bits
47        void Open(bool AllowOverwrite = false);
48        void Commit(bool ConvertToRaidNow = false);
49        void Discard();
50        void TransformToRaidStorage();
51        void Delete();
52        pos_type GetFileSize();
53        pos_type GetDiscUsageInBlocks();
54       
55        static void CreateDirectory(int SetNumber, const std::string &rDirName, bool Recursive = false, int mode = 0777);
56        static void CreateDirectory(const RaidFileDiscSet &rSet, const std::string &rDirName, bool Recursive = false, int mode = 0777);
57       
58private:
59
60private:
61        int mSetNumber;
62        std::string mFilename;
63        int mOSFileHandle;
64        int mRefCount;
65};
66
67#endif // RAIDFILEWRITE__H
68
Note: See TracBrowser for help on using the repository browser.