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::ConnectionCache Class Reference

Singleton cache mapping connection IDs to Bezier control points. More...

#include <ConnectionCache.h>

+ Collaboration diagram for Olympe::ConnectionCache:

Public Member Functions

bool HasCached (int connectionId) const
 Returns true if Bezier points are stored for connectionId.
 
const BezierPointsGetBezier (int connectionId) const
 Returns the cached Bezier points for connectionId.
 
void SetBezier (int connectionId, const BezierPoints &pts)
 Stores or overwrites the Bezier points for connectionId.
 
void Invalidate (int connectionId)
 Removes the cached entry for connectionId.
 
void InvalidateAll ()
 Clears all cached entries.
 
size_t GetCacheSize () const
 Returns the number of entries currently in the cache.
 

Static Public Member Functions

static ConnectionCacheGet ()
 Returns the single shared instance.
 

Private Member Functions

 ConnectionCache ()
 

Private Attributes

std::map< int, BezierPointsm_Cache
 
BezierPoints m_DefaultBezier
 Returned when ID is not in cache.
 

Detailed Description

Singleton cache mapping connection IDs to Bezier control points.

Typical usage:

if (!cc.HasCached(connId))
{
cc.SetBezier(connId, pts);
}
const BezierPoints& pts = cc.GetBezier(connId);
ComponentTypeID GetComponentTypeID_Static()
Definition ECS_Entity.h:56
static ConnectionCache & Get()
Returns the single shared instance.
Four cubic Bezier control points (P0..P3).

Definition at line 58 of file ConnectionCache.h.

Constructor & Destructor Documentation

◆ ConnectionCache()

Olympe::ConnectionCache::ConnectionCache ( )
private

Definition at line 28 of file ConnectionCache.cpp.

References m_DefaultBezier.

Member Function Documentation

◆ Get()

ConnectionCache & Olympe::ConnectionCache::Get ( )
static

Returns the single shared instance.

Definition at line 18 of file ConnectionCache.cpp.

◆ GetBezier()

const BezierPoints & Olympe::ConnectionCache::GetBezier ( int  connectionId) const

Returns the cached Bezier points for connectionId.

Returns a default (zero-initialised) BezierPoints if not cached.

Definition at line 42 of file ConnectionCache.cpp.

References GetComponentTypeID_Static(), m_Cache, and m_DefaultBezier.

+ Here is the call graph for this function:

◆ GetCacheSize()

size_t Olympe::ConnectionCache::GetCacheSize ( ) const

Returns the number of entries currently in the cache.

Definition at line 65 of file ConnectionCache.cpp.

References m_Cache.

◆ HasCached()

bool Olympe::ConnectionCache::HasCached ( int  connectionId) const

Returns true if Bezier points are stored for connectionId.

Definition at line 37 of file ConnectionCache.cpp.

References GetComponentTypeID_Static(), and m_Cache.

+ Here is the call graph for this function:

◆ Invalidate()

void Olympe::ConnectionCache::Invalidate ( int  connectionId)

Removes the cached entry for connectionId.

Definition at line 55 of file ConnectionCache.cpp.

References GetComponentTypeID_Static(), and m_Cache.

+ Here is the call graph for this function:

◆ InvalidateAll()

void Olympe::ConnectionCache::InvalidateAll ( )

Clears all cached entries.

Definition at line 60 of file ConnectionCache.cpp.

References m_Cache.

◆ SetBezier()

void Olympe::ConnectionCache::SetBezier ( int  connectionId,
const BezierPoints pts 
)

Stores or overwrites the Bezier points for connectionId.

Definition at line 50 of file ConnectionCache.cpp.

References GetComponentTypeID_Static(), and m_Cache.

+ Here is the call graph for this function:

Member Data Documentation

◆ m_Cache

std::map<int, BezierPoints> Olympe::ConnectionCache::m_Cache
private

◆ m_DefaultBezier

BezierPoints Olympe::ConnectionCache::m_DefaultBezier
private

Returned when ID is not in cache.

Definition at line 110 of file ConnectionCache.h.

Referenced by ConnectionCache(), and GetBezier().


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