All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
ResourceObserver.h
1 // Copyright eeGeo Ltd (2012-2014), All Rights Reserved
2 
3 #pragma once
4 
5 #include "Types.h"
6 #include "IResourceObserver.h"
7 
8 #include "ICallback.h"
9 #include "CallbackCollection.h"
10 
11 
12 namespace Eegeo
13 {
14  namespace Labels
15  {
16  template<typename TResourceType>
17  class ResourceObserver : public virtual IResourceObserver<TResourceType>, private Eegeo::NonCopyable
18  {
19  public:
21  typedef typename BaseType::CallbackParamType CallbackParamType;
22  typedef typename BaseType::CallbackType CallbackType;
23 
24 
25  void RegisterAddedToSceneGraphCallback(CallbackType& callback)
26  {
27  m_addedToSceneGraphCallbacks.AddCallback(callback);
28  }
29 
30  void UnregisterAddedToSceneGraphCallback(CallbackType& callback)
31  {
32  m_addedToSceneGraphCallbacks.RemoveCallback(callback);
33  }
34 
35  void RegisterRemovedFromSceneGraphCallback(CallbackType& callback)
36  {
37  m_removedFromSceneGraphCallbacks.AddCallback(callback);
38  }
39 
40  void UnregisterRemovedFromSceneGraphCallback(CallbackType& callback)
41  {
42  m_removedFromSceneGraphCallbacks.RemoveCallback(callback);
43  }
44 
45  void RegisterResourceDeletedCallback(CallbackType& callback)
46  {
47  m_resourceDeletedCallbacks.AddCallback(callback);
48  }
49 
50  void UnregisterResourceDeletedCallback(CallbackType& callback)
51  {
52  m_resourceDeletedCallbacks.RemoveCallback(callback);
53  }
54 
55  void NotifyAddedToSceneGraph(CallbackParamType& resource)
56  {
57  m_addedToSceneGraphCallbacks.ExecuteCallbacks(resource);
58  }
59 
60  void NotifyRemovedFromSceneGraph(CallbackParamType& resource)
61  {
62  m_removedFromSceneGraphCallbacks.ExecuteCallbacks(resource);
63  }
64 
65  void NotifyResourceDeleted(CallbackParamType& resource)
66  {
67  m_resourceDeletedCallbacks.ExecuteCallbacks(resource);
68  }
69  private:
71 
72  TCallbackCollection m_addedToSceneGraphCallbacks;
73  TCallbackCollection m_removedFromSceneGraphCallbacks;
74  TCallbackCollection m_resourceDeletedCallbacks;
75  };
76  }
77 }