From fe17bf1e29884902ff4eda519345f2018ca0b6a1 Mon Sep 17 00:00:00 2001 From: Loek Le Blansch Date: Sun, 16 Jun 2024 10:26:07 +0200 Subject: check member visibility --- GateAnd.h | 4 ++-- GateNand.h | 7 +++---- GateNor.h | 7 +++---- GateNot.h | 7 +++++-- GateOr.h | 9 +++++---- GateXor.h | 10 ++++++---- Node.h | 2 ++ NodeInput.h | 13 +++++++------ NodeOutput.h | 12 +++++++----- Observer.h | 6 +++--- Parser.cpp | 1 + Parser.h | 3 --- main.cpp | 1 + 13 files changed, 45 insertions(+), 37 deletions(-) diff --git a/GateAnd.h b/GateAnd.h index 4c19836..8b399e1 100644 --- a/GateAnd.h +++ b/GateAnd.h @@ -7,10 +7,10 @@ class GateAnd : public Node { public: GateAnd() = default; - ~GateAnd() = default; + virtual ~GateAnd() = default; virtual GateAnd * clone() const; -protected: +public: SignalLevel level(); private: diff --git a/GateNand.h b/GateNand.h index fb9d788..3d78af5 100644 --- a/GateNand.h +++ b/GateNand.h @@ -1,19 +1,18 @@ #pragma once -// #include "Node.h" #include "GateAnd.h" class GateNand : public GateAnd { + using GateAnd::GateAnd; + public: virtual GateNand * clone() const; -protected: +public: SignalLevel level(); - using GateAnd::GateAnd; private: GateNand(const GateNand *) : GateAnd() {} - // GateNand(const char * type); constexpr static const char * type = "nand"; static GateNand instance; }; diff --git a/GateNor.h b/GateNor.h index 35b5a74..e094f46 100644 --- a/GateNor.h +++ b/GateNor.h @@ -1,19 +1,18 @@ #pragma once -// #include "Node.h" #include "GateOr.h" class GateNor : public GateOr { + using GateOr::GateOr; + public: virtual GateNor * clone() const; -protected: +public: SignalLevel level(); - using GateOr::GateOr; private: GateNor(const GateNor *) : GateOr() {} - // GateNor(const char * type); constexpr static const char * type = "nor"; static GateNor instance; }; diff --git a/GateNot.h b/GateNot.h index 2a185f9..0f79a0d 100644 --- a/GateNot.h +++ b/GateNot.h @@ -3,15 +3,18 @@ #include "Node.h" class GateNot : public Node { + using Node::Node; + public: GateNot(); - GateNot(const GateNot * prototype); virtual ~GateNot() = default; virtual GateNot * clone() const; + +public: SignalLevel level(); private: - using Node::Node; + GateNot(const GateNot * prototype); constexpr static const char * type = "not"; static GateNot instance; }; diff --git a/GateOr.h b/GateOr.h index bc96b24..6daa989 100644 --- a/GateOr.h +++ b/GateOr.h @@ -3,17 +3,18 @@ #include "Node.h" class GateOr : public Node { + using Node::Node; + public: GateOr() = default; - GateOr(const GateOr * prototype); - ~GateOr() = default; + virtual ~GateOr() = default; virtual GateOr * clone() const; -protected: +public: SignalLevel level(); private: - using Node::Node; + GateOr(const GateOr * prototype); constexpr static const char * type = "or"; static GateOr instance; }; diff --git a/GateXor.h b/GateXor.h index b70d552..7665b8c 100644 --- a/GateXor.h +++ b/GateXor.h @@ -3,16 +3,18 @@ #include "Node.h" class GateXor : public Node { + using Node::Node; + public: GateXor() = default; - GateXor(const GateXor * prototype); - ~GateXor() = default; + virtual ~GateXor() = default; virtual GateXor * clone() const; -private: +public: SignalLevel level(); - using Node::Node; +private: + GateXor(const GateXor * prototype); constexpr static const char * type = "xor"; static GateXor instance; }; diff --git a/Node.h b/Node.h index 9685141..34e1895 100644 --- a/Node.h +++ b/Node.h @@ -23,6 +23,8 @@ public: virtual void setOutput(Net *); //! validate and simulate virtual void sim(); + +public: //! logical implementation of the node/gate virtual SignalLevel level() = 0; diff --git a/NodeInput.h b/NodeInput.h index ebacf4f..4317e0c 100644 --- a/NodeInput.h +++ b/NodeInput.h @@ -3,23 +3,23 @@ #include "Node.h" class NodeInput : public Node { + using Node::Node; + public: NodeInput(); ~NodeInput() = default; virtual void addInput(Net *); - -protected: - using Node::Node; }; class NodeInputLow : public NodeInput { + using NodeInput::NodeInput; + public: virtual NodeInputLow * clone() const; -protected: +public: SignalLevel level(); - using NodeInput::NodeInput; private: NodeInputLow(const NodeInputLow *) : NodeInput() {} @@ -28,12 +28,13 @@ private: }; class NodeInputHigh : public NodeInput { + using NodeInput::NodeInput; + public: virtual NodeInputHigh * clone() const; protected: SignalLevel level(); - using NodeInput::NodeInput; private: NodeInputHigh(const NodeInputHigh *) : NodeInput() {} diff --git a/NodeOutput.h b/NodeOutput.h index 83a8b34..8b3eb44 100644 --- a/NodeOutput.h +++ b/NodeOutput.h @@ -3,19 +3,21 @@ #include "Node.h" class NodeOutput : public Node { + using Node::Node; + public: NodeOutput(); - NodeOutput(const NodeOutput * prototype); - ~NodeOutput() = default; + virtual ~NodeOutput() = default; + virtual NodeOutput * clone() const; virtual void sim(); - virtual SignalLevel level(); - virtual NodeOutput * clone() const; virtual void setOutput(Net *); +public: + virtual SignalLevel level(); private: - using Node::Node; + NodeOutput(const NodeOutput * prototype); constexpr static const char * type = "probe"; static NodeOutput instance; diff --git a/Observer.h b/Observer.h index 53c23c7..1d03525 100644 --- a/Observer.h +++ b/Observer.h @@ -7,14 +7,14 @@ public: }; class Subject { -private: - std::vector observers; public: virtual void attach(Observer* obs); virtual void detach(Observer*); //! Get number of attached observers virtual int size(); - virtual void notify(); + +private: + std::vector observers; }; diff --git a/Parser.cpp b/Parser.cpp index 9b98267..e72e3f9 100644 --- a/Parser.cpp +++ b/Parser.cpp @@ -2,6 +2,7 @@ #include #include "Parser.h" +#include "Exception.h" using std::getline; diff --git a/Parser.h b/Parser.h index 271d0f4..221e14e 100644 --- a/Parser.h +++ b/Parser.h @@ -5,13 +5,10 @@ #include "Circuit.h" -#include "Exception.h" using std::istream; using std::string; - - class Parser { public: Parser() = default; diff --git a/main.cpp b/main.cpp index b87eab7..4b4fc46 100644 --- a/main.cpp +++ b/main.cpp @@ -4,6 +4,7 @@ #include "Parser.h" #include "Circuit.h" +#include "Exception.h" using std::cout; using std::endl; -- cgit v1.2.3