All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
FireworksLocationRepository.h
1 // Copyright eeGeo Ltd (2012-2014), All Rights Reserved
2 
3 #pragma once
4 
5 #include "IFireworksLocationRepository.h"
6 #include "Fireworks.h"
7 #include "FireworksLocation.h"
8 #include "MortonKey.h"
9 #include "ICallback.h"
10 #include <vector>
11 #include <string>
12 #include <map>
13 
14 namespace Eegeo
15 {
16  namespace Fireworks
17  {
18  typedef Helpers::ICallback1<const IFireworksLocation&> TFireworkLocationAddedCallback;
19 
21  {
22  public:
23 
24  static const int BaseCellDepth;
25 
28 
29  void AddFireworksLocation(u32 uid, FireworksLocationConfiguration& location);
30  void RemoveFireworksLocation(u32 uid);
31 
32  void Clear();
33 
34  void GetLocationsAtMortonKey(const Streaming::MortonKey& key, std::vector<IFireworksLocation*> & out_locations);
35 
36  void RegisterFireworksAddedCallback(TFireworkLocationAddedCallback& callback);
37  void UnregisterFireworksAddedCallback(TFireworkLocationAddedCallback& callback);
38  void RegisterFireworksRemovedCallback(TFireworkLocationAddedCallback& callback);
39  void UnregisterFireworksRemovedCallback(TFireworkLocationAddedCallback& callback);
40 
41  private:
42 
43  void ValidateAndFindFireworksLocationForRemoval(u32 uid,
44  std::map<u32, FireworksLocation*>::iterator& out_iterator,
45  Streaming::MortonKey& out_key);
46  void ValidateLocationConfig(FireworksLocationConfiguration& locationConfig);
47  void CallLocationAddedCallbacks(const IFireworksLocation& location);
48  void CallLocationRemovedCallbacks(const IFireworksLocation& location);
49 
50  typedef std::vector<FireworksLocation*> TLocations;
51  std::map<u32, FireworksLocation*> m_uniqueIdToLocationMap;
52  std::map<Streaming::MortonKey, TLocations> m_mortonKeyToLocationsMap;
53 
54  std::vector<TFireworkLocationAddedCallback*> m_locationAddedCallbacks;
55  std::vector<TFireworkLocationAddedCallback*> m_locationRemovedCallbacks;
56  };
57  }
58 }