File kernel/src/utils/SiconosMemory/SiconosMemory.hpp#

Go to the source code of this file

class SiconosMemory

Typedefs

typedef std::vector<SiconosVector> MemoryContainer#

Container used to save vectors in SiconosMemory.

typedef std::vector<SiconosMemory> VectorOfMemories#

a set of memory vectors

class SiconosMemory : public MemoryContainer
#include <SiconosMemory.hpp>

Interface to stl container of SiconosVector.

This class is used as a backup during simulation, to save vectors (e.g. state) computed during previous time steps.

  • The size of the container is fixed, with a first-in first-out mechanism used through swap method.

  • All saved vectors must have the same dimension.

This class must be reviewed and backup should probably be moved to graph rather than in this object.

Public Functions

SiconosMemory() = default

creates an empty SiconosMemory.

SiconosMemory(const unsigned int size, const unsigned int vectorSize)

creates a SiconosMemory

Parameters:
  • size – number of elements in the container

  • vectorSize – size of each vector in the container

SiconosMemory(const SiconosMemory &mem)

creates a SiconosMemory, copy constructor Required because of resize call in DS initMemory function.

Parameters:

mem – a SiconosMemory

inline ~SiconosMemory()

destructor

void operator=(const SiconosMemory&)

Assignment.

const SiconosVector &getSiconosVector(const unsigned int) const

To get SiconosVector number i of the memory.

Parameters:

int – i: the position in the memory of the wanted SiconosVector

Returns:

a SP::SiconosVector

SiconosVector &getSiconosVectorMutable(const unsigned int)

To get SiconosVector number i of the memory as mutable reference.

Use should be avoided whenever possible. (Used in LinearSMC::actuate)

Parameters:

int – i: the position in the memory of the wanted SiconosVector

Returns:

a SP::SiconosVector

void setMemorySize(const unsigned int steps, const unsigned int vectorSize)

set size of the SiconosMemory (number of vectors and size of vector)

Parameters:
  • steps – the max size for this SiconosMemory, size of the container

  • vectorSize – size of each vector of the container

inline MemoryContainer::size_type nbVectorsInMemory() const

gives the numbers of SiconosVectors currently stored in the memory

Returns:

int >= 0

void swap(const SiconosVector &v)

puts a SiconosVector into the memory

Parameters:

v – the SiconosVector we want to put in memory

void swap(SP::SiconosVector v)

puts a SiconosVector into the memory

Parameters:

v – the SiconosVector we want to put in memory, or do nothing if v is null

void display() const

displays the data of the memory object

Private Functions

ACCEPT_SERIALIZATION(SiconosMemory)#
SiconosMemory(const MemoryContainer&) = delete#
void operator=(const MemoryContainer &V)#

Private Members

MemoryContainer::size_type _nbVectorsInMemory = 0#

the real number of SiconosVectors saved in the Memory (ie the ones for which memory has been allocated)

MemoryContainer::size_type _indx = 0#

index to avoid removal and creation of vectors.

this[_indx] is to the oldest element in the set