FlowArithmeticCalculator 1.0.0
Flow Arithmetic Calculator
Loading...
Searching...
No Matches
ConstantBlock.h
Go to the documentation of this file.
1#ifndef BUSINESS_LOGIC_ELEMENTS_IMPL_CONSTANT_BLOCK_H
2#define BUSINESS_LOGIC_ELEMENTS_IMPL_CONSTANT_BLOCK_H
3
6#include "logging/Loggable.h"
7#include "typenames.h"
8#include "utils/misc.h"
9
19 class ConstantBlock final : public business_logic::Loggable<ConstantBlock>,
22 public:
33 int cx,
34 int cy,
38
42 void onDoubleClick(int x, int y) override;
43
44 std::string getSelfId() const override { return selfId; }
45
46 void calculateOutputValues() override {
47 // do nothing
48 }
49
50 protected:
51 // since Loggable is a template base class, the compiler does not see Logger::logger in the
52 // current scope; so as not to use this->logger explicitly each time, the below brings it to
53 // the current scope explicitly
55
59 std::string selfId;
60
64 static constexpr int CONSTANT_BLOCK_WIDTH = 120;
65
69 static constexpr int CONSTANT_BLOCK_HEIGHT = 120;
70
74 const std::vector<business_logic::elements::structures::Port>& getInputPorts()
75 const override {
76 return inputPorts;
77 }
78
82 const std::vector<business_logic::elements::structures::Port>& getOutputPorts()
83 const override {
84 return outputPorts;
85 }
86
93
97 static const std::vector<business_logic::elements::structures::Port> inputPorts;
98
102 static const std::vector<business_logic::elements::structures::Port> outputPorts;
103 };
104} // namespace business_logic::elements::blocks
105
106#endif // BUSINESS_LOGIC_ELEMENTS_IMPL_CONSTANT_BLOCK_H
Class that provides a logger for the given class; automatically deduces the logger.
Definition Loggable.h:37
Delegate that is notified when a new block is chosen to be added to the canvas.
The base class for all blocks, containing common functionality and members.
Definition BaseBlock.h:36
business_logic::delegate::IBlockLifecycleManagerDelegate * blockLifecycleManagerDelegate
Definition BaseBlock.h:301
std::shared_ptr< spdlog::logger > logger
Definition BaseBlock.h:285
business_logic::delegate::INewBlockChoiceDelegate * newBlockChoiceDelegate
Definition BaseBlock.h:295
business_logic::delegate::IWindowDelegate * windowDelegate
Definition BaseBlock.h:307
A constant block that holds a constant value (scalar)
static const std::vector< business_logic::elements::structures::Port > inputPorts
const std::vector< business_logic::elements::structures::Port > & getOutputPorts() const override
Gets the output ports of the block.
business_logic::elements::blocks::BlockType getBlockType() const override
Gets the type of the block.
void calculateOutputValues() override
Calculates the output port values based on input port values.
void onDoubleClick(int x, int y) override
Called when the element is double-clicked.
const std::vector< business_logic::elements::structures::Port > & getInputPorts() const override
Gets the input ports of the block.
static const std::vector< business_logic::elements::structures::Port > outputPorts
Interface for elements that can be double-clicked.
The base classes and structs for elements.
BlockType
The available block types.
Definition BlockType.h:10