SimGrid
3.13
Versatile Simulation of Distributed Systems
|
An Extendable is an object that you can extend with external elements. More...
#include <Extendable.hpp>
Public Member Functions | |
Extendable () | |
~Extendable () | |
void * | extension (std::size_t rank) |
void | extension_set (std::size_t rank, void *value, bool use_dtor=true) |
template<class U > | |
U * | extension (Extension< T, U > rank) |
template<class U > | |
void | extension_set (Extension< T, U > rank, U *value, bool use_dtor=true) |
template<class U > | |
U * | extension () |
template<class U > | |
void | extension_set (U *p) |
Static Public Member Functions | |
static size_t | extension_create (void(*deleter)(void *)) |
template<class U > | |
static Extension< T, U > | extension_create (void(*deleter)(void *)) |
template<class U > | |
static Extension< T, U > | extension_create () |
Protected Attributes | |
std::vector< void * > | extensions_ |
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.
|
inline |
|
inline |
|
inlinestatic |
|
inlinestatic |
|
inlinestatic |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
protected |