source: box/trunk/lib/raidfile/RaidFileController.h @ 2498

Revision 2498, 3.0 KB checked in by chris, 3 years ago (diff)

Change default location for config files from /etc/box to
/etc/boxbackup, thanks to Reinhard Tartler and the Debian Project.

  • Property svn:eol-style set to native
Line 
1// --------------------------------------------------------------------------
2//
3// File
4//              Name:    RaidFileController.h
5//              Purpose: Controls config and daemon comms for RaidFile classes
6//              Created: 2003/07/08
7//
8// --------------------------------------------------------------------------
9
10/*  NOTE: will log to local5: include a line like
11        local5.info                                             /var/log/raidfile
12        in /etc/syslog.conf
13*/
14
15#ifndef RAIDFILECONTROLLER__H
16#define RAIDFILECONTROLLER__H
17
18#include <string>
19#include <vector>
20
21// --------------------------------------------------------------------------
22//
23// Class
24//              Name:    RaidFileDiscSet
25//              Purpose: Describes a set of paritions for RAID like files.
26//                               Use as list of directories containing the files.
27//              Created: 2003/07/08
28//
29// --------------------------------------------------------------------------
30class RaidFileDiscSet : public std::vector<std::string>
31{
32public:
33        RaidFileDiscSet(int SetID, unsigned int BlockSize)
34                : mSetID(SetID),
35                  mBlockSize(BlockSize)
36        {
37        }
38        RaidFileDiscSet(const RaidFileDiscSet &rToCopy)
39                : std::vector<std::string>(rToCopy),
40                  mSetID(rToCopy.mSetID),
41                  mBlockSize(rToCopy.mBlockSize)
42        {
43        }
44       
45        ~RaidFileDiscSet()
46        {
47        }
48
49        int GetSetID() const {return mSetID;}
50       
51        int GetSetNumForWriteFiles(const std::string &rFilename) const;
52       
53        unsigned int GetBlockSize() const {return mBlockSize;}
54
55        // Is this disc set a non-RAID disc set? (ie files never get transformed to raid storage)
56        bool IsNonRaidSet() const {return 1 == size();}
57
58private:
59        int mSetID;
60        unsigned int mBlockSize;
61};
62
63class _RaidFileController;      // compiler warning avoidance
64
65// --------------------------------------------------------------------------
66//
67// Class
68//              Name:    RaidFileController
69//              Purpose: Manages the configuration of the RaidFile system, handles
70//                               communication with the daemon.
71//              Created: 2003/07/08
72//
73// --------------------------------------------------------------------------
74class RaidFileController
75{
76        friend class _RaidFileController;       // to avoid compiler warning
77private:
78        RaidFileController();
79        RaidFileController(const RaidFileController &rController);
80public:
81        ~RaidFileController();
82       
83public:
84        void Initialise(const std::string& rConfigFilename = 
85                "/etc/boxbackup/raidfile.conf");
86        int GetNumDiscSets() {return mSetList.size();}
87
88        // --------------------------------------------------------------------------
89        //
90        // Function
91        //              Name:    RaidFileController::GetController()
92        //              Purpose: Gets the one and only controller object.
93        //              Created: 2003/07/08
94        //
95        // --------------------------------------------------------------------------   
96        static RaidFileController &GetController() {return mController;}
97        RaidFileDiscSet &GetDiscSet(unsigned int DiscSetNum);
98
99        static std::string DiscSetPathToFileSystemPath(unsigned int DiscSetNum, const std::string &rFilename, int DiscOffset);
100       
101private:
102        std::vector<RaidFileDiscSet> mSetList;
103       
104        static RaidFileController mController;
105};
106
107#endif // RAIDFILECONTROLLER__H
108
Note: See TracBrowser for help on using the repository browser.