mirror of
https://github.com/MaSzyna-EU07/maszyna.git
synced 2026-11-04 03:02:05 +01:00
refactor(sonar): declare non-mutating member functions const (cpp:S5817)
Virtual functions are left untouched so overrides keep matching.
This commit is contained in:
@@ -156,7 +156,7 @@ bool TEventLauncher::Load(cParser *parser)
|
||||
return true;
|
||||
}
|
||||
|
||||
bool TEventLauncher::check_activation_key() {
|
||||
bool TEventLauncher::check_activation_key() const {
|
||||
if (iKey <= 0)
|
||||
return false;
|
||||
|
||||
@@ -211,7 +211,7 @@ bool TEventLauncher::check_activation() {
|
||||
return bCond;
|
||||
}
|
||||
|
||||
bool TEventLauncher::check_conditions() {
|
||||
bool TEventLauncher::check_conditions() const {
|
||||
|
||||
auto bCond { true };
|
||||
|
||||
|
||||
@@ -30,10 +30,10 @@ public:
|
||||
|
||||
// methods
|
||||
bool Load( cParser *parser );
|
||||
bool check_activation_key();
|
||||
bool check_activation_key() const;
|
||||
bool check_activation();
|
||||
// checks conditions associated with the event. returns: true if the conditions are met
|
||||
bool check_conditions();
|
||||
bool check_conditions() const;
|
||||
inline
|
||||
auto key() const {
|
||||
return iKey; }
|
||||
|
||||
@@ -258,7 +258,7 @@ TMemCell::export_as_text_( std::ostream &Output ) const {
|
||||
|
||||
// legacy method, initializes traction after deserialization from scenario file
|
||||
void
|
||||
memory_table::InitCells() {
|
||||
memory_table::InitCells() const {
|
||||
|
||||
for( auto *cell : m_items ) {
|
||||
// Ra: eventy komórek pamięci, wykonywane po wysłaniu komendy do zatrzymanego pojazdu
|
||||
@@ -275,7 +275,7 @@ memory_table::InitCells() {
|
||||
|
||||
// legacy method, sends content of all cells to the log
|
||||
void
|
||||
memory_table::log_all() {
|
||||
memory_table::log_all() const {
|
||||
|
||||
for( auto *cell : m_items ) {
|
||||
cell->LogValues();
|
||||
|
||||
@@ -85,10 +85,10 @@ class memory_table : public basic_table<TMemCell> {
|
||||
public:
|
||||
// legacy method, initializes traction after deserialization from scenario file
|
||||
void
|
||||
InitCells();
|
||||
InitCells() const;
|
||||
// legacy method, sends content of all cells to the log
|
||||
void
|
||||
log_all();
|
||||
log_all() const;
|
||||
};
|
||||
|
||||
//---------------------------------------------------------------------------
|
||||
|
||||
@@ -335,7 +335,7 @@ glm::dvec3 TSegment::GetDirection(double const fDistance) const
|
||||
return FastGetPoint(t2) - FastGetPoint(t1);
|
||||
}
|
||||
|
||||
glm::dvec3 TSegment::FastGetDirection(double fDistance, double fOffset)
|
||||
glm::dvec3 TSegment::FastGetDirection(double fDistance, double fOffset) const
|
||||
{ // takie toporne liczenie pochodnej dla parametru 0.0÷1.0
|
||||
double t1 = fDistance - fOffset;
|
||||
if (t1 <= 0.0)
|
||||
|
||||
@@ -93,7 +93,7 @@ public:
|
||||
GetDirection() const {
|
||||
return CPointOut; };
|
||||
glm::dvec3
|
||||
FastGetDirection(double const fDistance, double const fOffset);
|
||||
FastGetDirection(double const fDistance, double const fOffset) const;
|
||||
/*
|
||||
Math3D::vector3
|
||||
GetPoint(double const fDistance) const;
|
||||
|
||||
@@ -17,7 +17,7 @@ void TSpring::Init(double nKs, double nKd) {
|
||||
kd = static_cast<float>(Kd);
|
||||
}
|
||||
|
||||
glm::dvec3 TSpring::ComputateForces(glm::dvec3 const &pPosition1, glm::dvec3 const &pPosition2) {
|
||||
glm::dvec3 TSpring::ComputateForces(glm::dvec3 const &pPosition1, glm::dvec3 const &pPosition2) const {
|
||||
glm::vec3 springForce;
|
||||
// p1 = &system[spring->p1];
|
||||
// p2 = &system[spring->p2];
|
||||
|
||||
@@ -27,7 +27,7 @@ public:
|
||||
// void Init(TParticnp1, TParticle *np2, double nKs= 0.5f, double nKd= 0.002f,
|
||||
// double nrestLen= -1.0f);
|
||||
void Init(double nKs = 0.5f, double nKd = 0.002f);
|
||||
glm::dvec3 ComputateForces(glm::dvec3 const &pPosition1, glm::dvec3 const &pPosition2);
|
||||
glm::dvec3 ComputateForces(glm::dvec3 const &pPosition1, glm::dvec3 const &pPosition2) const;
|
||||
//private:
|
||||
// members
|
||||
double restLen { 0.01 }; // LENGTH OF SPRING AT REST
|
||||
|
||||
@@ -349,7 +349,7 @@ TTraction::create_geometry( gfx::geometrybank_handle const &Bank ) {
|
||||
return elementcount;
|
||||
}
|
||||
|
||||
int TTraction::TestPoint(glm::dvec3 const &Point)
|
||||
int TTraction::TestPoint(glm::dvec3 const &Point) const
|
||||
{ // sprawdzanie, czy przęsła można połączyć
|
||||
if( hvNext[0] == nullptr
|
||||
&& glm::all(glm::epsilonEqual(Point, pPoint1, 0.025)) ) {
|
||||
|
||||
@@ -68,7 +68,7 @@ class TTraction : public scene::basic_node
|
||||
// creates geometry data in specified geometry bank. returns: number of created elements, or NULL
|
||||
// NOTE: deleting nodes doesn't currently release geometry data owned by the node. TODO: implement erasing individual geometry chunks and banks
|
||||
std::size_t create_geometry( gfx::geometrybank_handle const &Bank );
|
||||
int TestPoint(glm::dvec3 const &Point);
|
||||
int TestPoint(glm::dvec3 const &Point) const;
|
||||
void Connect(int my, TTraction *with, int to);
|
||||
void Init();
|
||||
bool WhereIs();
|
||||
|
||||
@@ -14,7 +14,7 @@ http://mozilla.org/MPL/2.0/.
|
||||
#include "utilities/dictionary.h"
|
||||
#include "utilities/utilities.h"
|
||||
|
||||
double TTrainParameters::CheckTrainLatency()
|
||||
double TTrainParameters::CheckTrainLatency() const
|
||||
{
|
||||
if (LastStationLatency > 1.0 || LastStationLatency < 0)
|
||||
return LastStationLatency; /*spoznienie + lub do przodu - z tolerancja 1 min*/
|
||||
@@ -22,7 +22,7 @@ double TTrainParameters::CheckTrainLatency()
|
||||
return 0;
|
||||
}
|
||||
|
||||
double TTrainParameters::WatchMTable(double DistCounter)
|
||||
double TTrainParameters::WatchMTable(double DistCounter) const
|
||||
{ // zwraca odleglość do najblizszej stacji z zatrzymaniem
|
||||
double dist;
|
||||
|
||||
@@ -163,7 +163,7 @@ void TTrainParameters::StationIndexInc()
|
||||
++StationIndex;
|
||||
}
|
||||
|
||||
bool TTrainParameters::IsTimeToGo(double hh, double mm)
|
||||
bool TTrainParameters::IsTimeToGo(double hh, double mm) const
|
||||
// sprawdzenie, czy można już odjechać z aktualnego zatrzymania
|
||||
// StationIndex to numer następnego po dodarciu do aktualnego
|
||||
{
|
||||
@@ -629,7 +629,7 @@ TTrainParameters::load_sounds() {
|
||||
}
|
||||
}
|
||||
|
||||
bool TTrainParameters::DirectionChange()
|
||||
bool TTrainParameters::DirectionChange() const
|
||||
// sprawdzenie, czy po zatrzymaniu wykonać kolejne komendy
|
||||
{
|
||||
if (StationIndex > 0 && StationIndex < StationCount) // dla ostatniej stacji nie
|
||||
|
||||
@@ -65,17 +65,17 @@ class TTrainParameters
|
||||
std::string NextStationName;
|
||||
double LastStationLatency;
|
||||
int Direction; /*kierunek jazdy w/g kilometrazu*/
|
||||
double CheckTrainLatency();
|
||||
double CheckTrainLatency() const;
|
||||
/*todo: str hh:mm to int i z powrotem*/
|
||||
std::string ShowRelation() const;
|
||||
double WatchMTable(double DistCounter);
|
||||
double WatchMTable(double DistCounter) const;
|
||||
std::string NextStop() const;
|
||||
sound_source next_stop_sound() const;
|
||||
sound_source last_stop_sound() const;
|
||||
bool IsStop() const;
|
||||
bool IsLastStop() const;
|
||||
bool IsMaintenance() const;
|
||||
bool IsTimeToGo(double hh, double mm);
|
||||
bool IsTimeToGo(double hh, double mm) const;
|
||||
// returns: difference between specified time and scheduled departure from current stop, in seconds
|
||||
double seconds_until_departure( double const Hour, double const Minute ) const;
|
||||
bool UpdateMTable(double hh, double mm, std::string const &NewName);
|
||||
@@ -85,7 +85,7 @@ class TTrainParameters
|
||||
void NewName(std::string const &NewTrainName);
|
||||
void UpdateVelocity(int StationCount, double vActual);
|
||||
bool LoadTTfile(std::string scnpath, int iPlus, double vmax);
|
||||
bool DirectionChange();
|
||||
bool DirectionChange() const;
|
||||
void StationIndexInc();
|
||||
void serialize( dictionary_source *Output ) const;
|
||||
// returns: radio channel associated with current station, or -1
|
||||
|
||||
@@ -22,7 +22,7 @@ basic_station Station;
|
||||
|
||||
// exchanges load with consist attached to specified vehicle, operating on specified schedule
|
||||
double
|
||||
basic_station::update_load( TDynamicObject *First, Mtable::TTrainParameters &Schedule, int const Platform ) {
|
||||
basic_station::update_load( TDynamicObject *First, Mtable::TTrainParameters &Schedule, int const Platform ) const {
|
||||
|
||||
// TODO: filter out maintenance stops when determining first and last stop
|
||||
auto const firststop { Schedule.StationIndex == 1 };
|
||||
|
||||
@@ -18,7 +18,7 @@ public:
|
||||
// methods
|
||||
// exchanges load with consist attached to specified vehicle, operating on specified schedule; returns: time needed for exchange, in seconds
|
||||
double
|
||||
update_load( TDynamicObject *First, Mtable::TTrainParameters &Schedule, int const Platform );
|
||||
update_load( TDynamicObject *First, Mtable::TTrainParameters &Schedule, int const Platform ) const;
|
||||
};
|
||||
|
||||
namespace simulation {
|
||||
|
||||
Reference in New Issue
Block a user