roo_prefs
API Documentation for roo_prefs
Loading...
Searching...
No Matches
transaction.h
Go to the documentation of this file.
1#pragma once
2
4
5namespace roo_prefs {
6
7/// Ref-counted RAII for managing access to Preference namespaces. Allows
8/// orchestrating access to the Store.
10 public:
11 Transaction(Collection& collection, bool read_only = false)
12 : collection_(collection) {
13 active_ = collection_.inc(read_only);
14 }
15
17 if (active_) collection_.dec();
18 }
19
20 bool active() const { return active_; }
21
22 Store& store() { return collection_.store_; }
23
24 private:
25 Collection& collection_;
26 bool active_;
27};
28
29} // namespace roo_prefs
Collection corresponds to a preferences namespace. Use it to group related preferences.
Definition collection.h:14
Low-level wrapper around the underlying preferences storage.
Ref-counted RAII for managing access to Preference namespaces. Allows orchestrating access to the Sto...
Definition transaction.h:9
Transaction(Collection &collection, bool read_only=false)
Definition transaction.h:11
Similar to Pref<T>, but does not immediately store written data in persistent storage....
Definition collection.h:6