diff options
| author | Carl Hetherington <cth@carlh.net> | 2013-01-09 21:41:06 +0000 |
|---|---|---|
| committer | Carl Hetherington <cth@carlh.net> | 2013-01-09 21:41:06 +0000 |
| commit | 7f8062032e16d9c9cfc28659a6da67f8205dc27b (patch) | |
| tree | e6315a838adcb34f3ac2cf2a517e84ea956e891d /src/lib | |
| parent | 29d863fb2533fe754a82a5274caf19a3b19e2994 (diff) | |
Basic cinema / screen database.
Diffstat (limited to 'src/lib')
| -rw-r--r-- | src/lib/cinema.h | 6 | ||||
| -rw-r--r-- | src/lib/config.cc | 30 | ||||
| -rw-r--r-- | src/lib/config.h | 15 |
3 files changed, 48 insertions, 3 deletions
diff --git a/src/lib/cinema.h b/src/lib/cinema.h index 232fc5ec8..02b38c496 100644 --- a/src/lib/cinema.h +++ b/src/lib/cinema.h @@ -14,10 +14,12 @@ public: class Cinema { public: - Cinema (std::string const & n) + Cinema (std::string const & n, std::string const & e) : name (n) + , email (e) {} std::string name; - std::list<Screen> screens; + std::string email; + std::list<boost::shared_ptr<Screen> > screens; }; diff --git a/src/lib/config.cc b/src/lib/config.cc index d19adc2a4..80d357e1a 100644 --- a/src/lib/config.cc +++ b/src/lib/config.cc @@ -27,11 +27,13 @@ #include "scaler.h" #include "filter.h" #include "sound_processor.h" +#include "cinema.h" using std::vector; using std::ifstream; using std::string; using std::ofstream; +using std::list; using boost::shared_ptr; Config* Config::_instance = 0; @@ -48,6 +50,9 @@ Config::Config () { ifstream f (file().c_str ()); string line; + + shared_ptr<Cinema> cinema; + while (getline (f, line)) { if (line.empty ()) { continue; @@ -91,8 +96,23 @@ Config::Config () _tms_password = v; } else if (k == "sound_processor") { _sound_processor = SoundProcessor::from_id (v); + } else if (k == "cinema") { + if (cinema) { + _cinemas.push_back (cinema); + } + cinema.reset (new Cinema (v, "")); + } else if (k == "cinema_email") { + assert (cinema); + cinema->email = v; + } else if (k == "screen") { + shared_ptr<Screen> s (new Screen (v)); + cinema->screens.push_back (s); } } + + if (cinema) { + _cinemas.push_back (cinema); + } } /** @return Filename to write configuration to */ @@ -140,7 +160,15 @@ Config::write () const f << "tms_path " << _tms_path << "\n"; f << "tms_user " << _tms_user << "\n"; f << "tms_password " << _tms_password << "\n"; - f << "sound_processor " << _sound_processor->id (); + f << "sound_processor " << _sound_processor->id () << "\n"; + + for (list<shared_ptr<Cinema> >::const_iterator i = _cinemas.begin(); i != _cinemas.end(); ++i) { + f << "cinema " << (*i)->name << "\n"; + f << "cinema_email " << (*i)->email << "\n"; + for (list<shared_ptr<Screen> >::iterator j = (*i)->screens.begin(); j != (*i)->screens.end(); ++j) { + f << "screen " << (*j)->name << "\n"; + } + } } string diff --git a/src/lib/config.h b/src/lib/config.h index 4575cb54d..2d5b82ac5 100644 --- a/src/lib/config.h +++ b/src/lib/config.h @@ -32,6 +32,7 @@ class ServerDescription; class Scaler; class Filter; class SoundProcessor; +class Cinema; /** @class Config * @brief A singleton class holding configuration. @@ -107,6 +108,10 @@ public: return _sound_processor; } + std::list<boost::shared_ptr<Cinema> > cinemas () const { + return _cinemas; + } + /** @param n New number of local encoding threads */ void set_num_local_encoding_threads (int n) { _num_local_encoding_threads = n; @@ -163,6 +168,14 @@ public: void set_tms_password (std::string p) { _tms_password = p; } + + void add_cinema (boost::shared_ptr<Cinema> c) { + _cinemas.push_back (c); + } + + void remove_cinema (boost::shared_ptr<Cinema> c) { + _cinemas.remove (c); + } void write () const; @@ -202,6 +215,8 @@ private: /** Our sound processor */ SoundProcessor const * _sound_processor; + std::list<boost::shared_ptr<Cinema> > _cinemas; + /** Singleton instance, or 0 */ static Config* _instance; }; |
