Skip to content

Commit

Permalink
expr: Added more final and const
Browse files Browse the repository at this point in the history
  • Loading branch information
Petr Laštovička committed May 11, 2022
1 parent 7d50517 commit a74783b
Show file tree
Hide file tree
Showing 11 changed files with 97 additions and 74 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -10,28 +10,30 @@ namespace cz::lastaapps::vimxel::expr {
using ST = shared_ptr<Term>;

// sum
struct SumNode : public MultiOpNumOrAreaNode {
struct SumNode final : public MultiOpNumOrAreaNode {
using MultiOpNumOrAreaNode::MultiOpNumOrAreaNode;
string getName() const override;
ST getValue() override;
ST getValue() const override;
private:
void addTerm(ST term, long double& sum) const;
};
// max
struct MaxNode : public MultiOpNumOrAreaNode {
struct MaxNode final : public MultiOpNumOrAreaNode {
using MultiOpNumOrAreaNode::MultiOpNumOrAreaNode;
string getName() const override;
ST getValue() override;
ST getValue() const override;
};
// min
struct MinNode : public MultiOpNumOrAreaNode {
struct MinNode final : public MultiOpNumOrAreaNode {
using MultiOpNumOrAreaNode::MultiOpNumOrAreaNode;
string getName() const override;
ST getValue() override;
ST getValue() const override;
};
// avg
struct AvgNode : public MultiOpNumOrAreaNode {
struct AvgNode final : public MultiOpNumOrAreaNode {
using MultiOpNumOrAreaNode::MultiOpNumOrAreaNode;
string getName() const override;
ST getValue() override;
ST getValue() const override;
};
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,17 +12,21 @@ using ST = shared_ptr<Term>;

class BinOpNode : public OperatorNode {
protected:
ST mLeft, mRight;
const ST mLeft, mRight;
public:
BinOpNode(Node * left, Node * right);
};

struct BinOpNumNode : public BinOpNode {
BinOpNumNode(Node * left, Node * right);
using BinOpNode::BinOpNode;
shared_ptr<DoubleTerm> castedLeft() const;
shared_ptr<DoubleTerm> castedRight() const;
};

struct BinOpTextNode : public BinOpNode {
BinOpTextNode(Node * left, Node * right);
using BinOpNode::BinOpNode;
shared_ptr<TextTerm> castedLeft() const;
shared_ptr<TextTerm> castedRight() const;
};
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,52 +11,52 @@ namespace cz::lastaapps::vimxel::expr {
using ST = shared_ptr<Term>;

// sin
struct SinNode : public UnOpNumNode {
struct SinNode final : public UnOpNumNode {
using UnOpNumNode::UnOpNumNode;
string getName() const override;
ST getValue() override;
ST getValue() const override;
};
// cos
struct CosNode : public UnOpNumNode {
struct CosNode final : public UnOpNumNode {
using UnOpNumNode::UnOpNumNode;
string getName() const override;
ST getValue() override;
ST getValue() const override;
};
// tan
struct TanNode : public UnOpNumNode {
struct TanNode final : public UnOpNumNode {
using UnOpNumNode::UnOpNumNode;
string getName() const override;
ST getValue() override;
ST getValue() const override;
};
// cot
struct CotNode : public UnOpNumNode {
struct CotNode final : public UnOpNumNode {
using UnOpNumNode::UnOpNumNode;
string getName() const override;
ST getValue() override;
ST getValue() const override;
};
// arcsin
struct ArcsinNode : public UnOpNumNode {
struct ArcsinNode final : public UnOpNumNode {
using UnOpNumNode::UnOpNumNode;
string getName() const override;
ST getValue() override;
ST getValue() const override;
};
// arccos
struct ArccosNode : public UnOpNumNode {
struct ArccosNode final : public UnOpNumNode {
using UnOpNumNode::UnOpNumNode;
string getName() const override;
ST getValue() override;
ST getValue() const override;
};
// arctan
struct ArctanNode : public UnOpNumNode {
struct ArctanNode final : public UnOpNumNode {
using UnOpNumNode::UnOpNumNode;
string getName() const override;
ST getValue() override;
ST getValue() const override;
};
// arccot
struct ArccotNode : public UnOpNumNode {
struct ArccotNode final : public UnOpNumNode {
using UnOpNumNode::UnOpNumNode;
string getName() const override;
ST getValue() override;
ST getValue() const override;
};
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,46 +11,46 @@ namespace cz::lastaapps::vimxel::expr {
using ST = shared_ptr<Term>;

// pow
struct PowNode : public BinOpNumNode {
struct PowNode final : public BinOpNumNode {
using BinOpNumNode::BinOpNumNode;
string getName() const override;
ST getValue() override;
ST getValue() const override;
};
// sqrt
struct SqrtNode : public BinOpNumNode {
struct SqrtNode final : public BinOpNumNode {
using BinOpNumNode::BinOpNumNode;
string getName() const override;
ST getValue() override;
ST getValue() const override;
};
// abs
struct AbsNode : public UnOpNumNode {
struct AbsNode final : public UnOpNumNode {
using UnOpNumNode::UnOpNumNode;
string getName() const override;
ST getValue() override;
ST getValue() const override;
};
// e
struct ENode : public UnOpNumNode {
struct ENode final : public UnOpNumNode {
using UnOpNumNode::UnOpNumNode;
string getName() const override;
ST getValue() override;
ST getValue() const override;
};
// ln
struct LnNode : public UnOpNumNode {
struct LnNode final : public UnOpNumNode {
using UnOpNumNode::UnOpNumNode;
string getName() const override;
ST getValue() override;
ST getValue() const override;
};
// log2
struct Log2Node : public UnOpNumNode {
struct Log2Node final : public UnOpNumNode {
using UnOpNumNode::UnOpNumNode;
string getName() const override;
ST getValue() override;
ST getValue() const override;
};
// log10
struct Log10Node : public UnOpNumNode {
struct Log10Node final : public UnOpNumNode {
using UnOpNumNode::UnOpNumNode;
string getName() const override;
ST getValue() override;
ST getValue() const override;
};
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,35 +10,35 @@ using namespace std;
namespace cz::lastaapps::vimxel::expr {
using ST = shared_ptr<Term>;

struct BinPlusNode : public BinOpNumNode {
struct BinPlusNode final : public BinOpNumNode {
using BinOpNumNode::BinOpNumNode;
ST getValue() override;
ST getValue() const override;
string getName() const override;
};
struct BinMinusNode : public BinOpNumNode {
struct BinMinusNode final : public BinOpNumNode {
using BinOpNumNode::BinOpNumNode;
ST getValue() override;
ST getValue() const override;
string getName() const override;
};
struct BinTimesNode : public BinOpNumNode {
struct BinTimesNode final : public BinOpNumNode {
using BinOpNumNode::BinOpNumNode;
ST getValue() override;
ST getValue() const override;
string getName() const override;
};
struct BinDivideNode : public BinOpNumNode {
struct BinDivideNode final : public BinOpNumNode {
using BinOpNumNode::BinOpNumNode;
ST getValue() override;
ST getValue() const override;
string getName() const override;
};

struct UnPlusNode : public UnOpNumNode {
struct UnPlusNode final : public UnOpNumNode {
using UnOpNumNode::UnOpNumNode;
ST getValue() override;
ST getValue() const override;
string getName() const override;
};
struct UnMinusNode : public UnOpNumNode {
struct UnMinusNode final : public UnOpNumNode {
using UnOpNumNode::UnOpNumNode;
ST getValue() override;
ST getValue() const override;
string getName() const override;
};
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,28 +11,28 @@ namespace cz::lastaapps::vimxel::expr {
using ST = shared_ptr<Term>;

// round
struct RoundNode : public UnOpNumNode {
struct RoundNode final : public UnOpNumNode {
using UnOpNumNode::UnOpNumNode;
string getName() const override;
ST getValue() override;
ST getValue() const override;
};
// ceil
struct CeilNode : public UnOpNumNode {
struct CeilNode final : public UnOpNumNode {
using UnOpNumNode::UnOpNumNode;
string getName() const override;
ST getValue() override;
ST getValue() const override;
};
// floor
struct FloorNode : public UnOpNumNode {
struct FloorNode final : public UnOpNumNode {
using UnOpNumNode::UnOpNumNode;
string getName() const override;
ST getValue() override;
ST getValue() const override;
};
// tail
struct TailNode : public UnOpNumNode {
struct TailNode final : public UnOpNumNode {
using UnOpNumNode::UnOpNumNode;
string getName() const override;
ST getValue() override;
ST getValue() const override;
};
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,25 +13,25 @@ using ST = shared_ptr<Term>;

class MultiOpNode : public OperatorNode {
protected:
vector<ST> mChildren;
const vector<ST> mChildren;
public:
MultiOpNode(vector<Node*> children);
MultiOpNode(vector<ST> children);
};

struct MultiOpNumNode : public MultiOpNode {
MultiOpNumNode(vector<Node*> children);
MultiOpNumNode(vector<ST> children);
};

struct MultiOpNumOrAreaNode : public MultiOpNode {
MultiOpNumOrAreaNode(vector<Node*> children);
MultiOpNumOrAreaNode(vector<ST> children);
};

struct MultiOpNumOrTextNode : public MultiOpNode {
MultiOpNumOrTextNode(vector<Node*> children);
MultiOpNumOrTextNode(vector<ST> children);
};

struct MultiOpTextNode : public MultiOpNode {
MultiOpTextNode(vector<Node*> children);
MultiOpTextNode(vector<ST> children);
};
}

Expand Down
15 changes: 15 additions & 0 deletions Semestralni_prace/src/cz/lastaapps/vimxel/expr/nodes/node.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
#ifndef H_NODE
#define H_NODE
#include <memory>
#include "terms.hpp"

using namespace std;
namespace cz::lastaapps::vimxel::expr {
using ST = shared_ptr<Term>;
struct Node {
virtual ~Node() = default;
virtual ST getValue() const = 0;
};
} // namespace cz::lastaapps::vimxel::expr

#endif
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,10 @@ using namespace std;
namespace cz::lastaapps::vimxel::expr {
using ST = shared_ptr<Term>;
class TermNode final : Node {
ST mTerm;
const ST mTerm;
public:
TermNode(shared_ptr<Term> term);
ST getValue() override;
ST getValue() const override;
};
} // namespace cz::lastaapps::vimxel::expr

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,10 @@ namespace cz::lastaapps::vimxel::expr {
using ST = shared_ptr<Term>;

// concat
struct ConcatNode : public MultiOpNumOrTextNode {
struct ConcatNode final : public MultiOpNumOrTextNode {
using MultiOpNumOrTextNode::MultiOpNumOrTextNode;
string getName() const override;
ST getValue() override;
ST getValue() const override;
};
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,17 +12,19 @@ using ST = shared_ptr<Term>;

class UnOpNode : public OperatorNode {
protected:
ST mChild;
const ST mChild;
public:
UnOpNode(Node * child);
};

struct UnOpNumNode : public UnOpNode {
UnOpNumNode(Node * child);
using UnOpNode::UnOpNode;
shared_ptr<DoubleTerm> casted() const;
};

struct UnOpTextNode : public UnOpNode {
UnOpTextNode(Node * child);
using UnOpNode::UnOpNode;
shared_ptr<TextTerm> casted() const;
};
}

Expand Down

0 comments on commit a74783b

Please sign in to comment.