]> git.lyx.org Git - lyx.git/blob - src/support/Package.h
fix linking error in the frontend
[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 "support/FileName.h"
19
20 #include <string>
21
22 namespace lyx {
23 namespace support {
24
25 class Package;
26
27 /** When run in-place <build-dir>/src/lyx is one level up from
28  *  the <build-dir> whilst <build-dir>/src/tex2lyx/tex2lyx is
29  *  two levels up.
30  */
31 enum exe_build_dir_to_top_build_dir {
32         top_build_dir_is_one_level_up,
33         top_build_dir_is_two_levels_up
34 };
35
36
37 /** Initialise package() with the command line data.
38  *  This data is exactly as it was passed in the argv[] array.
39  *
40  *  @param command_line_arg0 argv[0], the name of the LyX executable
41  *  as passed on the command line.
42  *
43  *  @param command_line_system_support_dir, the LyX system dir,
44  *  as specified on the command line with "-sysdir <path to dir>".
45  *
46  *  @param command_line_user_support_dir, the LyX user dir,
47  *  as specified on the command line with "-userdir <path to dir>".
48  */
49 void init_package(std::string const & command_line_arg0,
50                   std::string const & command_line_system_support_dir,
51                   std::string const & command_line_user_support_dir,
52                   exe_build_dir_to_top_build_dir);
53
54 /** Accessor to the global data.
55  *  Asserts that init_package() has been called first.
56  */
57 Package const & package();
58
59 class Package {
60 public:
61         /// Default constructor does not lead to the paths being set.
62         Package();
63
64         /** Called by init_package, above.
65          *  All paths will be initialized.
66          */
67         Package(std::string const & command_line_arg0,
68                 std::string const & command_line_system_support_dir,
69                 std::string const & command_line_user_support_dir,
70                 exe_build_dir_to_top_build_dir);
71
72         /** The directory containing the LyX executable.
73          */
74         FileName const & binary_dir() const;
75
76         /** The top of the LyX source code tree.
77          */
78         static FileName const & top_srcdir();
79
80         /** The path to the system-level support files
81          *  we're actually going to use.
82          */
83         FileName const & system_support() const;
84
85         /** The path to the autogenerated support files
86          *  when running in-place.
87          */
88         FileName const & build_support() const;
89
90         /** The path to the user-level support files.
91          */
92         FileName const & user_support() const;
93
94         /** The user_support directory was set explicitly using either
95          *  the -userdir command line switch or
96          *  the LYX_USERDIR_15x environment variable.
97          */
98         bool explicit_user_support() const;
99
100         /** The path to the locale directory.
101          */
102         FileName const & locale_dir() const;
103
104         /** The default document directory.
105          *  Can be reset by LyXRC.
106          */
107         FileName & document_dir() const;
108
109         /** The path to the system temporary directory.
110          *  (Eg /tmp on *nix.)
111          */
112         FileName const & system_temp_dir() const;
113
114         /** The path to the temporary directory used by LyX.
115          *  (Eg /tmp/lyx_tmpdir800nBI1z9 on *nix.)
116          *  Can be reset by LyXRC.
117          */
118         FileName & temp_dir() const;
119
120         /** Used when setting the user_support directory.
121          *  Used also when expanding "~/" or contracting to "~/". (filetools.cpp)
122          *  Used in emergencyWrite (BufferList.cpp) as one possible location
123          *  for the dump.
124          *  This may be empty (e. g. when run under a CGI environment)
125          */
126         FileName const & home_dir() const;
127
128         /** Command to run the configure script.
129          *  Caution: This is "ready-to-run", i.e. in the locale encoding, not
130          *  utf8.
131          */
132         std::string const & configure_command() const;
133
134 private:
135         FileName binary_dir_;
136         FileName system_support_dir_;
137         FileName build_support_dir_;
138         FileName user_support_dir_;
139         FileName locale_dir_;
140         mutable FileName document_dir_;
141         mutable FileName temp_dir_;
142         FileName system_temp_dir_;
143         FileName home_dir_;
144         std::string configure_command_;
145         bool explicit_user_support_dir_;
146 };
147
148
149 inline
150 Package::Package() {}
151
152 inline
153 FileName const & Package::binary_dir() const
154 {
155         return binary_dir_;
156 }
157
158 inline
159 FileName const & Package::system_support() const
160 {
161         return system_support_dir_;
162 }
163
164 inline
165 FileName const & Package::build_support() const
166 {
167         return build_support_dir_;
168 }
169
170 inline
171 FileName const & Package::user_support() const
172 {
173         return user_support_dir_;
174 }
175
176 inline
177 bool Package::explicit_user_support() const
178 {
179         return explicit_user_support_dir_;
180 }
181
182 inline
183 FileName const & Package::locale_dir() const
184 {
185         return locale_dir_;
186 }
187
188 inline
189 FileName & Package::document_dir() const
190 {
191         return document_dir_;
192 }
193
194 inline
195 FileName & Package::temp_dir() const
196 {
197         return temp_dir_;
198 }
199
200 inline
201 FileName const & Package::system_temp_dir() const
202 {
203         return system_temp_dir_;
204 }
205
206 inline
207 FileName const & Package::home_dir() const
208 {
209         return home_dir_;
210 }
211
212 inline
213 std::string const & Package::configure_command() const
214 {
215         return configure_command_;
216 }
217
218 } // namespace support
219 } // namespace lyx
220
221 #endif // LYX_PACHAGE_H