]> git.ipfire.org Git - thirdparty/squid.git/blob - src/fs/ufs/StoreFSufs.h
SourceFormat Enforcement
[thirdparty/squid.git] / src / fs / ufs / StoreFSufs.h
1 /*
2 * Copyright (C) 1996-2015 The Squid Software Foundation and contributors
3 *
4 * Squid software is distributed under GPLv2+ license and includes
5 * contributions from numerous individuals and organizations.
6 * Please see the COPYING and CONTRIBUTORS files for details.
7 */
8
9 #ifndef SQUID_STOREFSUFS_H
10 #define SQUID_STOREFSUFS_H
11
12 /**
13 \defgroup UFS UFS Storage Filesystem
14 \ingroup FileSystems
15 */
16
17 #include "StoreFileSystem.h"
18
19 class DiskIOModule;
20
21 namespace Fs
22 {
23 namespace Ufs
24 {
25 /**
26 \ingroup UFS, FileSystems
27 *
28 * Core UFS class. This template provides compile time aliases for
29 * ufs/aufs/diskd to ease configuration conversion - each becomes a
30 * StoreFS module whose createSwapDir method parameterises the common
31 * UFSSwapDir with an IO module instance.
32 */
33 template <class TheSwapDir>
34 class StoreFSufs : public StoreFileSystem
35 {
36 public:
37 static StoreFileSystem &GetInstance();
38 StoreFSufs(char const *DefaultModuleType, char const *label);
39 virtual ~StoreFSufs() {}
40
41 virtual char const *type() const;
42 virtual SwapDir *createSwapDir();
43 virtual void done();
44 virtual void setup();
45 /** Not implemented */
46 StoreFSufs (StoreFSufs const &);
47 StoreFSufs &operator=(StoreFSufs const &);
48
49 protected:
50 DiskIOModule *IO;
51 char const *moduleName;
52 char const *label;
53 };
54
55 template <class C>
56 StoreFSufs<C>::StoreFSufs(char const *defaultModuleName, char const *aLabel) : IO(NULL), moduleName(defaultModuleName), label(aLabel)
57 {
58 FsAdd(*this);
59 }
60
61 template <class C>
62 char const *
63 StoreFSufs<C>::type() const
64 {
65 return label;
66 }
67
68 template <class C>
69 SwapDir *
70 StoreFSufs<C>::createSwapDir()
71 {
72 C *result = new C(type(), moduleName);
73 return result;
74 }
75
76 template <class C>
77 void
78 StoreFSufs<C>::done()
79 {
80 initialised = false;
81 }
82
83 template <class C>
84 void
85 StoreFSufs<C>::setup()
86 {
87 assert(!initialised);
88 initialised = true;
89 }
90
91 } /* namespace Ufs */
92 } /* namespace Fs */
93
94 #endif /* SQUID_STOREFSUFS_H */
95