Flutter Impeller
impeller::CapturePlaybackList< Type > Class Template Reference

#include <capture.h>

Public Member Functions

 CapturePlaybackList ()=default
 
 ~CapturePlaybackList ()
 
void Rewind ()
 
size_t Count ()
 
std::shared_ptr< Type > GetNext (std::shared_ptr< Type > captured, bool force_overwrite)
 
std::shared_ptr< Type > FindFirstByLabel (const std::string &label)
 
void Iterate (std::function< void(Type &)> iterator) const
 

Detailed Description

template<typename Type>
class impeller::CapturePlaybackList< Type >

Definition at line 133 of file capture.h.

Constructor & Destructor Documentation

◆ CapturePlaybackList()

template<typename Type >
impeller::CapturePlaybackList< Type >::CapturePlaybackList ( )
default

◆ ~CapturePlaybackList()

template<typename Type >
impeller::CapturePlaybackList< Type >::~CapturePlaybackList ( )
inline

Definition at line 137 of file capture.h.

137  {
138  // Force the list element type to inherit the CRTP type. We can't enforce
139  // this as a template requirement directly because `CaptureElement` has a
140  // recursive `CaptureCursorList<CaptureElement>` property, and so the
141  // compiler fails the check due to the type being incomplete.
142  static_assert(std::is_base_of_v<CaptureCursorListElement<Type>, Type>);
143  }

Member Function Documentation

◆ Count()

template<typename Type >
size_t impeller::CapturePlaybackList< Type >::Count ( )
inline

Definition at line 147 of file capture.h.

147 { return values_.size(); }

◆ FindFirstByLabel()

template<typename Type >
std::shared_ptr<Type> impeller::CapturePlaybackList< Type >::FindFirstByLabel ( const std::string &  label)
inline

Definition at line 172 of file capture.h.

172  {
173  for (std::shared_ptr<Type>& value : values_) {
174  if (value->label == label) {
175  return value;
176  }
177  }
178  return nullptr;
179  }

◆ GetNext()

template<typename Type >
std::shared_ptr<Type> impeller::CapturePlaybackList< Type >::GetNext ( std::shared_ptr< Type >  captured,
bool  force_overwrite 
)
inline

Definition at line 149 of file capture.h.

150  {
151  if (cursor_ < values_.size()) {
152  std::shared_ptr<Type>& result = values_[cursor_];
153 
154  if (result->MatchesCloselyEnough(*captured)) {
155  if (force_overwrite) {
156  values_[cursor_] = captured;
157  }
158  // Safe playback is possible.
159  ++cursor_;
160  return result;
161  }
162  // The data has changed too much from the last capture to safely continue
163  // playback. Discard this and all subsequent elements to re-record.
164  values_.resize(cursor_);
165  }
166 
167  ++cursor_;
168  values_.push_back(captured);
169  return captured;
170  }

◆ Iterate()

template<typename Type >
void impeller::CapturePlaybackList< Type >::Iterate ( std::function< void(Type &)>  iterator) const
inline

Definition at line 181 of file capture.h.

181  {
182  for (auto& value : values_) {
183  iterator(*value);
184  }
185  }

◆ Rewind()

template<typename Type >
void impeller::CapturePlaybackList< Type >::Rewind ( )
inline

Definition at line 145 of file capture.h.

145 { cursor_ = 0; }

The documentation for this class was generated from the following file: