-
Notifications
You must be signed in to change notification settings - Fork 4
Simplify streets #243
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Simplify streets #243
Changes from all commits
527450f
3a59878
33c5271
889da9b
db04e6c
a052a14
16a3ab1
37a00ca
e5a4ebb
6fd5298
f7f5ac7
79ef769
48e3559
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,44 @@ | ||
| #include "Edge.hpp" | ||
| #include "../utility/Logger.hpp" | ||
|
|
||
| #include <stdexcept> | ||
| #include <format> | ||
|
|
||
| namespace dsm { | ||
| Edge::Edge(Id id, std::pair<Id, Id> nodePair, int capacity, int transportCapacity) | ||
| : m_id(id), | ||
| m_nodePair(nodePair), | ||
| m_capacity{capacity}, | ||
Check noticeCode scanning / Cppcheck (reported by Codacy) MISRA 12.3 rule Note
MISRA 12.3 rule
|
||
| m_transportCapacity{transportCapacity} { | ||
| if (capacity < 1) { | ||
| throw std::invalid_argument( | ||
| buildLog(std::format("Edge capacity ({}) must be greater than 0.", capacity))); | ||
| } | ||
| if (transportCapacity < 1) { | ||
| throw std::invalid_argument(buildLog(std::format( | ||
| "Edge transport capacity ({}) must be greater than 0.", transportCapacity))); | ||
| } | ||
| } | ||
|
|
||
| void Edge::setCapacity(int capacity) { | ||
| if (capacity < 1) { | ||
| throw std::invalid_argument( | ||
| buildLog(std::format("Edge capacity ({}) must be greater than 0.", capacity))); | ||
| } | ||
| m_capacity = capacity; | ||
| } | ||
| void Edge::setTransportCapacity(int capacity) { | ||
| if (capacity < 1) { | ||
| throw std::invalid_argument(buildLog( | ||
| std::format("Edge transport capacity ({}) must be greater than 0.", capacity))); | ||
| } | ||
| m_transportCapacity = capacity; | ||
| } | ||
|
|
||
| Id Edge::id() const { return m_id; } | ||
| Id Edge::u() const { return m_nodePair.first; } | ||
| Id Edge::v() const { return m_nodePair.second; } | ||
| std::pair<Id, Id> Edge::nodePair() const { return m_nodePair; } | ||
Check noticeCode scanning / Cppcheck (reported by Codacy) MISRA 12.3 rule Note
MISRA 12.3 rule
|
||
| int Edge::capacity() const { return m_capacity; } | ||
| int Edge::transportCapacity() const { return m_transportCapacity; } | ||
| }; // namespace dsm | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,29 @@ | ||
| #pragma once | ||
|
|
||
| #include <utility> | ||
| #include "../utility/Typedef.hpp" | ||
|
|
||
| namespace dsm { | ||
| class Edge { | ||
| protected: | ||
| Id m_id; | ||
| std::pair<Id, Id> m_nodePair; | ||
| int m_capacity; | ||
| int m_transportCapacity; | ||
|
|
||
| public: | ||
| Edge(Id id, std::pair<Id, Id> nodePair, int capacity = 1, int transportCapacity = 1); | ||
|
|
||
| void setCapacity(int capacity); | ||
| void setTransportCapacity(int capacity); | ||
|
|
||
| Id id() const; | ||
| Id u() const; | ||
| Id v() const; | ||
| std::pair<Id, Id> nodePair() const; | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Debatable but I'd say |
||
| int capacity() const; | ||
| int transportCapacity() const; | ||
|
|
||
| virtual bool isFull() const = 0; | ||
| }; | ||
| }; // namespace dsm | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
u and v?