Move things round a bit.
[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
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         /** @return port to use for J2K encoding servers */
49         int server_port () const {
50                 return _server_port;
51         }
52
53         /** @return index of colour LUT to use when converting RGB to XYZ.
54          *  0: sRGB
55          *  1: Rec 709
56          *  2: DC28
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         /** @param n New number of local encoding threads */
101         void set_num_local_encoding_threads (int n) {
102                 _num_local_encoding_threads = n;
103                 Changed ();
104         }
105
106         /** @param p New server port */
107         void set_sever_port (int p) {
108                 _server_port = p;
109                 Changed ();
110         }
111
112         /** @param i New colour LUT index */
113         void set_colour_lut_index (int i) {
114                 _colour_lut_index = i;
115                 Changed ();
116         }
117
118         /** @param b New J2K bandwidth */
119         void set_j2k_bandwidth (int b) {
120                 _j2k_bandwidth = b;
121                 Changed ();
122         }
123
124         /** @param s New list of servers */
125         void set_servers (std::vector<Server*> s) {
126                 _servers = s;
127                 Changed ();
128         }
129
130         void set_screens (std::vector<boost::shared_ptr<Screen> > s) {
131                 _screens = s;
132                 Changed ();
133         }
134
135         void set_reference_scaler (Scaler const * s) {
136                 _reference_scaler = s;
137                 Changed ();
138         }
139         
140         void set_reference_filters (std::vector<Filter const *> const & f) {
141                 _reference_filters = f;
142                 Changed ();
143         }
144
145         void set_tms_ip (std::string i) {
146                 _tms_ip = i;
147                 Changed ();
148         }
149
150         void set_tms_path (std::string p) {
151                 _tms_path = p;
152                 Changed ();
153         }
154
155         void set_tms_user (std::string u) {
156                 _tms_user = u;
157                 Changed ();
158         }
159
160         void set_tms_password (std::string p) {
161                 _tms_password = p;
162                 Changed ();
163         }
164         
165         void write () const;
166
167         sigc::signal0<void> Changed;
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         /** port to use for J2K encoding servers */
178         int _server_port;
179         /** index of colour LUT to use when converting RGB to XYZ
180          *  (see colour_lut_index ())
181          */
182         int _colour_lut_index;
183         /** bandwidth for J2K files in Mb/s */
184         int _j2k_bandwidth;
185
186         /** J2K encoding servers to use */
187         std::vector<Server *> _servers;
188
189         /** Screen definitions */
190         std::vector<boost::shared_ptr<Screen> > _screens;
191
192         /** Scaler to use for the "A" part of A/B comparisons */
193         Scaler const * _reference_scaler;
194
195         /** Filters to use for the "A" part of A/B comparisons */
196         std::vector<Filter const *> _reference_filters;
197
198         std::string _tms_ip;
199         std::string _tms_path;
200         std::string _tms_user;
201         std::string _tms_password;
202
203         /** Singleton instance, or 0 */
204         static Config* _instance;
205 };
206
207 #endif