TuringSim
C++ framework to simulate abstract computing models
Public Member Functions | Protected Attributes | List of all members
TuringSim::Memory::MemoryModifier< Memory, Modifier > Class Template Reference

Base class for all memory modifiers. More...

#include <memory/memoryStructure.h>

Public Member Functions

 MemoryModifier ()
 Default constructor that binds no memory structure.
 
 MemoryModifier (Memory *m)
 Constructor that binds to a memory structure. More...
 
 MemoryModifier (const MemoryModifier &other)=delete
 Copy constructor is deleted because a memory structure should have only one modifier.
 
 MemoryModifier (MemoryModifier &&other)
 Move constructor. More...
 
MemoryModifieroperator= (MemoryModifier &)=delete
 Copy assignment operator is deleted because a memory structure should have only one modifier.
 
MemoryModifieroperator= (MemoryModifier &&other)
 Move assignment operator. More...
 
 ~MemoryModifier ()
 Destruct a modifier and release the memory structure.
 
void acquire (Memory *toAcquire)
 Bind a new memory structure. More...
 
void force_acquire (Memory *toAcquire)
 Bind a new memory structure. More...
 
void unsafe_release ()
 Releases the current observed memory, without checking if there is some. More...
 
void release ()
 Releases the current bounded memory if there is one. Otherwise, does nothing.
 
bool empty () const noexcept
 Check if *this is bounded to a memory. More...
 

Protected Attributes

Memory * memory
 The observed memory. More...
 

Detailed Description

template<typename Memory, typename Modifier>
class TuringSim::Memory::MemoryModifier< Memory, Modifier >

Base class for all memory modifiers.

Template Parameters
MemoryThe type of the bounded memory structure.
ModifierThe type the modifier.

Modifiers of this class are known by the memory structure it is bounded to. Consequently, when it is deleted, it can release its modifier. Moreover, this mechanism ensures that at most on modifier is bounded to a given memory structure.

Definition at line 307 of file memoryStructure.h.

Constructor & Destructor Documentation

◆ MemoryModifier() [1/2]

template<typename Memory , typename Modifier >
TuringSim::Memory::MemoryModifier< Memory, Modifier >::MemoryModifier ( Memory *  m)
inline

Constructor that binds to a memory structure.

Parameters
mthe memory structure to modify.

Definition at line 315 of file memoryStructure.h.

Here is the call graph for this function:

◆ MemoryModifier() [2/2]

template<typename Memory , typename Modifier >
TuringSim::Memory::MemoryModifier< Memory, Modifier >::MemoryModifier ( MemoryModifier< Memory, Modifier > &&  other)
inline

Move constructor.

Parameters
[in,out]otherthe observer whose observed memory is the one we want to observe.

After the move other does not observe anything, and the memory structure still has the same number of observers.

Definition at line 328 of file memoryStructure.h.

Here is the call graph for this function:

Member Function Documentation

◆ acquire()

template<typename Memory , typename Modifier >
void TuringSim::Memory::MemoryModifier< Memory, Modifier >::acquire ( Memory *  toAcquire)
inline

Bind a new memory structure.

Parameters
[in,out]toAcquirethe memory structure to bind.
Exceptions
ExistingModifierExceptionif toAcquire is not already bounded by *this but already has a modifier.

If the memory is already bounded, nothing is done. Otherwise, if toAcquire already has another modifier, an exception is thrown. Otherwise, the currently bounded memory structure, if any, is released, and the new is bounded instead.

Definition at line 366 of file memoryStructure.h.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ empty()

template<typename Memory , typename Modifier >
bool TuringSim::Memory::MemoryModifier< Memory, Modifier >::empty ( ) const
inlinenoexcept

Check if *this is bounded to a memory.

Returns
true if and only if *this is not bounded to a memory.

Definition at line 420 of file memoryStructure.h.

◆ force_acquire()

template<typename Memory , typename Modifier >
void TuringSim::Memory::MemoryModifier< Memory, Modifier >::force_acquire ( Memory *  toAcquire)
inline

Bind a new memory structure.

Parameters
[in,out]toAcquirethe memory structure to bind.

If the memory is already bounded, nothing is done. Otherwise, if toAcquire already has another modifier, it is released. The currently bounded memory structure, if any, is released. The new memory structure is then acquired.

Definition at line 386 of file memoryStructure.h.

Here is the call graph for this function:

◆ operator=()

template<typename Memory , typename Modifier >
MemoryModifier& TuringSim::Memory::MemoryModifier< Memory, Modifier >::operator= ( MemoryModifier< Memory, Modifier > &&  other)
inline

Move assignment operator.

Parameters
[in,out]otherThe memory observer to copy
Returns
a reference to *this.

Definition at line 342 of file memoryStructure.h.

Here is the call graph for this function:

◆ unsafe_release()

template<typename Memory , typename Modifier >
void TuringSim::Memory::MemoryModifier< Memory, Modifier >::unsafe_release ( )
inline

Releases the current observed memory, without checking if there is some.

Behavior is undefined if *this does not observe anything.

Definition at line 404 of file memoryStructure.h.

Here is the caller graph for this function:

Member Data Documentation

◆ memory

template<typename Memory , typename Modifier >
Memory* TuringSim::Memory::MemoryModifier< Memory, Modifier >::memory
protected

The observed memory.

The const pointer allows only const function member to be called, but mutable data members can be modified, to manage the optional modifiers, for instance.

Definition at line 430 of file memoryStructure.h.


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