This class is responsible for scope-related functionality of class Lox.
| T | The stored object type. |
| TStackedThreadValues | If true, values stored for thread scopes will be always replaced instead of appended. This is, for example, false for Log Data and Log Once and true for Scope Domains and Prefix Logables. |
Definition at line 77 of file scopestore.hpp.
#include <scopestore.hpp>
Inner Type Index: | |
| struct | BoolThreadIDHash |
Hash functor for std::pair<bool,ThreadID>. More... | |
Public Type Index: | |
| using | ThreadMapKey = std::pair<bool,threads::ThreadID> |
| Key type for the thread store. | |
| using | TLanguageStore |
| using | TThreadMapValue = std::conditional_t<TStackedThreadValues, StdVectorMA<T>, T> |
Public Field Index: | |
| T | globalStore |
| The value of the global scope. | |
| TLanguageStore | languageStore |
StringTree to store data for language-related scopes (path,source,method). | |
| HashMap< MonoAllocator, ThreadMapKey, TThreadMapValue, BoolThreadIDHash > | threadStore |
Public Method Index: | |
| ScopeStore (ScopeInfo &scopeInfo, MonoAllocator &monoAllocator) | |
| ~ScopeStore () | |
| Destructor. | |
| T | Get () |
| void | InitAccess (Scope scope, int pathLevel, threads::ThreadID threadID) |
| void | InitWalk (Scope startScope, const T localObject) |
| T | Remove (T value) |
| T | Store (T value) |
| T | Walk () |
Protected Field Index: | |
| int | actPathLevel |
| The path level when using access methods. | |
| Scope | actScope |
| The actual scope of a walk. | |
| TLanguageStore::Cursor | actStringTreeNode |
| The actual language related scope's map node. | |
| threads::ThreadID | actThreadID |
| Actual thread ID. | |
| bool | lazyLanguageNode |
| Flag used to lazily create the key to language-related scope values. | |
| ScopeInfo & | scopeInfo |
| ScopeInfo of 'our' lox. | |
| bool | walking |
| Indicates if currently a scope walk is active. | |
| T | walkLocalObject |
| The 'local object' returned by a walk after Scope::ThreadInner and before Scope::Method. | |
| int | walkNextThreadIdx |
| The next value of a walk during Scope::ThreadInner/Outer. | |
| TThreadMapValue * | walkThreadValues |
| The list of values of Scope::ThreadOuter/Inner during a walk. | |
Protected Method Index: | |
| T | access (int cmd, T value) |
| void | initCursor (bool create) |
| using alib::lox::detail::ScopeStore< T, TStackedThreadValues >::ThreadMapKey = std::pair<bool,threads::ThreadID> |
Key type for the thread store.
Definition at line 105 of file scopestore.hpp.
| using alib::lox::detail::ScopeStore< T, TStackedThreadValues >::TLanguageStore |
Alias name for the string tree template used for storing language-related data. The language store uses a StringTree with a monotonic allocator. This does not lead to memory leaks, because during the life-time of a Lox objects are only added, but never deleted. If a value is unset, the node is not deleted but set to a nulled value. This makes the language store very memory efficient (and fast).
Definition at line 88 of file scopestore.hpp.
| using alib::lox::detail::ScopeStore< T, TStackedThreadValues >::TThreadMapValue = std::conditional_t<TStackedThreadValues, StdVectorMA<T>, T> |
The type of object stored for the thread values. This depends on whether multiple (a stack of) values can be stored, which is not true for log data and log once, as those operate with hash maps.
Definition at line 95 of file scopestore.hpp.
|
protected |
The path level when using access methods.
Definition at line 147 of file scopestore.hpp.
|
protected |
The actual scope of a walk.
Definition at line 141 of file scopestore.hpp.
|
protected |
The actual language related scope's map node.
Definition at line 144 of file scopestore.hpp.
|
protected |
Actual thread ID.
Definition at line 151 of file scopestore.hpp.
| T alib::lox::detail::ScopeStore< T, TStackedThreadValues >::globalStore |
The value of the global scope.
Definition at line 98 of file scopestore.hpp.
| TLanguageStore alib::lox::detail::ScopeStore< T, TStackedThreadValues >::languageStore |
StringTree to store data for language-related scopes (path,source,method).
Definition at line 101 of file scopestore.hpp.
|
protected |
Flag used to lazily create the key to language-related scope values.
Definition at line 135 of file scopestore.hpp.
|
protected |
ScopeInfo of 'our' lox.
Definition at line 132 of file scopestore.hpp.
| HashMap<MonoAllocator, ThreadMapKey, TThreadMapValue, BoolThreadIDHash > alib::lox::detail::ScopeStore< T, TStackedThreadValues >::threadStore |
The inner/outer thread map of values. The boolean value of the key is true for the inner store and false for the outer.
Definition at line 122 of file scopestore.hpp.
|
protected |
Indicates if currently a scope walk is active.
Definition at line 138 of file scopestore.hpp.
|
protected |
The 'local object' returned by a walk after Scope::ThreadInner and before Scope::Method.
Definition at line 155 of file scopestore.hpp.
|
protected |
The next value of a walk during Scope::ThreadInner/Outer.
Definition at line 158 of file scopestore.hpp.
|
protected |
The list of values of Scope::ThreadOuter/Inner during a walk.
Definition at line 161 of file scopestore.hpp.
| alib::lox::detail::ScopeStore< T, TStackedThreadValues >::ScopeStore | ( | ScopeInfo & | scopeInfo, |
| MonoAllocator & | monoAllocator ) |
Constructor
| scopeInfo | The ScopeInfo singleton of 'our' Lox. |
| monoAllocator | The monotonic allocator used for the StringTree needed by member languageStore. |
Definition at line 17 of file scopestore.cpp.
| alib::lox::detail::ScopeStore< T, TStackedThreadValues >::~ScopeStore | ( | ) |
Destructor.
Definition at line 30 of file scopestore.cpp.
|
inlineprotected |
Receives, inserts or removes a value.
| cmd | 0= insert, 1= remove, 2= get. |
| value | The new value or the one to be removed. |
Definition at line 231 of file scopestore.hpp.
|
inline |
Retrieves the value.
Definition at line 202 of file scopestore.hpp.
| void alib::lox::detail::ScopeStore< T, TStackedThreadValues >::InitAccess | ( | Scope | scope, |
| int | pathLevel, | ||
| threads::ThreadID | threadID ) |
Initializes access methods Store, Get and Remove and has to be invoked before using them
| scope | Scope to use. |
| pathLevel | Used only if parameter scope equals Path to reference parent directories. Optional and defaults to 0. |
| threadID | ID of the associated thread (for thread-related scopes only). If UNDEFINED is given, the ID provided in scopeInfo is used. |
Definition at line 448 of file scopestore.cpp.
|
protected |
Retrieves and optionally creates an entry in the map that stores language-related scope information. The result is stored in field actStringTreeNode.
| create | If true, a non-existing entry is created. |
Definition at line 396 of file scopestore.cpp.
| void alib::lox::detail::ScopeStore< T, TStackedThreadValues >::InitWalk | ( | Scope | startScope, |
| const T | localObject ) |
Initializes a scope 'walk' by storing the given scope information and setting fields of our walk 'state-machine' to proper start values.
| startScope | The Scope to start searching for. |
| localObject | The 'local object' returned by a walk after Scope::ThreadInner and before Scope::Method |
Definition at line 37 of file scopestore.cpp.
|
inline |
Removes a value.
| value | The value to remove (must only be given for thread-related Scopes). |
Definition at line 198 of file scopestore.hpp.
|
inline |
Stores a new value.
| value | The value to set. |
Definition at line 193 of file scopestore.hpp.
|
inline |
Searches next value in the actual scope. While not found, moves walk state to next outer state and continues there.
Definition at line 216 of file scopestore.hpp.