FlowArithmeticCalculator 1.0.0
Flow Arithmetic Calculator
Loading...
Searching...
No Matches
BlocksCalculator.h
Go to the documentation of this file.
1#ifndef BLOCKS_CALCULATOR_H
2#define BLOCKS_CALCULATOR_H
3
4#include <optional>
5#include <unordered_set>
6
11#include "logging/Loggable.h"
12
20 class BlocksCalculator : public business_logic::Loggable<BlocksCalculator> {
21 public:
24
25 virtual ~BlocksCalculator() noexcept = default;
26
27 // disable copy semantics
29 BlocksCalculator& operator=(const BlocksCalculator&) = delete;
30
31 // disable move semantics
33 BlocksCalculator& operator=(BlocksCalculator&&) = delete;
34
40
41 protected:
42 // since Loggable is a template base class, the compiler does not see Logger::logger in the
43 // current scope; so as not to use this->logger explicitly each time, the below brings it to
44 // the current scope explicitly
46
50 void calculateBlockValues(business_logic::elements::blocks::BaseBlock* block);
51
55 std::unordered_set<business_logic::elements::structures::BlocksConnectionSide> visited;
56
60 std::unordered_set<business_logic::elements::structures::BlocksConnectionSide>
62
67 std::unordered_set<business_logic::elements::blocks::BaseBlock*> calcVisited;
68
74 std::optional<
75 std::unordered_set<business_logic::elements::structures::BlocksConnectionSide>>
76 hasCycle(elements::structures::BlocksConnectionSide side);
77
81 business_logic::calculations::delegate::IBlocksRegistryDelegate* blocksRegistryDelegate;
82 };
83
84} // namespace business_logic::calculations
85#endif // BLOCKS_CALCULATOR_H
Class that provides a logger for the given class; automatically deduces the logger.
Definition Loggable.h:37
std::shared_ptr< spdlog::logger > logger
Definition Loggable.h:75
The blocks calculator logic, computes the flowing values.
void calculateValuesFlow()
Calculates the values flowing through the graph.
business_logic::calculations::delegate::IBlocksRegistryDelegate * blocksRegistryDelegate
The delegate that provides the connections registry.
std::unordered_set< business_logic::elements::structures::BlocksConnectionSide > recursionStack
The stack of recursion to detect cycles.
virtual ~BlocksCalculator() noexcept=default
std::optional< std::unordered_set< business_logic::elements::structures::BlocksConnectionSide > > hasCycle(elements::structures::BlocksConnectionSide side)
Checks if there is a cycle in the graph.
std::unordered_set< business_logic::elements::structures::BlocksConnectionSide > visited
The set of visited blocks to detect cycles.
void calculateBlockValues(business_logic::elements::blocks::BaseBlock *block)
Calculates the values of the dependencies of a block and then the block itself.
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.
The delegate for the blocks registry, allowing to get connections and blocks.
Utilities regarding calculation of values for the calculator itself.
The business logic module.
STL namespace.