StarBlockFactory

Search for usage in LXR

#include <starblockfactory.h>

Public Member Functions

 ~StarBlockFactory ()
 
int freeAll ()
 
int freeUnused ()
 
std::shared_ptr< StarBlockgetBlock ()
 
int getBlockCount () const
 
bool markFirst (std::shared_ptr< StarBlock > &block)
 
bool markNext (std::shared_ptr< StarBlock > &after, std::shared_ptr< StarBlock > &block)
 
void printStructure () const
 

Static Public Member Functions

static StarBlockFactoryInstance ()
 

Public Attributes

quint32 drawID
 

Detailed Description

A factory that creates StarBlocks and recycles them in an LRU Cache.

Author
Akarsh Simha
Version
0.1

Definition at line 21 of file starblockfactory.h.

Constructor & Destructor Documentation

◆ ~StarBlockFactory()

StarBlockFactory::~StarBlockFactory ( )

Destructor Deletes the linked list that maintains the Cache, sets the pointer to nullptr.

Definition at line 35 of file starblockfactory.cpp.

Member Function Documentation

◆ freeAll()

int StarBlockFactory::freeAll ( )
inline

Frees all StarBlocks that are in the cache.

Returns
The number of StarBlocks freed

Definition at line 73 of file starblockfactory.h.

◆ freeUnused()

int StarBlockFactory::freeUnused ( )

Frees all StarBlocks that are not used in this draw cycle.

Returns
The number of StarBlocks freed

Definition at line 287 of file starblockfactory.cpp.

◆ getBlock()

std::shared_ptr< StarBlock > StarBlockFactory::getBlock ( )

Return a StarBlock available for use.

This method first checks if there are any cached StarBlocks that are not in use. If such a StarBlock is found, it returns the same for use. Else it freshly allocates a StarBlock and returns the same. It also moves the StarBlock to the front, marking it as the most recently used. If the StarBlock had a parent StarBlockList, this method detaches the StarBlock from the StarBlockList

Returns
A StarBlock that is available for use

Definition at line 42 of file starblockfactory.cpp.

◆ getBlockCount()

int StarBlockFactory::getBlockCount ( ) const
inline

Returns the number of StarBlocks currently produced.

Returns
Number of StarBlocks currently allocated

Definition at line 67 of file starblockfactory.h.

◆ markFirst()

bool StarBlockFactory::markFirst ( std::shared_ptr< StarBlock > &  block)

Mark a StarBlock as most recently used and sync its drawID with the current drawID.

Returns
true on success, false if the StarBlock supplied was not on our list at all

Definition at line 82 of file starblockfactory.cpp.

◆ markNext()

bool StarBlockFactory::markNext ( std::shared_ptr< StarBlock > &  after,
std::shared_ptr< StarBlock > &  block 
)

Rank a given StarBlock after another given StarBlock in the LRU list and sync its drawID with the current drawID.

Parameters
afterThe block after which 'block' should be put
blockThe block to mark for use
Returns
true on success, false on failure

Definition at line 122 of file starblockfactory.cpp.

◆ printStructure()

void StarBlockFactory::printStructure ( ) const

Prints the structure of the cache, for debugging.

Definition at line 257 of file starblockfactory.cpp.


The documentation for this class was generated from the following files:
This file is part of the KDE documentation.
Documentation copyright © 1996-2022 The KDE developers.
Generated on Mon Aug 15 2022 04:04:09 by doxygen 1.8.17 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.