HoverRace  2.0
RulebookLibrary.h
Go to the documentation of this file.
1 
2 // RulebookLibrary.h
3 //
4 // Copyright (c) 2013-2016 Michael Imamura.
5 //
6 // Licensed under GrokkSoft HoverRace SourceCode License v1.0(the "License");
7 // you may not use this file except in compliance with the License.
8 //
9 // A copy of the license should have been attached to the package from which
10 // you have taken this file. If you can not find the license you can not use
11 // this file.
12 //
13 //
14 // The author makes no representations about the suitability of
15 // this software for any purpose. It is provided "as is" "AS IS",
16 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
17 // implied.
18 //
19 // See the License for the specific language governing permissions
20 // and limitations under the License.
21 
22 #pragma once
23 
24 namespace HoverRace {
25  namespace Client {
26  class Rulebook;
27  }
28  namespace Script {
29  class Core;
30  }
31 }
32 
33 namespace HoverRace {
34 namespace Client {
35 
41 public:
42  RulebookLibrary(Script::Core &scripting);
43 
44 public:
45  void Reload();
46  void Add(std::shared_ptr<Rulebook> &rulebook);
47  std::shared_ptr<const Rulebook> GetDefault() const;
48  std::shared_ptr<const Rulebook> Find(const std::string &name);
49 
50 private:
51  using sorted_t = std::set<
52  std::shared_ptr<const Rulebook>,
53  boost::less_pointees_t<std::shared_ptr<const Rulebook>>>;
54 public:
55  using const_iterator = sorted_t::const_iterator;
56  using value_type = sorted_t::value_type;
57 
58  const_iterator begin() const { return sorted.cbegin(); }
59  const_iterator end() const { return sorted.cend(); }
60  const_iterator cbegin() const { return sorted.cbegin(); }
61  const_iterator cend() const { return sorted.cend(); }
62 
63 private:
65  std::map<std::string, std::shared_ptr<Rulebook>> library;
67  std::shared_ptr<Rulebook> defaultRulebook;
68 };
69 
70 } // namespace Client
71 } // namespace HoverRace
const_iterator begin() const
Definition: RulebookLibrary.h:58
Script::Core & scripting
Definition: RulebookLibrary.h:64
sorted_t::const_iterator const_iterator
Definition: RulebookLibrary.h:55
const_iterator end() const
Definition: RulebookLibrary.h:59
const_iterator cend() const
Definition: RulebookLibrary.h:61
std::set< std::shared_ptr< const Rulebook >, boost::less_pointees_t< std::shared_ptr< const Rulebook >>> sorted_t
Definition: RulebookLibrary.h:53
sorted_t sorted
Definition: RulebookLibrary.h:66
const_iterator cbegin() const
Definition: RulebookLibrary.h:60
The collection of all registered rulebooks.
Definition: RulebookLibrary.h:40
std::map< std::string, std::shared_ptr< Rulebook > > library
Definition: RulebookLibrary.h:65
sorted_t::value_type value_type
Definition: RulebookLibrary.h:56
Definition: Announcement.h:24
std::shared_ptr< Rulebook > defaultRulebook
Definition: RulebookLibrary.h:67
A script environment.
Definition: Core.h:66