Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
rename facets to extensions for clarity sake
authorMartin Quinson <martin.quinson@loria.fr>
Fri, 18 Dec 2015 23:39:49 +0000 (00:39 +0100)
committerMartin Quinson <martin.quinson@loria.fr>
Fri, 18 Dec 2015 23:39:49 +0000 (00:39 +0100)
22 files changed:
include/simgrid/Host.hpp
include/simgrid/host.h
include/xbt/Extendable.hpp [new file with mode: 0644]
include/xbt/Facetable.hpp [deleted file]
src/bindings/java/jmsg.cpp
src/bindings/java/jmsg_as.cpp
src/bindings/java/jmsg_host.cpp
src/bindings/java/jmsg_task.cpp
src/bindings/java/jmsg_vm.cpp
src/include/surf/surf.h
src/simgrid/host.cpp
src/simgrid/sg_config.c
src/surf/cpu_interface.cpp
src/surf/cpu_interface.hpp
src/surf/host_interface.cpp
src/surf/host_interface.hpp
src/surf/ns3/ns3_interface.h
src/surf/surf_c_bindings.cpp
src/surf/surf_routing.cpp
src/surf/surf_routing_vivaldi.cpp
src/surf/virtual_machine.cpp
tools/cmake/DefinePackages.cmake

index e1d2999..c887ee7 100644 (file)
 #include <vector>
 
 #include <xbt/base.h>
-#include <xbt/Facetable.hpp>
 #include <xbt/string.hpp>
+#include <xbt/Extendable.hpp>
 
 namespace simgrid {
 
-XBT_PUBLIC_CLASS Host : public simgrid::xbt::Facetable<Host> {
+XBT_PUBLIC_CLASS Host : public simgrid::xbt::Extendable<Host> {
 private:
   simgrid::xbt::string id_;
 public:
index 83bba0b..1669159 100644 (file)
 SG_BEGIN_DECL()
 
 XBT_PUBLIC(size_t) sg_host_count();
-XBT_PUBLIC(size_t) sg_host_add_level(void(*deleter)(void*));
+XBT_PUBLIC(size_t) sg_host_extension_create(void(*deleter)(void*));
+XBT_PUBLIC(void*) sg_host_extension_get(sg_host_t host, size_t rank);
 XBT_PUBLIC(sg_host_t) sg_host_by_name(const char *name);
 XBT_PUBLIC(sg_host_t) sg_host_by_name_or_create(const char *name);
-XBT_PUBLIC(void*) sg_host_get_facet(sg_host_t host, size_t facet);
 XBT_PUBLIC(const char*) sg_host_get_name(sg_host_t host);
 XBT_PUBLIC(xbt_dynar_t) sg_hosts_as_dynar(void);
 
diff --git a/include/xbt/Extendable.hpp b/include/xbt/Extendable.hpp
new file mode 100644 (file)
index 0000000..81e7150
--- /dev/null
@@ -0,0 +1,125 @@
+/* Copyright (c) 2015. 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. */
+
+#ifndef SIMGRID_XBT_LIB_HPP
+#define SIMGRID_XBT_LIB_HPP
+
+#include <cstddef>
+#include <limits>
+#include <vector>
+
+namespace simgrid {
+namespace xbt {
+
+template<class T, class U> class Extension;
+template<class T>          class Extendable;
+
+template<class T, class U>
+class Extension {
+  static const std::size_t INVALID_ID = std::numeric_limits<std::size_t>::max();
+  std::size_t id_;
+  friend class Extendable<T>;
+  constexpr Extension(std::size_t id) : id_(id) {}
+public:
+  constexpr Extension() : id_(INVALID_ID) {}
+  std::size_t id() const { return id_; }
+  bool valid() { return id_ != INVALID_ID; }
+};
+
+/** An Extendable is an object that you can extend with external elements.
+ *
+ * An Extension is one dimension of such extension. They are similar to the concept of mixins, that is, a set of behavior that is injected into a class without derivation.
+ *
+ * Imagine that you want to write a plugin dealing with the energy in SimGrid.
+ * You will have to store some information about each and every host.
+ *
+ * You could modify the Host class directly (but your code will soon become messy).
+ * You could create a class EnergyHost deriving Host, but it is not easily combinable
+ *    with a notion of Host extended with another concept (such as mobility).
+ * You could completely externalize these data with an associative map Host->EnergyHost.
+ *    It would work, provided that you implement this classical feature correctly (and it would induce a little performance penalty).
+ * Instead, you should add a new facet to the Host class, that happens to be Facetable.
+ *
+ */
+template<class T>
+class Extendable {
+private:
+  static std::vector<void(*)(void*)> deleters_;
+protected:
+  std::vector<void*> extensions_;
+public:
+  static size_t extension_create(void (*deleter)(void*))
+  {
+    std::size_t res = deleters_.size();
+    deleters_.push_back(deleter);
+    return res;
+  }
+  template<class U>
+  static Extension<T,U> extension_create(void (*deleter)(void*))
+  {
+    return Extension<T,U>(extension_create(deleter));
+  }
+  template<class U> static
+  Extension<T,U> extension_create()
+  {
+    return extension_create([](void* p){ delete static_cast<U*>(p); });
+  }
+  Extendable() : extensions_(deleters_.size(), nullptr) {}
+  ~Extendable()
+  {
+    /* Call destructors in reverse order of their registrations
+     *
+     * The rationale for this, is that if an extension B as been added after
+     * an extension A, the subsystem of B might depend on the subsystem on A and
+     * an extension of B might need to have the extension of A around when executing
+     * its cleanup function/destructor. */
+    for (std::size_t i = extensions_.size(); i > 0; --i)
+      if (extensions_[i - 1] != nullptr)
+        deleters_[i - 1](extensions_[i - 1]);
+  }
+
+  // Type-unsafe versions of the facet access methods:
+  void* extension(std::size_t rank)
+  {
+    if (rank >= extensions_.size())
+      return nullptr;
+    else
+      return extensions_.at(rank);
+  }
+  void extension_set(std::size_t rank, void* value, bool use_dtor = true)
+  {
+    if (rank >= extensions_.size())
+      extensions_.resize(rank + 1, nullptr);
+    void* old_value = this->extension(rank);
+    extensions_.at(rank) = value;
+    if (use_dtor && old_value != nullptr && deleters_[rank])
+      deleters_[rank](old_value);
+  }
+
+  // Type safe versions of the facet access methods:
+  template<class U>
+  U* extension(Extension<T,U> rank)
+  {
+    return static_cast<U*>(extension(rank.id()));
+  }
+  template<class U>
+  void extension_set(Extension<T,U> rank, U* value, bool use_dtor = true)
+  {
+    extension_set(rank.id(), value, use_dtor);
+  }
+
+  // Convenience extension access when the type has a associated EXTENSION ID:
+  template<class U> U* extension()           { return extension<U>(U::EXTENSION_ID); }
+  template<class U> void extension_set(U* p) { extension_set<U>(U::EXTENSION_ID, p); }
+};
+
+template<class T>
+std::vector<void(*)(void*)> Extendable<T>::deleters_ = {};
+
+}
+}
+
+#endif
diff --git a/include/xbt/Facetable.hpp b/include/xbt/Facetable.hpp
deleted file mode 100644 (file)
index 34bd072..0000000
+++ /dev/null
@@ -1,125 +0,0 @@
-/* Copyright (c) 2015. 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. */
-
-#ifndef SIMGRID_XBT_LIB_HPP
-#define SIMGRID_XBT_LIB_HPP
-
-#include <cstddef>
-#include <limits>
-#include <vector>
-
-namespace simgrid {
-namespace xbt {
-
-template<class T, class U> class FacetLevel;
-template<class T>          class Facetable;
-
-template<class T, class U>
-class FacetLevel {
-  static const std::size_t INVALID_ID = std::numeric_limits<std::size_t>::max();
-  std::size_t id_;
-  friend class Facetable<T>;
-  constexpr FacetLevel(std::size_t id) : id_(id) {}
-public:
-  constexpr FacetLevel() : id_(INVALID_ID) {}
-  std::size_t id() const { return id_; }
-  bool valid() { return id_ != INVALID_ID; }
-};
-
-/** A Facetable is an object that you can extend with external facets.
- *
- * Facets are similar to the concept of mixins, that is, a set of behavior that is injected into a class without derivation.
- *
- * Imagine that you want to write a plugin dealing with the energy in SimGrid.
- * You will have to store some information about each and every host.
- *
- * You could modify the Host class directly (but your code will soon become messy).
- * You could create a class EnergyHost deriving Host, but it is not easily combinable
- *    with a notion of Host extended with another concept (such as mobility).
- * You could completely externalize these data with an associative map Host->EnergyHost.
- *    It would work, provided that you implement this classical feature correctly (and it would induce a little performance penalty).
- * Instead, you should add a new facet to the Host class, that happens to be Facetable.
- *
- */
-template<class T>
-class Facetable {
-private:
-  static std::vector<void(*)(void*)> deleters_;
-protected:
-  std::vector<void*> facets_;
-public:
-  static size_t add_level(void (*deleter)(void*))
-  {
-    std::size_t res = deleters_.size();
-    deleters_.push_back(deleter);
-    return res;
-  }
-  template<class U>
-  static FacetLevel<T,U> add_level(void (*deleter)(void*))
-  {
-    return FacetLevel<T,U>(add_level(deleter));
-  }
-  template<class U> static
-  FacetLevel<T,U> add_level()
-  {
-    return add_level([](void* p){ delete static_cast<U*>(p); });
-  }
-  Facetable() : facets_(deleters_.size(), nullptr) {}
-  ~Facetable()
-  {
-    /* Call destructors in reverse order of their registrations
-     *
-     * The rationale for this, is that if a level B as been added after a
-     * facet A, the subsystem of B might depend on the subsystem on A and a
-     * facet of B might need to have the facet of A around when executing
-     * its cleanup function/destructor. */
-    for (std::size_t i = facets_.size(); i > 0; --i)
-      if (facets_[i - 1] != nullptr)
-        deleters_[i - 1](facets_[i - 1]);
-  }
-
-  // Type-unsafe versions of the facet access methods:
-  void* facet(std::size_t level)
-  {
-    if (level >= facets_.size())
-      return nullptr;
-    else
-      return facets_.at(level);
-  }
-  void set_facet(std::size_t level, void* value, bool use_dtor = true)
-  {
-    if (level >= facets_.size())
-      facets_.resize(level + 1, nullptr);
-    void* old_value = this->facet(level);
-    facets_.at(level) = value;
-    if (use_dtor && old_value != nullptr && deleters_[level])
-      deleters_[level](old_value);
-  }
-
-  // Type safe versions of the facet access methods:
-  template<class U>
-  U* facet(FacetLevel<T,U> level)
-  {
-    return static_cast<U*>(facet(level.id()));
-  }
-  template<class U>
-  void set_facet(FacetLevel<T,U> level, U* value, bool use_dtor = true)
-  {
-    set_facet(level.id(), value, use_dtor);
-  }
-
-  // Convnience facet access when the type has a associated LEVEL:
-  template<class U> U* facet()           { return facet<U>(U::LEVEL); }
-  template<class U> void set_facet(U* p) { set_facet<U>(U::LEVEL, p); }
-};
-
-template<class T>
-std::vector<void(*)(void*)> Facetable<T>::deleters_ = {};
-
-}
-}
-
-#endif
index 90461fb..1b700b7 100644 (file)
@@ -134,7 +134,7 @@ Java_org_simgrid_msg_Msg_init(JNIEnv * env, jclass cls, jobjectArray jargs)
 
   MSG_init(&argc, argv);
 
-  JAVA_HOST_LEVEL = simgrid::Host::add_level(__JAVA_host_priv_free);
+  JAVA_HOST_LEVEL = simgrid::Host::extension_create(__JAVA_host_priv_free);
   JAVA_STORAGE_LEVEL = xbt_lib_add_level(storage_lib, __JAVA_storage_priv_free);
 
   for (index = 0; index < argc; index++)
@@ -158,7 +158,7 @@ JNIEXPORT void JNICALL
   xbt_dynar_t hosts = MSG_hosts_as_dynar();
   for (unsigned long index = 0; index < xbt_dynar_length(hosts) - 1; index++) {
     msg_host_t msg_host = xbt_dynar_get_as(hosts,index,msg_host_t);
-    jobject jhost = (jobject) msg_host->facet(JAVA_HOST_LEVEL);
+    jobject jhost = (jobject) msg_host->extension(JAVA_HOST_LEVEL);
     if (jhost)
       jhost_unref(env, jhost);
 
index b7d9cd8..474bccd 100644 (file)
@@ -161,7 +161,7 @@ Java_org_simgrid_msg_As_getHosts(JNIEnv * env, jobject jas)
 
     host = xbt_dynar_get_as(table,index,msg_host_t);
 
-    jhost = (jobject) host->facet(JAVA_HOST_LEVEL);
+    jhost = (jobject) host->extension(JAVA_HOST_LEVEL);
     if (!jhost) {
       jname = env->NewStringUTF(MSG_host_get_name(host));
 
index 9eb8312..accb02e 100644 (file)
@@ -86,7 +86,7 @@ Java_org_simgrid_msg_Host_getByName(JNIEnv * env, jclass cls,
   }
   env->ReleaseStringUTFChars(jname, name);
 
-  if (!host->facet(JAVA_HOST_LEVEL)) {       /* native host not associated yet with java host */
+  if (!host->extension(JAVA_HOST_LEVEL)) {       /* native host not associated yet with java host */
 
     /* Instantiate a new java host */
     jhost = jhost_new_instance(env);
@@ -111,11 +111,11 @@ Java_org_simgrid_msg_Host_getByName(JNIEnv * env, jclass cls,
     /* the native host data field is set with the global reference to the
      * java host returned by this function
      */
-    host->set_facet(JAVA_HOST_LEVEL, (void *)jhost);
+    host->extension_set(JAVA_HOST_LEVEL, (void *)jhost);
   }
 
   /* return the global reference to the java host instance */
-  return (jobject) host->facet(JAVA_HOST_LEVEL);
+  return (jobject) host->extension(JAVA_HOST_LEVEL);
 }
 
 JNIEXPORT jobject JNICALL
@@ -124,7 +124,7 @@ Java_org_simgrid_msg_Host_currentHost(JNIEnv * env, jclass cls) {
 
   msg_host_t host = MSG_host_self();
 
-  if (!host->facet(JAVA_HOST_LEVEL)) {
+  if (!host->extension(JAVA_HOST_LEVEL)) {
     /* the native host not yet associated with the java host instance */
 
     /* instanciate a new java host instance */
@@ -148,9 +148,9 @@ Java_org_simgrid_msg_Host_currentHost(JNIEnv * env, jclass cls) {
     env->SetObjectField(jhost, jhost_field_Host_name, jname);
     /* Bind & store it */
     jhost_bind(jhost, host, env);
-    host->set_facet(JAVA_HOST_LEVEL, (void *) jhost);
+    host->extension_set(JAVA_HOST_LEVEL, (void *) jhost);
   } else {
-    jhost = (jobject) host->facet(JAVA_HOST_LEVEL);
+    jhost = (jobject) host->extension(JAVA_HOST_LEVEL);
   }
 
   return jhost;
@@ -357,7 +357,7 @@ Java_org_simgrid_msg_Host_all(JNIEnv * env, jclass cls_arg)
 
   for (index = 0; index < count; index++) {
     host = xbt_dynar_get_as(table,index,msg_host_t);
-    jhost = (jobject) host->facet(JAVA_HOST_LEVEL);
+    jhost = (jobject) host->extension(JAVA_HOST_LEVEL);
 
     if (!jhost) {
       jname = env->NewStringUTF(MSG_host_get_name(host));
index cd22641..fb1a948 100644 (file)
@@ -282,12 +282,12 @@ Java_org_simgrid_msg_Task_getSource(JNIEnv * env,
   if (host == NULL) {
        return NULL;
   }
-  if (!host->facet(JAVA_HOST_LEVEL)) {
+  if (!host->extension(JAVA_HOST_LEVEL)) {
     jxbt_throw_jni(env, "MSG_task_get_source() failed");
     return NULL;
   }
 
-  return (jobject) host->facet(JAVA_HOST_LEVEL);
+  return (jobject) host->extension(JAVA_HOST_LEVEL);
 }
 
 JNIEXPORT jdouble JNICALL
index 0258585..84e8058 100644 (file)
@@ -167,7 +167,7 @@ Java_org_simgrid_msg_VM_get_pm(JNIEnv *env, jobject jvm) {
   msg_vm_t vm = jvm_get_native(env,jvm);
   msg_host_t host = MSG_vm_get_pm(vm);
 
-  if (!host->facet(JAVA_HOST_LEVEL)) {
+  if (!host->extension(JAVA_HOST_LEVEL)) {
     /* the native host not yet associated with the java host instance */
 
     /* instanciate a new java host instance */
@@ -193,9 +193,9 @@ Java_org_simgrid_msg_VM_get_pm(JNIEnv *env, jobject jvm) {
       jname);
     /* Bind & store it */
     jhost_bind(jhost, host, env);
-    host->set_facet(JAVA_HOST_LEVEL, (void *) jhost);
+    host->extension_set(JAVA_HOST_LEVEL, (void *) jhost);
   } else {
-    jhost = (jobject) host->facet(JAVA_HOST_LEVEL);
+    jhost = (jobject) host->extension(JAVA_HOST_LEVEL);
   }
 
   return jhost;
index 5e01fde..784d1aa 100644 (file)
@@ -200,7 +200,7 @@ XBT_PUBLIC_DATA(routing_platf_t) routing_platf;
 
 static inline surf_host_t surf_host_resource_priv(sg_host_t host)
 {
-  return (surf_host_t) sg_host_get_facet(host, SURF_HOST_LEVEL);
+  return (surf_host_t) sg_host_extension_get(host, SURF_HOST_LEVEL);
 }
 static inline void *surf_storage_resource_priv(const void *storage){
   return (void*)xbt_lib_get_level((xbt_dictelm_t)storage, SURF_STORAGE_LEVEL);
index c4c9f20..9b00223 100644 (file)
@@ -14,19 +14,19 @@ size_t sg_host_count()
   return xbt_dict_length(host_list);
 }
 
-void* sg_host_get_facet(sg_host_t host, size_t facet)
+const char *sg_host_get_name(sg_host_t host)
 {
-  return host->facet(facet);
+       return host->id().c_str();
 }
 
-const char *sg_host_get_name(sg_host_t host)
+void* sg_host_extension_get(sg_host_t host, size_t ext)
 {
-       return host->id().c_str();
+  return host->extension(ext);
 }
 
-size_t sg_host_add_level(void(*deleter)(void*))
+size_t sg_host_extension_create(void(*deleter)(void*))
 {
-  return simgrid::Host::add_level(deleter);
+  return simgrid::Host::extension_create(deleter);
 }
 
 sg_host_t sg_host_by_name(const char *name)
@@ -75,78 +75,78 @@ static XBT_INLINE void routing_asr_host_free(void *p) {
 
 void sg_host_init()
 {
-  MSG_HOST_LEVEL = simgrid::Host::add_level([](void *p) {
+  MSG_HOST_LEVEL = simgrid::Host::extension_create([](void *p) {
     __MSG_host_priv_free((msg_host_priv_t) p);
   });
-  SD_HOST_LEVEL = simgrid::Host::add_level(__SD_workstation_destroy);
-  SIMIX_HOST_LEVEL = simgrid::Host::add_level(SIMIX_host_destroy);
+  SD_HOST_LEVEL = simgrid::Host::extension_create(__SD_workstation_destroy);
+  SIMIX_HOST_LEVEL = simgrid::Host::extension_create(SIMIX_host_destroy);
   simgrid::surf::Cpu::init();
-  ROUTING_HOST_LEVEL = simgrid::Host::add_level(routing_asr_host_free);
-  USER_HOST_LEVEL = simgrid::Host::add_level(NULL);
+  ROUTING_HOST_LEVEL = simgrid::Host::extension_create(routing_asr_host_free);
+  USER_HOST_LEVEL = simgrid::Host::extension_create(NULL);
 }
 
 // ========== User data Layer ==========
 void *sg_host_user(sg_host_t host) {
-  return host->facet(USER_HOST_LEVEL);
+  return host->extension(USER_HOST_LEVEL);
 }
 void sg_host_user_set(sg_host_t host, void* userdata) {
-  host->set_facet(USER_HOST_LEVEL,userdata);
+  host->extension_set(USER_HOST_LEVEL,userdata);
 }
 void sg_host_user_destroy(sg_host_t host) {
-  host->set_facet(USER_HOST_LEVEL, nullptr);
+  host->extension_set(USER_HOST_LEVEL, nullptr);
 }
 
 // ========== MSG Layer ==============
 msg_host_priv_t sg_host_msg(sg_host_t host) {
-       return (msg_host_priv_t) host->facet(MSG_HOST_LEVEL);
+       return (msg_host_priv_t) host->extension(MSG_HOST_LEVEL);
 }
 void sg_host_msg_set(sg_host_t host, msg_host_priv_t smx_host) {
-  host->set_facet(MSG_HOST_LEVEL, smx_host);
+  host->extension_set(MSG_HOST_LEVEL, smx_host);
 }
 void sg_host_msg_destroy(sg_host_t host) {
-  host->set_facet(MSG_HOST_LEVEL, nullptr);
+  host->extension_set(MSG_HOST_LEVEL, nullptr);
 }
 // ========== SimDag Layer ==============
 SD_workstation_priv_t sg_host_sd(sg_host_t host) {
-  return (SD_workstation_priv_t) host->facet(SD_HOST_LEVEL);
+  return (SD_workstation_priv_t) host->extension(SD_HOST_LEVEL);
 }
 void sg_host_sd_set(sg_host_t host, SD_workstation_priv_t smx_host) {
-  host->set_facet(SD_HOST_LEVEL, smx_host);
+  host->extension_set(SD_HOST_LEVEL, smx_host);
 }
 void sg_host_sd_destroy(sg_host_t host) {
-  host->set_facet(SD_HOST_LEVEL, nullptr);
+  host->extension_set(SD_HOST_LEVEL, nullptr);
 }
 
 // ========== Simix layer =============
 smx_host_priv_t sg_host_simix(sg_host_t host){
-  return (smx_host_priv_t) host->facet(SIMIX_HOST_LEVEL);
+  return (smx_host_priv_t) host->extension(SIMIX_HOST_LEVEL);
 }
 void sg_host_simix_set(sg_host_t host, smx_host_priv_t smx_host) {
-  host->set_facet(SIMIX_HOST_LEVEL, smx_host);
+  host->extension_set(SIMIX_HOST_LEVEL, smx_host);
 }
 void sg_host_simix_destroy(sg_host_t host) {
-  host->set_facet(SIMIX_HOST_LEVEL, nullptr);
+  host->extension_set(SIMIX_HOST_LEVEL, nullptr);
 }
 
 // ========== SURF CPU ============
 surf_cpu_t sg_host_surfcpu(sg_host_t host) {
-       return host->facet<simgrid::surf::Cpu>();
+       return host->extension<simgrid::surf::Cpu>();
 }
 void sg_host_surfcpu_set(sg_host_t host, surf_cpu_t cpu) {
-  host->set_facet(simgrid::surf::Cpu::LEVEL, cpu);
+  host->extension_set(simgrid::surf::Cpu::EXTENSION_ID, cpu); // FIXME: use the typesafe version
 }
 void sg_host_surfcpu_destroy(sg_host_t host) {
-  host->set_facet<simgrid::surf::Cpu>(nullptr);
+  host->extension_set<simgrid::surf::Cpu>(nullptr);
 }
 // ========== RoutingEdge ============
 surf_RoutingEdge *sg_host_edge(sg_host_t host) {
-       return (surf_RoutingEdge*) host->facet(ROUTING_HOST_LEVEL);
+       return (surf_RoutingEdge*) host->extension(ROUTING_HOST_LEVEL);
 }
 void sg_host_edge_set(sg_host_t host, surf_RoutingEdge *edge) {
-  host->set_facet(ROUTING_HOST_LEVEL, edge);
+  host->extension_set(ROUTING_HOST_LEVEL, edge);
 }
 void sg_host_edge_destroy(sg_host_t host, int do_callback) {
-  host->set_facet(ROUTING_HOST_LEVEL, nullptr, do_callback);
+  host->extension_set(ROUTING_HOST_LEVEL, nullptr, do_callback);
 }
 
 // =========== user-level functions ===============
index c203424..7836066 100644 (file)
@@ -456,7 +456,7 @@ static void _sg_cfg_cb__surf_network_coordinates(const char *name,
   int val = xbt_cfg_get_boolean(_sg_cfg_set, name);
   if (val) {
     if (!already_set) {
-      COORD_HOST_LEVEL = sg_host_add_level(xbt_dynar_free_voidp);
+      COORD_HOST_LEVEL = sg_host_extension_create(xbt_dynar_free_voidp);
       COORD_ASR_LEVEL  = xbt_lib_add_level(as_router_lib,xbt_dynar_free_voidp);
     }
     already_set = 1;
index feca411..2f1f7df 100644 (file)
@@ -20,12 +20,12 @@ simgrid::surf::CpuModel *surf_cpu_model_vm;
 namespace simgrid {
 namespace surf {
 
-simgrid::xbt::FacetLevel<simgrid::Host, Cpu> Cpu::LEVEL;
+simgrid::xbt::Extension<simgrid::Host, Cpu> Cpu::EXTENSION_ID;
 
 void Cpu::init()
 {
-  if (!LEVEL.valid())
-    LEVEL = simgrid::Host::add_level<simgrid::surf::Cpu>();
+  if (!EXTENSION_ID.valid())
+    EXTENSION_ID = simgrid::Host::extension_create<simgrid::surf::Cpu>();
 }
 
 /*************
@@ -241,8 +241,8 @@ void Cpu::setState(e_surf_resource_state_t state)
 void Cpu::plug(simgrid::Host* host)
 {
   if (this->m_host != nullptr)
-    xbt_die("Aleady plugged into host %s", host->id().c_str());
-  host->set_facet(this);
+    xbt_die("Already plugged into host %s", host->id().c_str());
+  host->extension_set(this);
   this->m_host = host;
   simgrid::surf::cpuCreatedCallbacks(this);
   simgrid::surf::cpuStateChangedCallbacks(this,
index 80564a2..5e4aece 100644 (file)
@@ -98,7 +98,7 @@ public:
 */
 XBT_PUBLIC_CLASS Cpu : public simgrid::surf::Resource {
 public:
-  static simgrid::xbt::FacetLevel<simgrid::Host, Cpu> LEVEL;
+  static simgrid::xbt::Extension<simgrid::Host, Cpu> EXTENSION_ID;
   static void init();
   Cpu();
 
index 54d562f..0dcf34b 100644 (file)
@@ -31,7 +31,7 @@ void host_add_traces(){
 namespace simgrid {
 namespace surf {
 
-simgrid::xbt::FacetLevel<simgrid::Host, Host> Host::LEVEL;
+simgrid::xbt::Extension<simgrid::Host, Host> Host::EXTENSION_ID;
 
 simgrid::surf::signal<void(simgrid::surf::Host*)> hostCreatedCallbacks;
 simgrid::surf::signal<void(simgrid::surf::Host*)> hostDestructedCallbacks;
@@ -83,9 +83,9 @@ void HostModel::adjustWeightOfDummyCpuActions()
 
 void Host::init()
 {
-  if (!LEVEL.valid()) {
-    LEVEL = simgrid::Host::add_level<simgrid::surf::Host>();
-    SURF_HOST_LEVEL = LEVEL.id();
+  if (!EXTENSION_ID.valid()) {
+    EXTENSION_ID = simgrid::Host::extension_create<simgrid::surf::Host>();
+    SURF_HOST_LEVEL = EXTENSION_ID.id(); // FIXME: KILLME
   }
 }
 
@@ -122,7 +122,7 @@ void Host::attach(simgrid::Host* host)
 {
   if (p_host != nullptr)
     xbt_die("Already attached to host %s", host->id().c_str());
-  host->set_facet(this);
+  host->extension_set(this);
   p_host = host;
   hostCreatedCallbacks(this);
 }
index a7c6b51..2aa6669 100644 (file)
@@ -97,7 +97,7 @@ public:
  */
 class Host : public simgrid::surf::Resource, public simgrid::surf::PropertyHolder {
 public:
-  static simgrid::xbt::FacetLevel<simgrid::Host, Host> LEVEL;
+  static simgrid::xbt::Extension<simgrid::Host, Host> EXTENSION_ID;
   static void init();
   /**
    * @brief Host constructor
index 8043743..36c8aa7 100644 (file)
@@ -56,7 +56,7 @@ ns3_nodes_t ns3_find_host(const char* id)
   if (host == nullptr)
     return nullptr;
   else
-    return (ns3_nodes_t) sg_host_get_facet(host, NS3_HOST_LEVEL);
+    return (ns3_nodes_t) sg_host_get_extension(host, NS3_HOST_LEVEL);
 }
 
 SG_END_DECL()
index bc658f3..c709cca 100644 (file)
@@ -171,7 +171,7 @@ void routing_get_route_and_latency(sg_routing_edge_t src, sg_routing_edge_t dst,
 surf_host_model_t surf_host_get_model(sg_host_t host)
 {
   simgrid::surf::Host* surf_host =
-    (simgrid::surf::Host*) host->facet<simgrid::surf::Host>();
+    (simgrid::surf::Host*) host->extension<simgrid::surf::Host>();
   return (surf_host_model_t) surf_host->getModel();
 }
 
@@ -393,10 +393,10 @@ void surf_vm_destroy(sg_host_t resource){
    */
   sg_host_surfcpu_destroy(resource);
   sg_host_edge_destroy(resource,1);
-  resource->set_facet<simgrid::surf::Host>(nullptr);
+  resource->extension_set<simgrid::surf::Host>(nullptr);
 
   /* TODO: comment out when VM storage is implemented. */
-  // host->set_facet(SURF_STORAGE_LEVEL, nullptr);
+  // host->extension_set(SURF_STORAGE_LEVEL, nullptr);
 }
 
 void surf_vm_suspend(sg_host_t vm){
index 0d3e36c..dbc30ef 100644 (file)
@@ -197,7 +197,7 @@ simgrid::surf::RoutingEdge *routing_add_host(
     }
     xbt_dynar_shrink(ctn, 0);
     xbt_dynar_free(&ctn_str);
-    h->set_facet(COORD_HOST_LEVEL, (void *) ctn);
+    h->extension_set(COORD_HOST_LEVEL, (void *) ctn);
     XBT_DEBUG("Having set host coordinates for '%s'",host->id);
   }
 
index 3281f1e..d47f4ed 100644 (file)
@@ -57,9 +57,9 @@ void AsVivaldi::getRouteAndLatency(RoutingEdge *src, RoutingEdge *dst, sg_platf_
           *lat += static_cast<Link*>(info.link_up)->getLatency();
       }
     }
-    src_ctn = (xbt_dynar_t) simgrid::Host::by_name_or_create(tmp_src_name)->facet(COORD_HOST_LEVEL);
+    src_ctn = (xbt_dynar_t) simgrid::Host::by_name_or_create(tmp_src_name)->extension(COORD_HOST_LEVEL);
     if (src_ctn == nullptr)
-      src_ctn = (xbt_dynar_t) simgrid::Host::by_name_or_create(src->getName())->facet(COORD_HOST_LEVEL);
+      src_ctn = (xbt_dynar_t) simgrid::Host::by_name_or_create(src->getName())->extension(COORD_HOST_LEVEL);
   }
   else if(src->getRcType() == SURF_NETWORK_ELEMENT_ROUTER || src->getRcType() == SURF_NETWORK_ELEMENT_AS){
     tmp_src_name = ROUTER_PEER(src->getName());
@@ -81,10 +81,10 @@ void AsVivaldi::getRouteAndLatency(RoutingEdge *src, RoutingEdge *dst, sg_platf_
       }
     }
     dst_ctn = (xbt_dynar_t) simgrid::Host::by_name_or_create(tmp_dst_name)
-      ->facet(COORD_HOST_LEVEL);
+      ->extension(COORD_HOST_LEVEL);
     if (dst_ctn == nullptr)
       dst_ctn = (xbt_dynar_t) simgrid::Host::by_name_or_create(dst->getName())
-        ->facet(COORD_HOST_LEVEL);
+        ->extension(COORD_HOST_LEVEL);
   }
   else if(dst->getRcType() == SURF_NETWORK_ELEMENT_ROUTER || dst->getRcType() == SURF_NETWORK_ELEMENT_AS){
     tmp_dst_name = ROUTER_PEER(dst->getName());
index 9eab02c..37b24e7 100644 (file)
@@ -38,7 +38,7 @@ VirtualMachine::VirtualMachine(Model *model, const char *name, xbt_dict_t props,
 : Host(model, name, props, NULL, netElm, cpu)
 {
   VMModel::ws_vms.push_back(*this);
-  simgrid::Host::by_name_or_create(name)->set_facet<simgrid::surf::Host>(this);
+  simgrid::Host::by_name_or_create(name)->extension_set<simgrid::surf::Host>(this);
 }
 
 /*
index 0bc0ae4..5533efe 100644 (file)
@@ -755,7 +755,7 @@ set(headers_to_install
   include/xbt/hash.h
   include/xbt/heap.h
   include/xbt/lib.h
-  include/xbt/Facetable.hpp
+  include/xbt/Extendable.hpp
   include/xbt/log.h
   include/xbt/mallocator.h
   include/xbt/matrix.h