2 #include <boost/iterator/iterator_facade.hpp> 3 #include "creativity/state/StorageBackend.hpp" 4 #include <eris/types.hpp> 11 namespace boost {
namespace iterators {
struct random_access_traversal_tag; } }
13 namespace creativity {
struct CreativitySettings; }
38 template<
class SB,
class... Args>
39 static typename std::enable_if<std::is_base_of<StorageBackend, SB>::value, std::shared_ptr<Storage>>::type
41 return std::shared_ptr<Storage>(
new Storage(settings,
new SB(settings, std::forward<Args>(args)...)));
55 std::shared_ptr<const State> operator[](eris::eris_time_t t)
const;
63 void reserve(
size_t capacity);
73 void push_back(std::shared_ptr<const State> s);
82 void updateSettings();
89 template<
class... Args>
90 void emplace_back(Args&&... args);
105 void flush(
bool flush_buffers =
true);
123 bool flush_for(
long milliseconds,
bool flush_buffers =
true);
131 bool flush_on_destroy =
true;
137 class state_iterator :
public boost::iterator_facade<state_iterator, const std::shared_ptr<const State>, boost::random_access_traversal_tag> {
141 std::shared_ptr<const State> curr;
144 friend class boost::iterator_core_access;
148 reference dereference()
const;
151 void advance(difference_type n);
174 cache_.resize(backend_->size());
184 mutable std::vector<std::weak_ptr<const State>> cache_;
192 mutable std::shared_ptr<const State> cache_last_;
195 std::unique_ptr<StorageBackend> backend_;
200 bool need_settings_updated_ =
true;
203 template <
class... Args>
204 void Storage::emplace_back(Args&&... args) {
205 push_back(std::make_shared<State>(std::forward<Args>(args)...));
Primary namespace for all Creativity library code.
Definition: config.hpp:4
static std::enable_if< std::is_base_of< StorageBackend, SB >::value, std::shared_ptr< Storage > >::type create(CreativitySettings &settings, Args &&... args)
Storage constructor, which can construct a StorageBackend on the fly.
Definition: Storage.hpp:40
const CreativitySettings & settings
Read-only access to the settings object referenced by this object.
Definition: Storage.hpp:86
Class for state storage access which accesses State values.
Definition: Storage.hpp:27
Random access iterator class for iterating through states.
Definition: Storage.hpp:137
Simulation parameters that are used to configure the simulation when calling setup().
Definition: CreativitySettings.hpp:10
Base class for state storage which accesses State values.
Definition: StorageBackend.hpp:26