TODO.
[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 <sigc++/signal.h>
30
31 class Server;
32 class Screen;
33 class Scaler;
34 class Filter;
35 class SoundProcessor;
36
37 /** @class Config
38  *  @brief A singleton class holding configuration.
39  */
40 class Config
41 {
42 public:
43
44         /** @return number of threads to use for J2K encoding on the local machine */
45         int num_local_encoding_threads () const {
46                 return _num_local_encoding_threads;
47         }
48
49         /** @return port to use for J2K encoding servers */
50         int server_port () const {
51                 return _server_port;
52         }
53
54         /** @return index of colour LUT to use when converting RGB to XYZ.
55          *  0: sRGB
56          *  1: Rec 709
57          */
58         int colour_lut_index () const {
59                 return _colour_lut_index;
60         }
61
62         /** @return bandwidth for J2K files in bits per second */
63         int j2k_bandwidth () const {
64                 return _j2k_bandwidth;
65         }
66
67         /** @return J2K encoding servers to use */
68         std::vector<Server*> servers () const {
69                 return _servers;
70         }
71
72         std::vector<boost::shared_ptr<Screen> > screens () const {
73                 return _screens;
74         }
75
76         Scaler const * reference_scaler () const {
77                 return _reference_scaler;
78         }
79
80         std::vector<Filter const *> reference_filters () const {
81                 return _reference_filters;
82         }
83
84         std::string tms_ip () const {
85                 return _tms_ip;
86         }
87
88         std::string tms_path () const {
89                 return _tms_path;
90         }
91
92         std::string tms_user () const {
93                 return _tms_user;
94         }
95
96         std::string tms_password () const {
97                 return _tms_password;
98         }
99
100         SoundProcessor const * sound_processor () const {
101                 return _sound_processor;
102         }
103
104         /** @param n New number of local encoding threads */
105         void set_num_local_encoding_threads (int n) {
106                 _num_local_encoding_threads = n;
107                 Changed ();
108         }
109
110         /** @param p New server port */
111         void set_server_port (int p) {
112                 _server_port = p;
113                 Changed ();
114         }
115
116         /** @param i New colour LUT index */
117         void set_colour_lut_index (int i) {
118                 _colour_lut_index = i;
119                 Changed ();
120         }
121
122         /** @param b New J2K bandwidth */
123         void set_j2k_bandwidth (int b) {
124                 _j2k_bandwidth = b;
125                 Changed ();
126         }
127
128         /** @param s New list of servers */
129         void set_servers (std::vector<Server*> s) {
130                 _servers = s;
131                 Changed ();
132         }
133
134         void set_screens (std::vector<boost::shared_ptr<Screen> > s) {
135                 _screens = s;
136                 Changed ();
137         }
138
139         void set_reference_scaler (Scaler const * s) {
140                 _reference_scaler = s;
141                 Changed ();
142         }
143         
144         void set_reference_filters (std::vector<Filter const *> const & f) {
145                 _reference_filters = f;
146                 Changed ();
147         }
148
149         void set_tms_ip (std::string i) {
150                 _tms_ip = i;
151                 Changed ();
152         }
153
154         void set_tms_path (std::string p) {
155                 _tms_path = p;
156                 Changed ();
157         }
158
159         void set_tms_user (std::string u) {
160                 _tms_user = u;
161                 Changed ();
162         }
163
164         void set_tms_password (std::string p) {
165                 _tms_password = p;
166                 Changed ();
167         }
168         
169         void write () const;
170
171         sigc::signal0<void> Changed;
172
173         static Config* instance ();
174
175 private:
176         Config ();
177         std::string file () const;
178
179         /** number of threads to use for J2K encoding on the local machine */
180         int _num_local_encoding_threads;
181         /** port to use for J2K encoding servers */
182         int _server_port;
183         /** index of colour LUT to use when converting RGB to XYZ
184          *  (see colour_lut_index ())
185          */
186         int _colour_lut_index;
187         /** bandwidth for J2K files in bits per second */
188         int _j2k_bandwidth;
189
190         /** J2K encoding servers to use */
191         std::vector<Server *> _servers;
192
193         /** Screen definitions */
194         std::vector<boost::shared_ptr<Screen> > _screens;
195
196         /** Scaler to use for the "A" part of A/B comparisons */
197         Scaler const * _reference_scaler;
198
199         /** Filters to use for the "A" part of A/B comparisons */
200         std::vector<Filter const *> _reference_filters;
201
202         std::string _tms_ip;
203         std::string _tms_path;
204         std::string _tms_user;
205         std::string _tms_password;
206
207         SoundProcessor const * _sound_processor;
208
209         /** Singleton instance, or 0 */
210         static Config* _instance;
211 };
212
213 #endif