SimGrid  3.14.159
Versatile Simulation of Distributed Systems
simgrid::xbt::Extendable< T > Class Template Reference

Detailed Description

template<class T>
class simgrid::xbt::Extendable< T >

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 extension to the Host class, that happens to be Extendable.

#include <Extendable.hpp>

Public Member Functions

 Extendable ()
 
 ~Extendable ()
 
voidextension (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_
 

Constructor & Destructor Documentation

◆ Extendable()

template<class T>
simgrid::xbt::Extendable< T >::Extendable ( )
inline

◆ ~Extendable()

template<class T>
simgrid::xbt::Extendable< T >::~Extendable ( )
inline

Member Function Documentation

◆ extension_create() [1/3]

template<class T>
static size_t simgrid::xbt::Extendable< T >::extension_create ( void(*)(void *)  deleter)
inlinestatic

◆ extension_create() [2/3]

template<class T>
template<class U >
static Extension<T,U> simgrid::xbt::Extendable< T >::extension_create ( void(*)(void *)  deleter)
inlinestatic

◆ extension_create() [3/3]

template<class T>
template<class U >
static Extension<T,U> simgrid::xbt::Extendable< T >::extension_create ( )
inlinestatic

◆ extension() [1/3]

template<class T>
void* simgrid::xbt::Extendable< T >::extension ( std::size_t  rank)
inline

◆ extension_set() [1/3]

template<class T>
void simgrid::xbt::Extendable< T >::extension_set ( std::size_t  rank,
void value,
bool  use_dtor = true 
)
inline

◆ extension() [2/3]

template<class T>
template<class U >
U* simgrid::xbt::Extendable< T >::extension ( Extension< T, U >  rank)
inline

◆ extension_set() [2/3]

template<class T>
template<class U >
void simgrid::xbt::Extendable< T >::extension_set ( Extension< T, U >  rank,
U *  value,
bool  use_dtor = true 
)
inline

◆ extension() [3/3]

template<class T>
template<class U >
U* simgrid::xbt::Extendable< T >::extension ( )
inline

◆ extension_set() [3/3]

template<class T>
template<class U >
void simgrid::xbt::Extendable< T >::extension_set ( U *  p)
inline

Member Data Documentation

◆ extensions_

template<class T>
std::vector<void*> simgrid::xbt::Extendable< T >::extensions_
protected

The documentation for this class was generated from the following file: