1 // Copyright (C) 2015 Thomas Voß <thomas.voss.bochum@gmail.com>
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.
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.
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/>.
18 #include <boost/filesystem.hpp>
25 // NotCopyable deletes the copy c'tor and the assignment operator.
28 NotCopyable() = default;
29 NotCopyable(const NotCopyable&) = delete;
30 virtual ~NotCopyable() = default;
31 NotCopyable& operator=(const NotCopyable&) = delete;
34 // NotMoveable deletes the move c'tor and the move assignment operator.
37 NotMoveable() = default;
38 NotMoveable(NotMoveable&&) = delete;
39 virtual ~NotMoveable() = default;
40 NotMoveable& operator=(NotMoveable&&) = delete;
43 // Data provides functions to query the XDG_DATA_* entries.
44 class Data : NotCopyable, NotMoveable
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
53 virtual std::vector<boost::filesystem::path> dirs() const;
56 // Config provides functions to query the XDG_CONFIG_* entries.
57 class Config : NotCopyable, NotMoveable
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;
69 // Cache provides functions to query the XDG_CACHE_HOME entry.
70 class Cache : NotCopyable, NotMoveable
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;
78 // Runtime provides functions to query the XDG_RUNTIME_DIR entry.
79 class Runtime : NotCopyable, NotMoveable
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;
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
93 // create returns an Implementation of BaseDirSpecification.
94 static std::shared_ptr<BaseDirSpecification> create();
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;
105 BaseDirSpecification() = default;
108 // data returns an immutable reference to a Data instance.
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();