Olympe Engine 2.0
2D Game Engine with ECS Architecture
Loading...
Searching...
No Matches
Public Member Functions | Static Public Member Functions | Private Member Functions | Private Attributes | List of all members
Olympe::LinkCache Class Reference

Singleton that caches per-node incoming/outgoing ExecPinConnection lists. More...

#include <LinkCache.h>

Public Member Functions

void Rebuild (const std::vector< ExecPinConnection > &connections)
 Rebuilds both outgoing and incoming maps from the supplied list.
 
void Invalidate ()
 Marks the cache as stale.
 
bool IsValid () const
 Returns true if the cache has been built and is not stale.
 
const std::vector< ExecPinConnection > & GetOutgoing (int nodeId) const
 Returns the list of connections that originate from nodeId.
 
const std::vector< ExecPinConnection > & GetIncoming (int nodeId) const
 Returns the list of connections that terminate at nodeId.
 
int GetConnectionCount () const
 Returns the total number of connections stored in the cache.
 

Static Public Member Functions

static LinkCacheGet ()
 Returns the single shared instance.
 

Private Member Functions

 LinkCache ()
 

Private Attributes

std::unordered_map< int, std::vector< ExecPinConnection > > m_Outgoing
 
std::unordered_map< int, std::vector< ExecPinConnection > > m_Incoming
 
std::vector< ExecPinConnectionm_EmptyList
 Returned for misses.
 
bool m_IsValid
 
int m_ConnectionCount
 

Detailed Description

Singleton that caches per-node incoming/outgoing ExecPinConnection lists.

Typical usage:

auto& lc = LinkCache::Get();
lc.Rebuild(myTemplate.ExecConnections);
const auto& out = lc.GetOutgoing(nodeId);
const auto& in = lc.GetIncoming(nodeId);
ComponentTypeID GetComponentTypeID_Static()
Definition ECS_Entity.h:56
static LinkCache & Get()
Returns the single shared instance.
Definition LinkCache.cpp:16

Definition at line 43 of file LinkCache.h.

Constructor & Destructor Documentation

◆ LinkCache()

Olympe::LinkCache::LinkCache ( )
private

Definition at line 22 of file LinkCache.cpp.

Member Function Documentation

◆ Get()

LinkCache & Olympe::LinkCache::Get ( )
static

Returns the single shared instance.

Definition at line 16 of file LinkCache.cpp.

◆ GetConnectionCount()

int Olympe::LinkCache::GetConnectionCount ( ) const

Returns the total number of connections stored in the cache.

Definition at line 79 of file LinkCache.cpp.

References m_ConnectionCount.

◆ GetIncoming()

const std::vector< ExecPinConnection > & Olympe::LinkCache::GetIncoming ( int  nodeId) const

Returns the list of connections that terminate at nodeId.

Returns an empty vector if the node has no incoming connections.

Definition at line 71 of file LinkCache.cpp.

References GetComponentTypeID_Static(), m_EmptyList, and m_Incoming.

+ Here is the call graph for this function:

◆ GetOutgoing()

const std::vector< ExecPinConnection > & Olympe::LinkCache::GetOutgoing ( int  nodeId) const

Returns the list of connections that originate from nodeId.

Returns an empty vector if the node has no outgoing connections.

Definition at line 63 of file LinkCache.cpp.

References GetComponentTypeID_Static(), m_EmptyList, and m_Outgoing.

+ Here is the call graph for this function:

◆ Invalidate()

void Olympe::LinkCache::Invalidate ( )

Marks the cache as stale.

The next Rebuild() call refreshes it.

Definition at line 49 of file LinkCache.cpp.

References m_IsValid.

◆ IsValid()

bool Olympe::LinkCache::IsValid ( ) const

Returns true if the cache has been built and is not stale.

Definition at line 54 of file LinkCache.cpp.

References m_IsValid.

◆ Rebuild()

void Olympe::LinkCache::Rebuild ( const std::vector< ExecPinConnection > &  connections)

Rebuilds both outgoing and incoming maps from the supplied list.

Parameters
connectionsFlat list of exec-pin connections (e.g. from a TaskGraphTemplate).

Definition at line 32 of file LinkCache.cpp.

References GetComponentTypeID_Static(), m_ConnectionCount, m_Incoming, m_IsValid, and m_Outgoing.

+ Here is the call graph for this function:

Member Data Documentation

◆ m_ConnectionCount

int Olympe::LinkCache::m_ConnectionCount
private

Definition at line 104 of file LinkCache.h.

Referenced by GetConnectionCount(), and Rebuild().

◆ m_EmptyList

std::vector<ExecPinConnection> Olympe::LinkCache::m_EmptyList
private

Returned for misses.

Definition at line 102 of file LinkCache.h.

Referenced by GetIncoming(), and GetOutgoing().

◆ m_Incoming

std::unordered_map<int, std::vector<ExecPinConnection> > Olympe::LinkCache::m_Incoming
private

Definition at line 101 of file LinkCache.h.

Referenced by GetIncoming(), and Rebuild().

◆ m_IsValid

bool Olympe::LinkCache::m_IsValid
private

Definition at line 103 of file LinkCache.h.

Referenced by Invalidate(), IsValid(), and Rebuild().

◆ m_Outgoing

std::unordered_map<int, std::vector<ExecPinConnection> > Olympe::LinkCache::m_Outgoing
private

Definition at line 100 of file LinkCache.h.

Referenced by GetOutgoing(), and Rebuild().


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