Skip to content

Commit

Permalink
Correct constness of some functions
Browse files Browse the repository at this point in the history
Signed-off-by: Le Courtois Florent <[email protected]>
  • Loading branch information
Le Courtois Florent committed Mar 9, 2021
1 parent 8c2cac0 commit ebb4f56
Show file tree
Hide file tree
Showing 14 changed files with 103 additions and 99 deletions.
6 changes: 3 additions & 3 deletions metrix-simulator/log/include/metrix/log/logger.h
Original file line number Diff line number Diff line change
Expand Up @@ -232,7 +232,7 @@ class Logger
static bool checkLevel(severity::level level) { return level >= config.loggerLevel; }

private:
bool check(const boost::log::attribute_value_set& set);
bool check(const boost::log::attribute_value_set& set) const;

/**
* @brief Formatter of logger
Expand All @@ -249,11 +249,11 @@ class Logger
* @param[in] view the boost log record view containing the attributes to format the log
* @param[out] os the stream where to put the formatted message
*/
void formatter(const boost::log::record_view& view, boost::log::formatting_ostream& os);
void formatter(const boost::log::record_view& view, boost::log::formatting_ostream& os) const;
void logImpl();
void onTimerExpired(const boost::system::error_code& code);

void logImplDev();
void logImplDev() const;
void logImplResult();

/**
Expand Down
6 changes: 3 additions & 3 deletions metrix-simulator/log/src/logger.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ Logger& Logger::instance()
return logger_instance;
}

bool Logger::check(const boost::log::attribute_value_set& set)
bool Logger::check(const boost::log::attribute_value_set& set) const
{
return checkLevel(set["Severity"].extract<severity::level>().get());
}
Expand All @@ -163,7 +163,7 @@ Logger& Logger::log(severity::level lvl, const std::string& filepath, int line,
return *this;
}

void Logger::logImplDev()
void Logger::logImplDev() const
{
BOOST_LOG_SCOPED_LOGGER_ATTR(
(*logger_),
Expand Down Expand Up @@ -201,7 +201,7 @@ void Logger::logImpl()
logInfo_.reset();
}

void Logger::formatter(const record_view& view, formatting_ostream& os)
void Logger::formatter(const record_view& view, formatting_ostream& os) const
{
auto lvl = view.attribute_values()["Severity"].extract<severity::level>().get();

Expand Down
27 changes: 15 additions & 12 deletions metrix-simulator/src/calcul.h
Original file line number Diff line number Diff line change
Expand Up @@ -88,10 +88,13 @@ class Contrainte
bool ecrireContrainte_;

// Quelques methodes
string typeDeContrainteToString();
string toString() { return "(" + typeDeContrainteToString() + " " + nomInc() + " || " + elemAS_->nom_ + ")"; };
string nomInc() { return icdt_ ? icdt_->nom_ : "N"; };
int numInc() { return icdt_ ? icdt_->num_ : SITU_N; };
string typeDeContrainteToString() const;
string toString() const
{
return "(" + typeDeContrainteToString() + " " + nomInc() + " || " + elemAS_->nom_ + ")";
};
string nomInc() const { return icdt_ ? icdt_->nom_ : "N"; };
int numInc() const { return icdt_ ? icdt_->num_ : SITU_N; };

// constructeur
Contrainte(const std::shared_ptr<ElementASurveiller>& qdt,
Expand Down Expand Up @@ -261,7 +264,7 @@ class Calculer
static double round(double x, double prec); // utiliser pour arrondir les calculs
Calculer(Reseau& res, MapQuadinVar& variantesOrdonnees);
int PneSolveur(TypeDeSolveur typeSolveur, const std::shared_ptr<Variante>& varianteCourante);
void comput_ParticipationGrp(const std::shared_ptr<Incident>& icdt);
void comput_ParticipationGrp(const std::shared_ptr<Incident>& icdt) const;
void fixerVariablesEntieres(); // Fixe les variables entieres pour lancement avec SPX

// Modelisation DODU
Expand Down Expand Up @@ -331,7 +334,7 @@ class Calculer
std::shared_ptr<Incident> icdt,
const vector<double>& theta);
double transitSurQuadIncidentNonConnexe(const std::shared_ptr<Quadripole>& quad,
const std::shared_ptr<Incident>& icdt);
const std::shared_ptr<Incident>& icdt) const;
void choixContraintesAajouter();
int ajoutContraintes(bool& existe_contrainte_active,
int& nbNewContreParVariante,
Expand Down Expand Up @@ -383,11 +386,11 @@ class Calculer
int calculReportInfluencement();
int calculCoefsReport(std::shared_ptr<Incident> icdt);
int calculCoefsInfluencement(const std::shared_ptr<Incident>& icdt);
int calculInitCoefs(std::shared_ptr<Incident> icdt);
int calculReportLcc(const std::shared_ptr<Incident>& inc);
int calculInitCoefs(std::shared_ptr<Incident> icdt) const;
int calculReportLcc(const std::shared_ptr<Incident>& inc) const;
int calculReportLccs();
int resetCoefs(std::shared_ptr<Incident> icdt);
void resetCoeffQuadsN();
int resetCoefs(std::shared_ptr<Incident> icdt) const;
void resetCoeffQuadsN() const;
int calculerCoeffEnN(const std::shared_ptr<Quadripole>& quad);
int calculCoeffReportTD();
int calculReportGroupesEtConsos();
Expand All @@ -398,11 +401,11 @@ class Calculer
vector<double>& BValeurDesTermesDeLaMatrice,
vector<int>& BIndicesDeLigne,
int nbColones,
vector<vector<double>>& invB);
vector<vector<double>>& invB) const;
int coeffsRepportPhases(const vector<std::shared_ptr<Quadripole>>& listeQuads,
int nbColonnes,
const vector<vector<double>>& invB_T,
vector<vector<double>>& g_mk);
vector<vector<double>>& g_mk) const;

// Traces
void printFctObj(bool silent);
Expand Down
2 changes: 1 addition & 1 deletion metrix-simulator/src/calculecrirecontraintesdodu.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2134,7 +2134,7 @@ void enregistreMenaces(const std::shared_ptr<Incident>& icdt,


double Calculer::transitSurQuadIncidentNonConnexe(const std::shared_ptr<Quadripole>& quad,
const std::shared_ptr<Incident>& icdt)
const std::shared_ptr<Incident>& icdt) const
{
const auto& quadsInc = icdt->listeQuads_;
if (find(quadsInc.begin(), quadsInc.end(), quad) != quadsInc.end()) {
Expand Down
2 changes: 1 addition & 1 deletion metrix-simulator/src/calculmacrofonctions.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ void Contrainte::init(const std::shared_ptr<ElementASurveiller>& qdt,
}


string Contrainte::typeDeContrainteToString()
string Contrainte::typeDeContrainteToString() const
{
string nom = "unknown";
if (type_ == Contrainte::CONTRAINTE_N) {
Expand Down
14 changes: 7 additions & 7 deletions metrix-simulator/src/calculrepports.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ using std::vector;
//---------------------------------------------------------
// REMARQUE : pour le detail des formules que nous utilisons,
// consultez "MODERN POWER SYSTEMS CONTROL AND OPERATION (Atif S.Debs)"
int Calculer::calculInitCoefs(std::shared_ptr<Incident> icdt)
int Calculer::calculInitCoefs(std::shared_ptr<Incident> icdt) const
{
if (icdt->pochePerdue_) {
if (icdt->pochePerdue_->pocheAvecConsoProd_) {
Expand All @@ -61,7 +61,7 @@ int Calculer::calculInitCoefs(std::shared_ptr<Incident> icdt)
return METRIX_PAS_PROBLEME;
}

int Calculer::resetCoefs(std::shared_ptr<Incident> icdt)
int Calculer::resetCoefs(std::shared_ptr<Incident> icdt) const
{
if (icdt->pochePerdue_) {
icdt = icdt->pochePerdue_->incidentModifie_;
Expand Down Expand Up @@ -365,7 +365,7 @@ int Calculer::calculReportLccs()
return codeRet;
}

int Calculer::calculReportLcc(const std::shared_ptr<Incident>& inc)
int Calculer::calculReportLcc(const std::shared_ptr<Incident>& inc) const
{
// Calcul de sensibilite de toutes les lignes à la HVDC sur des incidents donnees
int debut = inc->nbLignes_ + inc->nbCouplagesFermes_ + inc->nbGroupes_;
Expand Down Expand Up @@ -400,7 +400,7 @@ int Calculer::calculReportLcc(const std::shared_ptr<Incident>& inc)
int Calculer::coeffsRepportPhases(const vector<std::shared_ptr<Quadripole>>& listeQuads,
int nbColonnes,
const vector<vector<double>>& invB_T,
vector<vector<double>>& g_mk)
vector<vector<double>>& g_mk) const
{
// Remarque : g_mk[indice colonne : 1...icdt->nbLignes_][indice ligne : 1...res_.nbNoeuds_]
// invB[indice colonne : 1...icdt->nbLignes_][indice ligne : 1...icdt->nbLignes_]
Expand Down Expand Up @@ -446,7 +446,7 @@ int Calculer::calculeInvB(const std::shared_ptr<Incident>& icdt,
vector<double>& BValeurDesTermesDeLaMatrice,
vector<int>& BIndicesDeLigne,
int nbColones,
vector<vector<double>>& invB)
vector<vector<double>>& invB) const
{
MATRICE_A_FACTORISER B;
MATRICE* Bptr;
Expand Down Expand Up @@ -484,7 +484,7 @@ int Calculer::calculeInvB(const std::shared_ptr<Incident>& icdt,
return METRIX_PAS_PROBLEME;
}

void Calculer::comput_ParticipationGrp(const std::shared_ptr<Incident>& icdt)
void Calculer::comput_ParticipationGrp(const std::shared_ptr<Incident>& icdt) const
{
// true si groupe qui participe a la compensation (1- connecte 2- Pmax diff Pmin 3- Pas N-k, non impose)
// sinon false
Expand Down Expand Up @@ -727,7 +727,7 @@ int Calculer::calculReportGroupesEtConsos()
}


void Calculer::resetCoeffQuadsN()
void Calculer::resetCoeffQuadsN() const
{
for (auto& elem : res_.quadsSurv_) {
elem->coeffN_.resize(0);
Expand Down
32 changes: 16 additions & 16 deletions metrix-simulator/src/config/variant_configuration.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -247,7 +247,7 @@ VariantConfiguration::VariantConfiguration(const std::string& pathname) :
}
}

void VariantConfiguration::processGroup(VariantConfig& variant, std::istringstream& iss)
void VariantConfiguration::processGroup(VariantConfig& variant, std::istringstream& iss) const
{
std::string sub_line;
getline(iss, sub_line, ';');
Expand Down Expand Up @@ -284,7 +284,7 @@ std::tuple<std::string, int> VariantConfiguration::extractInt(std::istringstream
return std::make_tuple(name, value);
}

void VariantConfiguration::processConso(VariantConfig& variant, std::istringstream& iss)
void VariantConfiguration::processConso(VariantConfig& variant, std::istringstream& iss) const
{
auto conso = extractDouble(iss);
variant.consos.push_back(conso);
Expand All @@ -293,7 +293,7 @@ void VariantConfiguration::processConso(VariantConfig& variant, std::istringstre
<< " with value " << std::get<VALUE>(conso);
}

void VariantConfiguration::processImposedGroup(VariantConfig& variant, std::istringstream& iss)
void VariantConfiguration::processImposedGroup(VariantConfig& variant, std::istringstream& iss) const
{
auto group = extractDouble(iss);
variant.groups.push_back(group);
Expand All @@ -302,7 +302,7 @@ void VariantConfiguration::processImposedGroup(VariantConfig& variant, std::istr
<< " is imposed at value " << std::get<VALUE>(group);
}

void VariantConfiguration::processGroupPmax(VariantConfig& variant, std::istringstream& iss)
void VariantConfiguration::processGroupPmax(VariantConfig& variant, std::istringstream& iss) const
{
auto group = extractDouble(iss);
variant.pmaxGroups.push_back(group);
Expand All @@ -311,7 +311,7 @@ void VariantConfiguration::processGroupPmax(VariantConfig& variant, std::istring
<< " at Pmax value " << std::get<VALUE>(group);
}

void VariantConfiguration::processGroupPmin(VariantConfig& variant, std::istringstream& iss)
void VariantConfiguration::processGroupPmin(VariantConfig& variant, std::istringstream& iss) const
{
auto group = extractDouble(iss);
variant.pminGroups.push_back(group);
Expand All @@ -320,7 +320,7 @@ void VariantConfiguration::processGroupPmin(VariantConfig& variant, std::istring
<< " at Pmin value " << std::get<VALUE>(group);
}

void VariantConfiguration::processLine(VariantConfig& variant, std::istringstream& iss)
void VariantConfiguration::processLine(VariantConfig& variant, std::istringstream& iss) const
{
std::string sub_line;
getline(iss, sub_line, ';');
Expand All @@ -331,7 +331,7 @@ void VariantConfiguration::processLine(VariantConfig& variant, std::istringstrea
LOG(debug) << metrix::log::verbose_config << "Variant " << variant.num << " : line " << sub_line << " unavailable";
}

void VariantConfiguration::processHVDCPmax(VariantConfig& variant, std::istringstream& iss)
void VariantConfiguration::processHVDCPmax(VariantConfig& variant, std::istringstream& iss) const
{
auto line = extractDouble(iss);
variant.pmaxHvdc.push_back(line);
Expand All @@ -340,7 +340,7 @@ void VariantConfiguration::processHVDCPmax(VariantConfig& variant, std::istrings
<< " Pmax at " << std::get<VALUE>(line);
}

void VariantConfiguration::processHVDCPmin(VariantConfig& variant, std::istringstream& iss)
void VariantConfiguration::processHVDCPmin(VariantConfig& variant, std::istringstream& iss) const
{
auto line = extractDouble(iss);
variant.pminHvdc.push_back(line);
Expand All @@ -349,7 +349,7 @@ void VariantConfiguration::processHVDCPmin(VariantConfig& variant, std::istrings
<< " Pmin at " << std::get<VALUE>(line);
}

void VariantConfiguration::processHVDCPower(VariantConfig& variant, std::istringstream& iss)
void VariantConfiguration::processHVDCPower(VariantConfig& variant, std::istringstream& iss) const
{
auto line = extractDouble(iss);
variant.powerHvdc.push_back(line);
Expand All @@ -358,7 +358,7 @@ void VariantConfiguration::processHVDCPower(VariantConfig& variant, std::istring
<< " power at " << std::get<VALUE>(line);
}

void VariantConfiguration::processTDPhasing(VariantConfig& variant, std::istringstream& iss)
void VariantConfiguration::processTDPhasing(VariantConfig& variant, std::istringstream& iss) const
{
auto td = extractInt(iss);
variant.tdPhasing.push_back(td);
Expand All @@ -367,7 +367,7 @@ void VariantConfiguration::processTDPhasing(VariantConfig& variant, std::istring
<< " phasing at " << std::get<VALUE>(td);
}

void VariantConfiguration::processCostConso(VariantConfig& variant, std::istringstream& iss)
void VariantConfiguration::processCostConso(VariantConfig& variant, std::istringstream& iss) const
{
auto conso = extractDouble(iss);
variant.deleteConsosCosts.push_back(conso);
Expand All @@ -376,7 +376,7 @@ void VariantConfiguration::processCostConso(VariantConfig& variant, std::istring
<< " delete cost at " << std::get<VALUE>(conso);
}

void VariantConfiguration::processBalancesConsumption(VariantConfig& variant, std::istringstream& iss)
void VariantConfiguration::processBalancesConsumption(VariantConfig& variant, std::istringstream& iss) const
{
auto region = extractDouble(iss);
variant.balancesConso.push_back(region);
Expand All @@ -385,7 +385,7 @@ void VariantConfiguration::processBalancesConsumption(VariantConfig& variant, st
<< ", balance objective by consumption value at" << std::get<VALUE>(region);
}

void VariantConfiguration::processBalancesProduction(VariantConfig& variant, std::istringstream& iss)
void VariantConfiguration::processBalancesProduction(VariantConfig& variant, std::istringstream& iss) const
{
auto region = extractDouble(iss);
variant.balancesProd.push_back(region);
Expand All @@ -394,7 +394,7 @@ void VariantConfiguration::processBalancesProduction(VariantConfig& variant, std
<< ", balance objective by production value at" << std::get<VALUE>(region);
}

void VariantConfiguration::processProbaInc(VariantConfig& variant, std::istringstream& iss)
void VariantConfiguration::processProbaInc(VariantConfig& variant, std::istringstream& iss) const
{
auto incident = extractDouble(iss);
variant.probas.push_back(incident);
Expand All @@ -405,7 +405,7 @@ void VariantConfiguration::processProbaInc(VariantConfig& variant, std::istrings

void VariantConfiguration::processCost(VariantConfig::CostType cost_type,
VariantConfig& variant,
std::istringstream& iss)
std::istringstream& iss) const
{
auto group = extractDouble(iss);
variant.costs[cost_type].push_back(group);
Expand All @@ -427,7 +427,7 @@ void VariantConfiguration::processCost(VariantConfig::CostType cost_type,

void VariantConfiguration::processThreshold(VariantConfig::Threshold threshold,
VariantConfig& variant,
std::istringstream& iss)
std::istringstream& iss) const
{
auto quad = extractDouble(iss);
variant.tresholds[threshold].push_back(quad);
Expand Down
40 changes: 20 additions & 20 deletions metrix-simulator/src/config/variant_configuration.h
Original file line number Diff line number Diff line change
Expand Up @@ -107,26 +107,26 @@ class VariantConfiguration
static std::tuple<std::string, int> extractInt(std::istringstream& iss);

private:
void processGroup(VariantConfig& variant, std::istringstream& iss);
void processConso(VariantConfig& variant, std::istringstream& iss);
void processCostConso(VariantConfig& variant, std::istringstream& iss);
void processImposedGroup(VariantConfig& variant, std::istringstream& iss);
void processGroupPmax(VariantConfig& variant, std::istringstream& iss);
void processGroupPmin(VariantConfig& variant, std::istringstream& iss);

void processCost(VariantConfig::CostType cost_type, VariantConfig& variant, std::istringstream& iss);

void processLine(VariantConfig& variant, std::istringstream& iss);
void processHVDCPmax(VariantConfig& variant, std::istringstream& iss);
void processHVDCPmin(VariantConfig& variant, std::istringstream& iss);
void processHVDCPower(VariantConfig& variant, std::istringstream& iss);
void processTDPhasing(VariantConfig& variant, std::istringstream& iss);

void processThreshold(VariantConfig::Threshold threshold, VariantConfig& variant, std::istringstream& iss);

void processBalancesConsumption(VariantConfig& variant, std::istringstream& iss);
void processBalancesProduction(VariantConfig& variant, std::istringstream& iss);
void processProbaInc(VariantConfig& variant, std::istringstream& iss);
void processGroup(VariantConfig& variant, std::istringstream& iss) const;
void processConso(VariantConfig& variant, std::istringstream& iss) const;
void processCostConso(VariantConfig& variant, std::istringstream& iss) const;
void processImposedGroup(VariantConfig& variant, std::istringstream& iss) const;
void processGroupPmax(VariantConfig& variant, std::istringstream& iss) const;
void processGroupPmin(VariantConfig& variant, std::istringstream& iss) const;

void processCost(VariantConfig::CostType cost_type, VariantConfig& variant, std::istringstream& iss) const;

void processLine(VariantConfig& variant, std::istringstream& iss) const;
void processHVDCPmax(VariantConfig& variant, std::istringstream& iss) const;
void processHVDCPmin(VariantConfig& variant, std::istringstream& iss) const;
void processHVDCPower(VariantConfig& variant, std::istringstream& iss) const;
void processTDPhasing(VariantConfig& variant, std::istringstream& iss) const;

void processThreshold(VariantConfig::Threshold threshold, VariantConfig& variant, std::istringstream& iss) const;

void processBalancesConsumption(VariantConfig& variant, std::istringstream& iss) const;
void processBalancesProduction(VariantConfig& variant, std::istringstream& iss) const;
void processProbaInc(VariantConfig& variant, std::istringstream& iss) const;

private:
const std::map<std::string, Processor>
Expand Down
2 changes: 1 addition & 1 deletion metrix-simulator/src/connexite.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -568,7 +568,7 @@ PochePerdue& PochePerdue::operator=(const PochePerdue& other)
}


string PochePerdue::print()
string PochePerdue::print() const
{
string txt = err::ioDico().msg("INFOPochePerdue");
for (auto& node : noeudsPoche_) {
Expand Down
Loading

0 comments on commit ebb4f56

Please sign in to comment.