ALib C++ Library
Library Version: 2312 R0
Documentation generated by doxygen
Public Types | Inner Classes | Public Fields | Public Methods | Protected Fields | Protected Methods | List of all members
ScopeStore< T, TStackedThreadValues > Class Template Reference
Collaboration diagram for ScopeStore< T, TStackedThreadValues >:
[legend]

Class Description

template<typename T, bool TStackedThreadValues>
class aworx::lib::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 76 of file scopestore.inl.

Public Types

using LanguageStoreT = monomem::StringTree< T, StringTreeNamesMonoAlloc< character > >
 
using ThreadMapKey = std::pair< bool, threads::ThreadID >
 
using ThreadMapValueT = ATMP_IF_T_F(TStackedThreadValues, std::vector< T ALIB_COMMA StdContMA< T > >, T)
 

Inner Classes

struct  BoolThreadIDHash
 

Public Fields

globalStore
 
LanguageStoreT languageStore
 
HashMap< ThreadMapKey, ThreadMapValueT, BoolThreadIDHashthreadStore
 

Public Methods

ALIB_API ScopeStore (ScopeInfo &scopeInfo, monomem::MonoAllocator *monoAllocator)
 
ALIB_API ~ScopeStore ()
 
Get ()
 
ALIB_API void InitAccess (Scope scope, int pathLevel, threads::ThreadID threadID)
 
ALIB_API void InitWalk (Scope startScope, const T localObject)
 
Remove (T value)
 
ALIB_API void Reset ()
 
Store (T value)
 
Walk ()
 

Protected Fields

int actPathLevel
 
Scope actScope
 
LanguageStoreT::NodePtr actStringTreeNode
 
threads::ThreadID actThreadID
 
bool lazyLanguageNode
 
ScopeInfoscopeInfo
 
bool walking
 
walkLocalObject
 
int walkNextThreadIdx
 
ThreadMapValueTwalkThreadValues
 

Protected Methods

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

Member Typedef Documentation

◆ LanguageStoreT

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

◆ ThreadMapKey

using ThreadMapKey = std::pair<bool,threads::ThreadID>

Key type for the thread store.

Definition at line 170 of file scopestore.inl.

◆ ThreadMapValueT

using ThreadMapValueT = ATMP_IF_T_F(TStackedThreadValues, std::vector<T ALIB_COMMA StdContMA<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 160 of file scopestore.inl.

Constructor & Destructor Documentation

◆ ScopeStore()

ScopeStore ( ScopeInfo scopeInfo,
monomem::MonoAllocator monoAllocator 
)

Constructor

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

Definition at line 42 of file scopestore.cpp.

◆ ~ScopeStore()

~ScopeStore ( )

Destructor

Definition at line 51 of file scopestore.cpp.

Member Function Documentation

◆ access()

T access ( int  cmd,
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 348 of file scopestore.inl.

◆ Get()

T Get ( )
inline

Retrieves the value.

Returns
Returns the current value stored.

Definition at line 305 of file scopestore.inl.

◆ InitAccess()

void InitAccess ( Scope  scope,
int  pathLevel,
threads::ThreadID  threadID 
)

Initializes access methods Store, Get and Remove and has to be invoked prior to 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 530 of file scopestore.cpp.

◆ initNodePtr()

void initNodePtr ( 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 475 of file scopestore.cpp.

◆ InitWalk()

void 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 69 of file scopestore.cpp.

◆ Remove()

T Remove ( 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 296 of file scopestore.inl.

◆ Reset()

void Reset ( )

Deletes all data stored and resets containers as the monotonic allocator will be reset after an invocation to this method as well.

Note
This method is used only with Lox::Reset, which is only provided to reset a lox in the unit-tests.

Definition at line 60 of file scopestore.cpp.

◆ Store()

T Store ( value)
inline

Stores a new value.

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

Definition at line 284 of file scopestore.inl.

◆ Walk()

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

Member Data Documentation

◆ actPathLevel

int actPathLevel
protected

The path level when using access methods.

Definition at line 216 of file scopestore.inl.

◆ actScope

Scope actScope
protected

The actual scope of a walk.

Definition at line 210 of file scopestore.inl.

◆ actStringTreeNode

LanguageStoreT::NodePtr actStringTreeNode
protected

The actual language related scope's map node.

Definition at line 213 of file scopestore.inl.

◆ actThreadID

threads::ThreadID actThreadID
protected

Actual thread ID

Definition at line 220 of file scopestore.inl.

◆ globalStore

T globalStore

The value of the global scope.

Definition at line 163 of file scopestore.inl.

◆ languageStore

LanguageStoreT languageStore

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

Definition at line 166 of file scopestore.inl.

◆ lazyLanguageNode

bool lazyLanguageNode
protected

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

Definition at line 204 of file scopestore.inl.

◆ scopeInfo

ScopeInfo& scopeInfo
protected

ScopeInfo of 'our' lox.

Definition at line 201 of file scopestore.inl.

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

◆ walking

bool walking
protected

Indicates if currently a scope walk is active.

Definition at line 207 of file scopestore.inl.

◆ walkLocalObject

T walkLocalObject
protected

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

Definition at line 224 of file scopestore.inl.

◆ walkNextThreadIdx

int walkNextThreadIdx
protected

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

Definition at line 227 of file scopestore.inl.

◆ walkThreadValues

ThreadMapValueT* walkThreadValues
protected

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

Definition at line 230 of file scopestore.inl.


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