From: Arnaud Giersch Date: Thu, 19 Oct 2017 07:12:40 +0000 (+0200) Subject: Make some protected fields private. X-Git-Tag: v3.18~405 X-Git-Url: http://info.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/commitdiff_plain/a42065590d308653d71e5a49c8647c535b964a94 Make some protected fields private. --- diff --git a/src/kernel/EngineImpl.hpp b/src/kernel/EngineImpl.hpp index d8f96c2acd..39f041a8cb 100644 --- a/src/kernel/EngineImpl.hpp +++ b/src/kernel/EngineImpl.hpp @@ -1,4 +1,4 @@ -/* Copyright (c) 2016. The SimGrid Team. All rights reserved. */ +/* Copyright (c) 2016-2017. The SimGrid Team. All rights reserved. */ /* This program is free software; you can redistribute it and/or modify it * under the terms of the license (GNU LGPL) which comes with this package. */ @@ -20,7 +20,7 @@ public: virtual ~EngineImpl(); kernel::routing::NetZoneImpl* netRoot_ = nullptr; -protected: +private: std::unordered_map netpoints_; friend simgrid::s4u::Engine; }; diff --git a/src/kernel/context/ContextRaw.cpp b/src/kernel/context/ContextRaw.cpp index 1cd6340932..5695d19728 100644 --- a/src/kernel/context/ContextRaw.cpp +++ b/src/kernel/context/ContextRaw.cpp @@ -27,10 +27,11 @@ class RawContextFactory; * preserve the signal mask when switching. This saves a system call (at least on Linux) on each context switch. */ class RawContext : public Context { -protected: +private: void* stack_ = nullptr; /** pointer to top the stack stack */ void* stack_top_ = nullptr; + public: friend class RawContextFactory; RawContext(std::function code, diff --git a/src/plugins/vm/VirtualMachineImpl.hpp b/src/plugins/vm/VirtualMachineImpl.hpp index fbc0483632..467b3cc3d8 100644 --- a/src/plugins/vm/VirtualMachineImpl.hpp +++ b/src/plugins/vm/VirtualMachineImpl.hpp @@ -93,9 +93,6 @@ public: int dp_enabled = 0; double dp_updated_by_deleted_tasks = 0; -protected: - simgrid::s4u::Host* hostPM_; - public: e_surf_vm_state_t getState(); void setState(e_surf_vm_state_t state); @@ -105,10 +102,9 @@ public: bool isMigrating = false; private: + simgrid::s4u::Host* hostPM_; s_vm_params_t params_; int coreAmount_; - -protected: e_surf_vm_state_t vmState_ = SURF_VM_STATE_CREATED; }; diff --git a/src/smpi/include/smpi_topo.hpp b/src/smpi/include/smpi_topo.hpp index d0cb5709ea..c8f0caf3d1 100644 --- a/src/smpi/include/smpi_topo.hpp +++ b/src/smpi/include/smpi_topo.hpp @@ -17,8 +17,10 @@ namespace smpi{ class Topo { public: virtual ~Topo()=default; - protected: - MPI_Comm comm_; + MPI_Comm getComm() const { return comm_; } + void setComm(MPI_Comm comm) { comm_ = comm; } + private: + MPI_Comm comm_; }; diff --git a/src/smpi/mpi/smpi_topo.cpp b/src/smpi/mpi/smpi_topo.cpp index b56bc73b05..04b5179ffd 100644 --- a/src/smpi/mpi/smpi_topo.cpp +++ b/src/smpi/mpi/smpi_topo.cpp @@ -94,7 +94,7 @@ Topo_Cart::Topo_Cart(MPI_Comm comm_old, int ndims, int dims[], int periods[], in *comm_cart = MPI_COMM_NULL; } } - comm_=*comm_cart; + setComm(*comm_cart); } Topo_Cart* Topo_Cart::sub(const int remain_dims[], MPI_Comm *newcomm) { @@ -125,7 +125,7 @@ Topo_Cart* Topo_Cart::sub(const int remain_dims[], MPI_Comm *newcomm) { } } } - return new Topo_Cart(comm_, newNDims, newDims, newPeriodic, 0, newcomm); + return new Topo_Cart(getComm(), newNDims, newDims, newPeriodic, 0, newcomm); } int Topo_Cart::coords(int rank, int maxdims, int coords[]) { @@ -195,7 +195,7 @@ int Topo_Cart::shift(int direction, int disp, int *rank_source, int *rank_dest) return MPI_ERR_DIMS; } - this->coords(comm_->rank(),ndims_, position); + this->coords(getComm()->rank(), ndims_, position); position[direction] += disp; if(position[direction] < 0 || diff --git a/src/xbt/config.cpp b/src/xbt/config.cpp index cb6c810de6..f7d8d81815 100644 --- a/src/xbt/config.cpp +++ b/src/xbt/config.cpp @@ -139,7 +139,7 @@ template class TypedConfigurationElement; // **** ConfigurationElement **** class ConfigurationElement { -protected: +private: std::string key; std::string desc; bool isdefault = true; @@ -174,6 +174,7 @@ public: { dynamic_cast&>(*this).setDefaultValue(std::move(value)); } + void unsetDefault() { isdefault = false; } bool isDefault() const { return isdefault; } std::string const& getDescription() const { return desc; } @@ -208,7 +209,7 @@ public: void update() { if (old_callback) - this->old_callback(key.c_str()); + this->old_callback(getKey().c_str()); if (this->callback) this->callback(this->content); } @@ -223,12 +224,12 @@ public: void setDefaultValue(T value) { - if (this->isdefault) { + if (this->isDefault()) { this->content = std::move(value); this->update(); } else { - XBT_DEBUG("Do not override configuration variable '%s' with value '%s' because it was already set.", key.c_str(), - to_string(value).c_str()); + XBT_DEBUG("Do not override configuration variable '%s' with value '%s' because it was already set.", + getKey().c_str(), to_string(value).c_str()); } } }; @@ -243,7 +244,7 @@ template void TypedConfigurationElement::setStringValue(const char* value) // override { this->content = ConfigType::parse(value); - this->isdefault = false; + this->unsetDefault(); this->update(); }