Open Lighting Architecture  0.9.2
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
UniverseStore.h
1 /*
2  * This program is free software; you can redistribute it and/or modify
3  * it under the terms of the GNU General Public License as published by
4  * the Free Software Foundation; either version 2 of the License, or
5  * (at your option) any later version.
6  *
7  * This program is distributed in the hope that it will be useful,
8  * but WITHOUT ANY WARRANTY; without even the implied warranty of
9  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
10  * GNU Library General Public License for more details.
11  *
12  * You should have received a copy of the GNU General Public License
13  * along with this program; if not, write to the Free Software
14  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
15  *
16  * UniverseStore.h
17  * The Universe Store class - this manages the universes
18  * Copyright (C) 2005 Simon Newton
19  */
20 
21 #ifndef OLAD_UNIVERSESTORE_H_
22 #define OLAD_UNIVERSESTORE_H_
23 
24 #include <map>
25 #include <set>
26 #include <string>
27 #include <vector>
28 
29 #include "ola/Clock.h"
30 #include "ola/base/Macro.h"
31 
32 namespace ola {
33 
34 class Universe;
35 
37  public:
38  UniverseStore(class Preferences *preferences, class ExportMap *export_map);
39  ~UniverseStore();
40 
41  Universe *GetUniverse(unsigned int universe_id) const;
42  Universe *GetUniverseOrCreate(unsigned int universe_id);
43 
44  unsigned int UniverseCount() const { return m_universe_map.size(); }
45  void GetList(std::vector<Universe*> *universes) const;
46 
47  void DeleteAll();
48  void AddUniverseGarbageCollection(Universe *universe);
49  void GarbageCollectUniverses();
50 
51  private:
52  typedef std::map<unsigned int, Universe*> universe_map;
53 
54  Preferences *m_preferences;
55  ExportMap *m_export_map;
56  // map of universe_id to Universe
57  universe_map m_universe_map;
58  std::set<Universe*> m_deletion_candiates; // list of universes we may be
59  // able to delete
60  Clock m_clock;
61 
62  bool RestoreUniverseSettings(Universe *universe) const;
63  bool SaveUniverseSettings(Universe *universe) const;
64 
65  static const unsigned int MINIMUM_RDM_DISCOVERY_INTERVAL;
66 
67  DISALLOW_COPY_AND_ASSIGN(UniverseStore);
68 };
69 } // namespace ola
70 #endif // OLAD_UNIVERSESTORE_H_