Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Make some protected fields private.
authorArnaud Giersch <arnaud.giersch@univ-fcomte.fr>
Thu, 19 Oct 2017 07:12:40 +0000 (09:12 +0200)
committerArnaud Giersch <arnaud.giersch@univ-fcomte.fr>
Thu, 19 Oct 2017 19:30:52 +0000 (21:30 +0200)
src/kernel/EngineImpl.hpp
src/kernel/context/ContextRaw.cpp
src/plugins/vm/VirtualMachineImpl.hpp
src/smpi/include/smpi_topo.hpp
src/smpi/mpi/smpi_topo.cpp
src/xbt/config.cpp

index d8f96c2..39f041a 100644 (file)
@@ -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. */
 
 /* 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;
 
   virtual ~EngineImpl();
   kernel::routing::NetZoneImpl* netRoot_ = nullptr;
 
-protected:
+private:
   std::unordered_map<std::string, simgrid::kernel::routing::NetPoint*> netpoints_;
   friend simgrid::s4u::Engine;
 };
   std::unordered_map<std::string, simgrid::kernel::routing::NetPoint*> netpoints_;
   friend simgrid::s4u::Engine;
 };
index 1cd6340..5695d19 100644 (file)
@@ -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 {
   * 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;
   void* stack_ = nullptr;
   /** pointer to top the stack stack */
   void* stack_top_ = nullptr;
+
 public:
   friend class RawContextFactory;
   RawContext(std::function<void()> code,
 public:
   friend class RawContextFactory;
   RawContext(std::function<void()> code,
index fbc0483..467b3cc 100644 (file)
@@ -93,9 +93,6 @@ public:
   int dp_enabled                     = 0;
   double dp_updated_by_deleted_tasks = 0;
 
   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);
 public:
   e_surf_vm_state_t getState();
   void setState(e_surf_vm_state_t state);
@@ -105,10 +102,9 @@ public:
   bool isMigrating = false;
 
 private:
   bool isMigrating = false;
 
 private:
+  simgrid::s4u::Host* hostPM_;
   s_vm_params_t params_;
   int coreAmount_;
   s_vm_params_t params_;
   int coreAmount_;
-
-protected:
   e_surf_vm_state_t vmState_ = SURF_VM_STATE_CREATED;
 };
 
   e_surf_vm_state_t vmState_ = SURF_VM_STATE_CREATED;
 };
 
index d0cb570..c8f0caf 100644 (file)
@@ -17,8 +17,10 @@ namespace smpi{
 class Topo {
   public:
     virtual ~Topo()=default;
 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_;
 };
 
 
 };
 
 
index b56bc73..04b5179 100644 (file)
@@ -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_cart = MPI_COMM_NULL;
     }
   }
-  comm_=*comm_cart;
+  setComm(*comm_cart);
 }
 
 Topo_Cart* Topo_Cart::sub(const int remain_dims[], MPI_Comm *newcomm) {
 }
 
 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[]) {
 }
 
 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;
   }
 
     return MPI_ERR_DIMS;
   }
 
-  this->coords(comm_->rank(),ndims_, position);
+  this->coords(getComm()->rank(), ndims_, position);
   position[direction] += disp;
 
   if(position[direction] < 0 ||
   position[direction] += disp;
 
   if(position[direction] < 0 ||
index cb6c810..f7d8d81 100644 (file)
@@ -139,7 +139,7 @@ template<class T> class TypedConfigurationElement;
 // **** ConfigurationElement ****
 
 class ConfigurationElement {
 // **** ConfigurationElement ****
 
 class ConfigurationElement {
-protected:
+private:
   std::string key;
   std::string desc;
   bool isdefault = true;
   std::string key;
   std::string desc;
   bool isdefault = true;
@@ -174,6 +174,7 @@ public:
   {
     dynamic_cast<TypedConfigurationElement<T>&>(*this).setDefaultValue(std::move(value));
   }
   {
     dynamic_cast<TypedConfigurationElement<T>&>(*this).setDefaultValue(std::move(value));
   }
+  void unsetDefault() { isdefault = false; }
   bool isDefault() const { return isdefault; }
 
   std::string const& getDescription() const { return desc; }
   bool isDefault() const { return isdefault; }
 
   std::string const& getDescription() const { return desc; }
@@ -208,7 +209,7 @@ public:
   void update()
   {
     if (old_callback)
   void update()
   {
     if (old_callback)
-      this->old_callback(key.c_str());
+      this->old_callback(getKey().c_str());
     if (this->callback)
       this->callback(this->content);
   }
     if (this->callback)
       this->callback(this->content);
   }
@@ -223,12 +224,12 @@ public:
 
   void setDefaultValue(T value)
   {
 
   void setDefaultValue(T value)
   {
-    if (this->isdefault) {
+    if (this->isDefault()) {
       this->content = std::move(value);
       this->update();
     } else {
       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<class T>
 void TypedConfigurationElement<T>::setStringValue(const char* value) // override
 {
   this->content = ConfigType<T>::parse(value);
 void TypedConfigurationElement<T>::setStringValue(const char* value) // override
 {
   this->content = ConfigType<T>::parse(value);
-  this->isdefault = false;
+  this->unsetDefault();
   this->update();
 }
 
   this->update();
 }