TYPE3
[iec.git] / src / type3_AndroidCloud / anbox-master / external / xdg / xdg.h
1 // Copyright (C) 2015 Thomas Voß <thomas.voss.bochum@gmail.com>
2 //
3 // This library is free software: you can redistribute it and/or modify
4 // it under the terms of the GNU Lesser General Public License as published
5 // by the Free Software Foundation, either version 3 of the License, or
6 // (at your option) any later version.
7 //
8 // This program is distributed in the hope that it will be useful,
9 // but WITHOUT ANY WARRANTY; without even the implied warranty of
10 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
11 // GNU General Public License for more details.
12 //
13 // You should have received a copy of the GNU Lesser General Public License
14 // along with this program.  If not, see <http://www.gnu.org/licenses/>.
15 #ifndef XDG_H_
16 #define XDG_H_
17
18 #include <boost/filesystem.hpp>
19
20 #include <string>
21 #include <vector>
22
23 namespace xdg
24 {
25 // NotCopyable deletes the copy c'tor and the assignment operator.
26 struct NotCopyable
27 {
28     NotCopyable() = default;
29     NotCopyable(const NotCopyable&) = delete;
30     virtual ~NotCopyable() = default;
31     NotCopyable& operator=(const NotCopyable&) = delete;
32 };
33
34 // NotMoveable deletes the move c'tor and the move assignment operator.
35 struct NotMoveable
36 {
37     NotMoveable() = default;
38     NotMoveable(NotMoveable&&) = delete;
39     virtual ~NotMoveable() = default;
40     NotMoveable& operator=(NotMoveable&&) = delete;
41 };
42
43 // Data provides functions to query the XDG_DATA_* entries.
44 class Data : NotCopyable, NotMoveable
45 {
46 public:
47     // home returns the base directory relative to which user specific
48     // data files should be stored.
49     virtual boost::filesystem::path home() const;
50     // dirs returns the preference-ordered set of base directories to
51     // search for data files in addition to the $XDG_DATA_HOME base
52     // directory.
53     virtual std::vector<boost::filesystem::path> dirs() const;
54 };
55
56 // Config provides functions to query the XDG_CONFIG_* entries.
57 class Config : NotCopyable, NotMoveable
58 {
59 public:
60     // home returns the base directory relative to which user specific
61     // configuration files should be stored.
62     virtual boost::filesystem::path home() const;
63     // dirs returns the preference-ordered set of base directories to
64     // search for configuration files in addition to the
65     // $XDG_CONFIG_HOME base directory.
66     virtual std::vector<boost::filesystem::path> dirs() const;
67 };
68
69 // Cache provides functions to query the XDG_CACHE_HOME entry.
70 class Cache : NotCopyable, NotMoveable
71 {
72 public:
73     // home returns the base directory relative to which user specific
74     // non-essential data files should be stored.
75     virtual boost::filesystem::path home() const;
76 };
77
78 // Runtime provides functions to query the XDG_RUNTIME_DIR entry.
79 class Runtime : NotCopyable, NotMoveable
80 {
81 public:
82     // home returns the base directory relative to which user-specific
83     // non-essential runtime files and other file objects (such as
84     // sockets, named pipes, ...) should be stored.
85     virtual boost::filesystem::path dir() const;
86 };
87
88 // A BaseDirSpecification implements the XDG base dir specification:
89 //   http://standards.freedesktop.org/basedir-spec/basedir-spec-latest.html
90 class BaseDirSpecification : NotCopyable, NotMoveable
91 {
92 public:
93     // create returns an Implementation of BaseDirSpecification.
94     static std::shared_ptr<BaseDirSpecification> create();
95
96     // data returns an immutable Data instance.
97     virtual const Data& data() const = 0;
98     // config returns an immutable Config instance.
99     virtual const Config& config() const = 0;
100     // cache returns an immutable Cache instance.
101     virtual const Cache& cache() const = 0;
102     // runtime returns an immutable Runtime instance.
103     virtual const Runtime& runtime() const = 0;
104 protected:
105     BaseDirSpecification() = default;
106 };
107
108 // data returns an immutable reference to a Data instance.
109 const Data& data();
110 // config returns an immutable reference to a Config instance.
111 const Config& config();
112 // cache returns an immutable reference to a Cache instance.
113 const Cache& cache();
114 // runtime returns an immutable reference to a Runtime instance.
115 const Runtime& runtime();
116 }
117
118 #endif // XDG_H_