30 pre_frame_callbacks_(*this),
31 post_frame_callbacks_(*this) {}
37 LOG(
ERROR) <<
"Frame::Begin() called while already in a frame.";
40 for (CallbackMap::const_iterator it = pre_frame_callbacks_.begin();
41 it != pre_frame_callbacks_.end(); ++it)
49 LOG(
ERROR) <<
"Frame::End() called while not in a frame.";
52 for (CallbackMap::const_iterator it = post_frame_callbacks_.begin();
53 it != post_frame_callbacks_.end(); ++it)
63 pre_frame_callbacks_[key] = callback;
69 post_frame_callbacks_[key] = callback;
73 CallbackMap::iterator it = pre_frame_callbacks_.find(key);
74 if (it != pre_frame_callbacks_.end()) {
75 pre_frame_callbacks_.erase(it);
82 CallbackMap::iterator it = post_frame_callbacks_.find(key);
83 if (it != post_frame_callbacks_.end()) {
84 post_frame_callbacks_.erase(it);
void AddPreFrameCallback(const std::string &key, const Callback &callback)
Adds a callback to be invoked when Begin() or End() is called.
bool RemovePreFrameCallback(const std::string &key)
Removes a callback added previously with AddPreFrameCallback() or AddPostFrameCallback(), identified by the key.
void Begin()
Begins a new frame.
void AddPostFrameCallback(const std::string &key, const Callback &callback)
#define LOG(severity)
Logs the streamed message unconditionally with a severity of severity.
void End()
Ends the current frame.
Frame()
The constructor initializes the frame counter to 0.
Copyright 2016 Google Inc.
std::function< void(const Frame &frame)> Callback
Callback that can be invoked at the beginning or end of a frame.
bool RemovePostFrameCallback(const std::string &key)