FlowArithmeticCalculator 1.0.0
Flow Arithmetic Calculator
Loading...
Searching...
No Matches
business_logic::calculations::BlocksCalculator Class Reference

The blocks calculator logic, computes the flowing values. More...

#include <BlocksCalculator.h>

+ Inheritance diagram for business_logic::calculations::BlocksCalculator:
+ Collaboration diagram for business_logic::calculations::BlocksCalculator:

Public Member Functions

 BlocksCalculator (business_logic::calculations::delegate::IBlocksRegistryDelegate *blocksRegistryDelegate)
 
virtual ~BlocksCalculator () noexcept=default
 
 BlocksCalculator (const BlocksCalculator &)=delete
 
BlocksCalculatoroperator= (const BlocksCalculator &)=delete
 
 BlocksCalculator (BlocksCalculator &&)=delete
 
BlocksCalculatoroperator= (BlocksCalculator &&)=delete
 
void calculateValuesFlow ()
 Calculates the values flowing through the graph.
 
- Public Member Functions inherited from business_logic::Loggable< BlocksCalculator >
 Loggable ()
 

Protected Member Functions

void calculateBlockValues (business_logic::elements::blocks::BaseBlock *block)
 Calculates the values of the dependencies of a block and then the block itself.
 
std::optional< std::unordered_set< business_logic::elements::structures::BlocksConnectionSide > > hasCycle (elements::structures::BlocksConnectionSide side)
 Checks if there is a cycle in the graph.
 

Protected Attributes

std::unordered_set< business_logic::elements::structures::BlocksConnectionSidevisited
 The set of visited blocks to detect cycles.
 
std::unordered_set< business_logic::elements::structures::BlocksConnectionSiderecursionStack
 The stack of recursion to detect cycles.
 
std::unordered_set< business_logic::elements::blocks::BaseBlock * > calcVisited
 The set of visited blocks to note which blocks have been visited when calculating their values.
 
business_logic::calculations::delegate::IBlocksRegistryDelegateblocksRegistryDelegate
 The delegate that provides the connections registry.
 
- Protected Attributes inherited from business_logic::Loggable< BlocksCalculator >
std::shared_ptr< spdlog::logger > logger
 

Detailed Description

The blocks calculator logic, computes the flowing values.

Definition at line 20 of file BlocksCalculator.h.

Constructor & Destructor Documentation

◆ BlocksCalculator() [1/3]

business_logic::calculations::BlocksCalculator::BlocksCalculator ( business_logic::calculations::delegate::IBlocksRegistryDelegate blocksRegistryDelegate)
explicit

Definition at line 4 of file BlocksCalculator.cpp.

◆ ~BlocksCalculator()

virtual business_logic::calculations::BlocksCalculator::~BlocksCalculator ( )
virtualdefaultnoexcept

◆ BlocksCalculator() [2/3]

business_logic::calculations::BlocksCalculator::BlocksCalculator ( const BlocksCalculator )
delete

◆ BlocksCalculator() [3/3]

business_logic::calculations::BlocksCalculator::BlocksCalculator ( BlocksCalculator &&  )
delete

Member Function Documentation

◆ calculateBlockValues()

void business_logic::calculations::BlocksCalculator::calculateBlockValues ( business_logic::elements::blocks::BaseBlock block)
protected

Calculates the values of the dependencies of a block and then the block itself.

Definition at line 30 of file BlocksCalculator.cpp.

References blocksRegistryDelegate, calculateBlockValues(), business_logic::elements::blocks::BaseBlock::calculateOutputValues(), calcVisited, business_logic::calculations::delegate::IBlocksRegistryDelegate::getConnectionsRegistry(), and business_logic::elements::blocks::BaseBlock::setPortValue().

Referenced by calculateBlockValues(), and calculateValuesFlow().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ calculateValuesFlow()

void business_logic::calculations::BlocksCalculator::calculateValuesFlow ( )

Calculates the values flowing through the graph.

Exceptions
`business_logic::errors::GraphCycleException`if a cycle is detected

Definition at line 8 of file BlocksCalculator.cpp.

References blocksRegistryDelegate, calculateBlockValues(), calcVisited, business_logic::calculations::delegate::IBlocksRegistryDelegate::getBlocks(), hasCycle(), recursionStack, and visited.

Referenced by gui::elements::SkiaBlocksManagerRenderer::render().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ hasCycle()

std::optional< std::unordered_set< business_logic::elements::structures::BlocksConnectionSide > > business_logic::calculations::BlocksCalculator::hasCycle ( elements::structures::BlocksConnectionSide  side)
protected

Checks if there is a cycle in the graph.

Parameters
sideThe side to check for cycles
Returns
The cycle if found, otherwise std::nullopt

Definition at line 59 of file BlocksCalculator.cpp.

References business_logic::elements::structures::BlocksConnectionSide::block, blocksRegistryDelegate, business_logic::calculations::delegate::IBlocksRegistryDelegate::getConnectionsRegistry(), hasCycle(), recursionStack, and visited.

Referenced by calculateValuesFlow(), and hasCycle().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ operator=() [1/2]

BlocksCalculator & business_logic::calculations::BlocksCalculator::operator= ( BlocksCalculator &&  )
delete

◆ operator=() [2/2]

BlocksCalculator & business_logic::calculations::BlocksCalculator::operator= ( const BlocksCalculator )
delete

Member Data Documentation

◆ blocksRegistryDelegate

business_logic::calculations::delegate::IBlocksRegistryDelegate* business_logic::calculations::BlocksCalculator::blocksRegistryDelegate
protected

The delegate that provides the connections registry.

Definition at line 81 of file BlocksCalculator.h.

Referenced by calculateBlockValues(), calculateValuesFlow(), and hasCycle().

◆ calcVisited

std::unordered_set<business_logic::elements::blocks::BaseBlock*> business_logic::calculations::BlocksCalculator::calcVisited
protected

The set of visited blocks to note which blocks have been visited when calculating their values.

Definition at line 67 of file BlocksCalculator.h.

Referenced by calculateBlockValues(), and calculateValuesFlow().

◆ recursionStack

std::unordered_set<business_logic::elements::structures::BlocksConnectionSide> business_logic::calculations::BlocksCalculator::recursionStack
protected

The stack of recursion to detect cycles.

Definition at line 61 of file BlocksCalculator.h.

Referenced by calculateValuesFlow(), and hasCycle().

◆ visited

std::unordered_set<business_logic::elements::structures::BlocksConnectionSide> business_logic::calculations::BlocksCalculator::visited
protected

The set of visited blocks to detect cycles.

Definition at line 55 of file BlocksCalculator.h.

Referenced by calculateValuesFlow(), and hasCycle().


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