Merge master.
[dcpomatic.git] / src / lib / config.h
1 /*
2     Copyright (C) 2012 Carl Hetherington <cth@carlh.net>
3
4     This program is free software; you can redistribute it and/or modify
5     it under the terms of the GNU General Public License as published by
6     the Free Software Foundation; either version 2 of the License, or
7     (at your option) any later version.
8
9     This program is distributed in the hope that it will be useful,
10     but WITHOUT ANY WARRANTY; without even the implied warranty of
11     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12     GNU General Public License for more details.
13
14     You should have received a copy of the GNU General Public License
15     along with this program; if not, write to the Free Software
16     Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
17
18 */
19
20 /** @file src/config.h
21  *  @brief Class holding configuration.
22  */
23
24 #ifndef DVDOMATIC_CONFIG_H
25 #define DVDOMATIC_CONFIG_H
26
27 #include <vector>
28 #include <boost/shared_ptr.hpp>
29 #include <boost/signals2.hpp>
30
31 class ServerDescription;
32 class Scaler;
33 class Filter;
34 class SoundProcessor;
35
36 /** @class Config
37  *  @brief A singleton class holding configuration.
38  */
39 class Config
40 {
41 public:
42
43         /** @return number of threads to use for J2K encoding on the local machine */
44         int num_local_encoding_threads () const {
45                 return _num_local_encoding_threads;
46         }
47
48         std::string default_directory () const {
49                 return _default_directory;
50         }
51
52         std::string default_directory_or (std::string a) const;
53
54         /** @return port to use for J2K encoding servers */
55         int server_port () const {
56                 return _server_port;
57         }
58
59         /** @return index of colour LUT to use when converting RGB to XYZ.
60          *  0: sRGB
61          *  1: Rec 709
62          */
63         int colour_lut_index () const {
64                 return _colour_lut_index;
65         }
66
67         /** @return bandwidth for J2K files in bits per second */
68         int j2k_bandwidth () const {
69                 return _j2k_bandwidth;
70         }
71
72         /** @return J2K encoding servers to use */
73         std::vector<ServerDescription*> servers () const {
74                 return _servers;
75         }
76
77         Scaler const * reference_scaler () const {
78                 return _reference_scaler;
79         }
80
81         std::vector<Filter const *> reference_filters () const {
82                 return _reference_filters;
83         }
84
85         /** @return The IP address of a TMS that we can copy DCPs to */
86         std::string tms_ip () const {
87                 return _tms_ip;
88         }
89
90         /** @return The path on a TMS that we should write DCPs to */
91         std::string tms_path () const {
92                 return _tms_path;
93         }
94
95         /** @return User name to log into the TMS with */
96         std::string tms_user () const {
97                 return _tms_user;
98         }
99
100         /** @return Password to log into the TMS with */
101         std::string tms_password () const {
102                 return _tms_password;
103         }
104
105         /** @return The sound processor that we are using */
106         SoundProcessor const * sound_processor () const {
107                 return _sound_processor;
108         }
109
110         /** @param n New number of local encoding threads */
111         void set_num_local_encoding_threads (int n) {
112                 _num_local_encoding_threads = n;
113         }
114
115         void set_default_directory (std::string d) {
116                 _default_directory = d;
117         }
118
119         /** @param p New server port */
120         void set_server_port (int p) {
121                 _server_port = p;
122         }
123
124         /** @param i New colour LUT index */
125         void set_colour_lut_index (int i) {
126                 _colour_lut_index = i;
127         }
128
129         /** @param b New J2K bandwidth */
130         void set_j2k_bandwidth (int b) {
131                 _j2k_bandwidth = b;
132         }
133
134         /** @param s New list of servers */
135         void set_servers (std::vector<ServerDescription*> s) {
136                 _servers = s;
137         }
138
139         void set_reference_scaler (Scaler const * s) {
140                 _reference_scaler = s;
141         }
142         
143         void set_reference_filters (std::vector<Filter const *> const & f) {
144                 _reference_filters = f;
145         }
146
147         /** @param i IP address of a TMS that we can copy DCPs to */
148         void set_tms_ip (std::string i) {
149                 _tms_ip = i;
150         }
151
152         /** @param p Path on a TMS that we should write DCPs to */
153         void set_tms_path (std::string p) {
154                 _tms_path = p;
155         }
156
157         /** @param u User name to log into the TMS with */
158         void set_tms_user (std::string u) {
159                 _tms_user = u;
160         }
161
162         /** @param p Password to log into the TMS with */
163         void set_tms_password (std::string p) {
164                 _tms_password = p;
165         }
166         
167         void write () const;
168
169         static Config* instance ();
170
171 private:
172         Config ();
173         std::string file () const;
174
175         /** number of threads to use for J2K encoding on the local machine */
176         int _num_local_encoding_threads;
177         /** default directory to put new films in */
178         std::string _default_directory;
179         /** port to use for J2K encoding servers */
180         int _server_port;
181         /** index of colour LUT to use when converting RGB to XYZ
182          *  (see colour_lut_index ())
183          */
184         int _colour_lut_index;
185         /** bandwidth for J2K files in bits per second */
186         int _j2k_bandwidth;
187
188         /** J2K encoding servers to use */
189         std::vector<ServerDescription *> _servers;
190         /** Scaler to use for the "A" part of A/B comparisons */
191         Scaler const * _reference_scaler;
192         /** Filters to use for the "A" part of A/B comparisons */
193         std::vector<Filter const *> _reference_filters;
194         /** The IP address of a TMS that we can copy DCPs to */
195         std::string _tms_ip;
196         /** The path on a TMS that we should write DCPs to */
197         std::string _tms_path;
198         /** User name to log into the TMS with */
199         std::string _tms_user;
200         /** Password to log into the TMS with */
201         std::string _tms_password;
202         /** Our sound processor */
203         SoundProcessor const * _sound_processor;
204
205         /** Singleton instance, or 0 */
206         static Config* _instance;
207 };
208
209 #endif