]> git.lyx.org Git - lyx.git/blob - src/support/package.h
a required file
[lyx.git] / src / support / package.h
1 // -*- C++ -*-
2 /**
3  * \file package.h
4  * This file is part of LyX, the document processor.
5  * Licence details can be found in the file COPYING.
6  *
7  * \author Angus Leeming
8  *
9  * Full author contact details are available in file CREDITS.
10  *
11  * A store of the paths to the various different directoies used
12  * by LyX. These paths differ markedly from one OS to another,
13  * following the local Windows, MacOS X or Posix conventions.
14  */
15 #ifndef LYX_PACHAGE_H
16 #define LYX_PACHAGE_H
17
18 #include <string>
19
20 namespace lyx {
21 namespace support {
22
23 class Package;
24
25 /** Initialise package() with the command line data.
26  *  This data is exactly as it was passed in the argv[] array.
27  *
28  *  @param command_line_arg0 argv[0], the name of the LyX executable
29  *  as passed on the command line.
30  *
31  *  @param command_line_system_support_dir, the LyX system dir,
32  *  as specified on the command line with "-sysdir <path to dir>".
33  *
34  *  @param command_line_user_support_dir, the LyX user dir,
35  *  as specified on the command line with "-userdir <path to dir>".
36  */
37 void init_package(std::string const & command_line_arg0,
38                   std::string const & command_line_system_support_dir,
39                   std::string const & command_line_user_support_dir);
40
41 /** Accessor to the global data.
42  *  Asserts that init_package() has been called first.
43  */
44 Package const & package();
45
46 class Package {
47 public:
48         /// Default constructor does not lead to the paths being set.
49         Package();
50
51         /** Called by init_package, above.
52          *  All paths will be initialized.
53          */
54         Package(std::string const & command_line_arg0,
55                 std::string const & command_line_system_support_dir,
56                 std::string const & command_line_user_support_dir);
57
58         /** The directory containing the LyX executable.
59          */
60         std::string const & binary_dir() const;
61
62         /** The top of the LyX source code tree.
63          *  Used by the GTK frontend when searching for .glade files.
64          */
65         std::string const & top_srcdir() const;
66
67         /** The path to the system-level support files
68          *  we're actually going to use.
69          */
70         std::string const & system_support() const;
71
72         /** The path to the autogenerated support files
73          *  when running in-place.
74          */
75         std::string const & build_support() const;
76
77         /** The path to the user-level support files.
78          */
79         std::string const & user_support() const;
80
81         /** The user_support directory was set explicitly using either
82          *  the -userdir command line switch or
83          *  the LYX_USERDIR_13x environment variable.
84          */
85         bool explicit_user_support() const;
86
87         /** The path to the locale directory.
88          */
89         std::string const & locale_dir() const;
90
91         /** The default document directory.
92          *  Can be reset by LyXRC.
93          */
94         std::string & document_dir() const;
95
96         /** The path to the temporary directory.
97          *  (Eg /tmp on *nix.)
98          *  Can be reset by LyXRC.
99          */
100         std::string & temp_dir() const;
101
102         /** Used when setting the user_support directory.
103          *  Used also when expanding "~/" or contracting to "~/". (filetools.C)
104          *  Used by the XForms file dialog.
105          *  Used in emergencyWrite (bufferlist.C) as one possible location
106          *  for the dump.
107          */
108         std::string const & home_dir() const;
109
110 private:
111         std::string binary_dir_;
112         std::string system_support_dir_;
113         std::string build_support_dir_;
114         std::string user_support_dir_;
115         std::string locale_dir_;
116         mutable std::string document_dir_;
117         mutable std::string temp_dir_;
118         std::string home_dir_;
119         bool explicit_user_support_dir_;
120 };
121
122
123 inline
124 Package::Package() {}
125
126 inline
127 std::string const & Package::binary_dir() const
128 {
129         return binary_dir_;
130 }
131
132 inline
133 std::string const & Package::system_support() const
134 {
135         return system_support_dir_;
136 }
137
138 inline
139 std::string const & Package::build_support() const
140 {
141         return build_support_dir_;
142 }
143
144 inline
145 std::string const & Package::user_support() const
146 {
147         return user_support_dir_;
148 }
149
150 inline
151 bool Package::explicit_user_support() const
152 {
153         return explicit_user_support_dir_;
154 }
155
156 inline
157 std::string const & Package::locale_dir() const
158 {
159         return locale_dir_;
160 }
161
162 inline
163 std::string & Package::document_dir() const
164 {
165         return document_dir_;
166 }
167
168 inline
169 std::string & Package::temp_dir() const
170 {
171         return temp_dir_;
172 }
173
174 inline
175 std::string const & Package::home_dir() const
176 {
177         return home_dir_;
178 }
179
180 } // namespace support
181 } // namespace lyx
182
183 #endif // LYX_PACHAGE_H