Ion
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
frame.h
Go to the documentation of this file.
1 
18 #ifndef ION_GFXUTILS_FRAME_H_
19 #define ION_GFXUTILS_FRAME_H_
20 
21 #include <functional>
22 #include <string>
23 
24 #include "base/integral_types.h"
25 #include "ion/base/referent.h"
27 
28 namespace ion {
29 namespace gfxutils {
30 
33 class ION_API Frame : public base::Referent {
34  public:
37  typedef std::function<void(const Frame& frame)> Callback;
38 
40  Frame();
41 
44  uint64 GetCounter() const { return counter_; }
45  void ResetCounter() { counter_ = 0; }
46 
50  void Begin();
51 
55  void End();
56 
58  bool IsInFrame() const { return in_frame_; }
59 
62  void AddPreFrameCallback(const std::string& key, const Callback& callback);
63  void AddPostFrameCallback(const std::string& key, const Callback& callback);
64 
68  bool RemovePreFrameCallback(const std::string& key);
69  bool RemovePostFrameCallback(const std::string& key);
70 
71  private:
72  typedef base::AllocMap<std::string, Callback> CallbackMap;
73 
75  ~Frame() override;
76 
77  uint64 counter_;
78  bool in_frame_;
79  CallbackMap pre_frame_callbacks_;
80  CallbackMap post_frame_callbacks_;
81 };
82 
85 
86 } // namespace gfxutils
87 } // namespace ion
88 
89 #endif // ION_GFXUTILS_FRAME_H_
base::ReferentPtr< Frame >::Type FramePtr
Convenience typedef for shared pointer to a Frame.
Definition: frame.h:84
Thread-safe abstract base class.
Definition: referent.h:49
Frame manages an application-defined frame of execution.
Definition: frame.h:33
void ResetCounter()
Definition: frame.h:45
uint64 GetCounter() const
Gets/resets the frame counter.
Definition: frame.h:44
std::function< void(const Frame &frame)> Callback
Callback that can be invoked at the beginning or end of a frame.
Definition: frame.h:37
bool IsInFrame() const
Returns true if Begin() was called and End() was not.
Definition: frame.h:58
A SharedPtr is a smart shared pointer to an instance of some class that implements reference counting...
Definition: sharedptr.h:60