ALib C++ Library
Library Version: 2510 R0
Documentation generated by doxygen
Loading...
Searching...
No Matches
alib::lox::detail::ScopeStore< T, TStackedThreadValues > Class Template Reference

Description:

template<typename T, bool TStackedThreadValues>
class alib::lox::detail::ScopeStore< T, TStackedThreadValues >

This class is responsible for scope-related functionality of class Lox.

Note
This is a pure internal helper-class. Documentation may be limited.
Template Parameters
TThe stored object type.
TStackedThreadValuesIf 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 81 of file scopestore.inl.

Collaboration diagram for alib::lox::detail::ScopeStore< T, TStackedThreadValues >:
[legend]

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, StdVectorMono<T>, T>
 

Public Field Index:

globalStore
 The value of the global scope.
 
TLanguageStore languageStore
 StringTree to store data for language-related scopes (path,source,method).
 
HashMap< MonoAllocator, ThreadMapKey, TThreadMapValue, BoolThreadIDHashthreadStore
 

Public Method Index:

ALIB_DLL ScopeStore (ScopeInfo &scopeInfo, MonoAllocator &monoAllocator)
 
ALIB_DLL ~ScopeStore ()
 Destructor.
 
Get ()
 
ALIB_DLL void InitAccess (Scope scope, int pathLevel, threads::ThreadID threadID)
 
ALIB_DLL void InitWalk (Scope startScope, const T localObject)
 
Remove (T value)
 
Store (T value)
 
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.
 
ScopeInfoscopeInfo
 ScopeInfo of 'our' lox.
 
bool walking
 Indicates if currently a scope walk is active.
 
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.
 
TThreadMapValuewalkThreadValues
 The list of values of Scope::ThreadOuter/Inner during a walk.
 

Protected Method Index:

access (int cmd, T value)
 
void initCursor (bool create)
 

Type Definition Details:

◆ ThreadMapKey

template<typename T, bool TStackedThreadValues>
using alib::lox::detail::ScopeStore< T, TStackedThreadValues >::ThreadMapKey = std::pair<bool,threads::ThreadID>

Key type for the thread store.

Definition at line 110 of file scopestore.inl.

◆ TLanguageStore

template<typename T, bool TStackedThreadValues>
using alib::lox::detail::ScopeStore< T, TStackedThreadValues >::TLanguageStore
Initial value:
T,
monomem::TMonoAllocator< lang::HeapAllocator > MonoAllocator
containers::StringTreeNamesAlloc< TChar > StringTreeNamesAlloc
Type alias in namespace alib.

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 93 of file scopestore.inl.

◆ TThreadMapValue

template<typename T, bool TStackedThreadValues>
using alib::lox::detail::ScopeStore< T, TStackedThreadValues >::TThreadMapValue = std::conditional_t<TStackedThreadValues, StdVectorMono<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 100 of file scopestore.inl.

Field Details:

◆ actPathLevel

template<typename T, bool TStackedThreadValues>
int alib::lox::detail::ScopeStore< T, TStackedThreadValues >::actPathLevel
protected

The path level when using access methods.

Definition at line 154 of file scopestore.inl.

◆ actScope

template<typename T, bool TStackedThreadValues>
Scope alib::lox::detail::ScopeStore< T, TStackedThreadValues >::actScope
protected

The actual scope of a walk.

Definition at line 148 of file scopestore.inl.

◆ actStringTreeNode

template<typename T, bool TStackedThreadValues>
TLanguageStore::Cursor alib::lox::detail::ScopeStore< T, TStackedThreadValues >::actStringTreeNode
protected

The actual language related scope's map node.

Definition at line 151 of file scopestore.inl.

◆ actThreadID

template<typename T, bool TStackedThreadValues>
threads::ThreadID alib::lox::detail::ScopeStore< T, TStackedThreadValues >::actThreadID
protected

Actual thread ID.

Definition at line 158 of file scopestore.inl.

◆ globalStore

template<typename T, bool TStackedThreadValues>
T alib::lox::detail::ScopeStore< T, TStackedThreadValues >::globalStore

The value of the global scope.

Definition at line 103 of file scopestore.inl.

◆ languageStore

template<typename T, bool TStackedThreadValues>
TLanguageStore alib::lox::detail::ScopeStore< T, TStackedThreadValues >::languageStore

StringTree to store data for language-related scopes (path,source,method).

Definition at line 106 of file scopestore.inl.

◆ lazyLanguageNode

template<typename T, bool TStackedThreadValues>
bool alib::lox::detail::ScopeStore< T, TStackedThreadValues >::lazyLanguageNode
protected

Flag used to lazily create the key to language-related scope values.

Definition at line 142 of file scopestore.inl.

◆ scopeInfo

template<typename T, bool TStackedThreadValues>
ScopeInfo& alib::lox::detail::ScopeStore< T, TStackedThreadValues >::scopeInfo
protected

ScopeInfo of 'our' lox.

Definition at line 139 of file scopestore.inl.

◆ threadStore

template<typename T, bool TStackedThreadValues>
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 129 of file scopestore.inl.

◆ walking

template<typename T, bool TStackedThreadValues>
bool alib::lox::detail::ScopeStore< T, TStackedThreadValues >::walking
protected

Indicates if currently a scope walk is active.

Definition at line 145 of file scopestore.inl.

◆ walkLocalObject

template<typename T, bool TStackedThreadValues>
T alib::lox::detail::ScopeStore< T, TStackedThreadValues >::walkLocalObject
protected

The 'local object' returned by a walk after Scope::ThreadInner and before Scope::Method.

Definition at line 162 of file scopestore.inl.

◆ walkNextThreadIdx

template<typename T, bool TStackedThreadValues>
int alib::lox::detail::ScopeStore< T, TStackedThreadValues >::walkNextThreadIdx
protected

The next value of a walk during Scope::ThreadInner/Outer.

Definition at line 165 of file scopestore.inl.

◆ walkThreadValues

template<typename T, bool TStackedThreadValues>
TThreadMapValue* alib::lox::detail::ScopeStore< T, TStackedThreadValues >::walkThreadValues
protected

The list of values of Scope::ThreadOuter/Inner during a walk.

Definition at line 168 of file scopestore.inl.

Constructor(s) / Destructor Details:

◆ ScopeStore()

template<typename T, bool TStackedThreadValues>
alib::lox::detail::ScopeStore< T, TStackedThreadValues >::ScopeStore ( ScopeInfo & scopeInfo,
MonoAllocator & monoAllocator )

Constructor

Parameters
scopeInfoThe ScopeInfo singleton of 'our' Lox.
monoAllocatorThe monotonic allocator used for the StringTree needed by member languageStore.

Definition at line 58 of file scopestore.cpp.

◆ ~ScopeStore()

template<typename T, bool TStackedThreadValues>
alib::lox::detail::ScopeStore< T, TStackedThreadValues >::~ScopeStore ( )

Destructor.

Definition at line 72 of file scopestore.cpp.

Method Details:

◆ access()

template<typename T, bool TStackedThreadValues>
T alib::lox::detail::ScopeStore< T, TStackedThreadValues >::access ( int cmd,
T value )
inlineprotected

Receives, inserts or removes a value.

Parameters
cmd0= insert, 1= remove, 2= get.
valueThe new value or the one to be removed.
Returns
Returns the previous value stored.

Definition at line 245 of file scopestore.inl.

Here is the call graph for this function:

◆ Get()

template<typename T, bool TStackedThreadValues>
T alib::lox::detail::ScopeStore< T, TStackedThreadValues >::Get ( )
inline

Retrieves the value.

Returns
Returns the current value stored.

Definition at line 213 of file scopestore.inl.

Here is the call graph for this function:

◆ InitAccess()

template<typename T, bool TStackedThreadValues>
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

Parameters
scopeScope to use.
pathLevelUsed only if parameter scope equals Scope::Path to reference parent directories. Optional and defaults to 0.
threadIDID of the associated thread (for thread-related scopes only). If threads::UNDEFINED is given, the ID provided in scopeInfo is used.

Definition at line 529 of file scopestore.cpp.

◆ initCursor()

template<typename T, bool TStackedThreadValues>
void alib::lox::detail::ScopeStore< T, TStackedThreadValues >::initCursor ( bool create)
protected

Retrieves and optionally creates an entry in the map that stores language-related scope information. The result is stored in field actStringTreeNode.

Parameters
createIf true, a non-existing entry is created.

Definition at line 474 of file scopestore.cpp.

Here is the call graph for this function:

◆ InitWalk()

template<typename T, bool TStackedThreadValues>
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.

Parameters
startScopeThe Scope to start searching for.
localObjectThe 'local object' returned by a walk after Scope::ThreadInner and before Scope::Method

Definition at line 82 of file scopestore.cpp.

◆ Remove()

template<typename T, bool TStackedThreadValues>
T alib::lox::detail::ScopeStore< T, TStackedThreadValues >::Remove ( T value)
inline

Removes a value.

Parameters
valueThe value to remove (must only be given for thread-related Scopes).
Returns
Returns the previous value stored.

Definition at line 209 of file scopestore.inl.

Here is the call graph for this function:

◆ Store()

template<typename T, bool TStackedThreadValues>
T alib::lox::detail::ScopeStore< T, TStackedThreadValues >::Store ( T value)
inline

Stores a new value.

Parameters
valueThe value to set.
Returns
Returns the previous value stored.

Definition at line 200 of file scopestore.inl.

Here is the call graph for this function:

◆ Walk()

template<typename T, bool TStackedThreadValues>
T alib::lox::detail::ScopeStore< T, TStackedThreadValues >::Walk ( )
inline

Searches next value in the actual scope. While not found, moves walk state to next outer state and continues there.

Returns
The next object found in the current or any next outer scope.

Definition at line 230 of file scopestore.inl.

Here is the call graph for this function:

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