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

Base class for all memory observers. More...

#include <memory/memoryStructure.h>

Public Member Functions

 MemoryObserver () noexcept
 Build an observer that observes nothing.
 
 MemoryObserver (const Memory *memory)
 Build an observer that observes a given memory. More...
 
 MemoryObserver (const MemoryObserver &other)
 Build a new observer to the same memory. More...
 
 MemoryObserver (MemoryObserver &&other)
 Move constructor. More...
 
MemoryObserveroperator= (MemoryObserver &other)
 Copy assignment operator. More...
 
MemoryObserveroperator= (MemoryObserver &&other)
 Move assignment operator. More...
 
 ~MemoryObserver ()
 Destruct an observer and release the memory structure.
 
void acquire (const Memory *toAcquire)
 Observe 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 observed memory if there is one. Otherwise, does nothing.
 
bool empty () const noexcept
 Check if *this observes a memory. More...
 

Protected Attributes

const Memory * memory
 The observed memory. More...
 

Detailed Description

template<typename Memory, typename Observer>
class TuringSim::Memory::MemoryObserver< Memory, Observer >

Base class for all memory observers.

Template Parameters
MemoryThe type of the memory structure observed.
ObserverThe type the observer.

Observers of this class are known by the observed memory structure. Consequently, when it is deleted, it can release observers that watch it.

Definition at line 187 of file memoryStructure.h.

Constructor & Destructor Documentation

◆ MemoryObserver() [1/3]

template<typename Memory , typename Observer >
TuringSim::Memory::MemoryObserver< Memory, Observer >::MemoryObserver ( const Memory *  memory)
inline

Build an observer that observes a given memory.

Parameters
[in]memorythe memory to observe.

Definition at line 195 of file memoryStructure.h.

Here is the call graph for this function:

◆ MemoryObserver() [2/3]

template<typename Memory , typename Observer >
TuringSim::Memory::MemoryObserver< Memory, Observer >::MemoryObserver ( const MemoryObserver< Memory, Observer > &  other)
inline

Build a new observer to the same memory.

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

After the copy, the memory structure has a supplementary observer.

Definition at line 204 of file memoryStructure.h.

Here is the call graph for this function:

◆ MemoryObserver() [3/3]

template<typename Memory , typename Observer >
TuringSim::Memory::MemoryObserver< Memory, Observer >::MemoryObserver ( MemoryObserver< Memory, Observer > &&  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 213 of file memoryStructure.h.

Here is the call graph for this function:

Member Function Documentation

◆ acquire()

template<typename Memory , typename Observer >
void TuringSim::Memory::MemoryObserver< Memory, Observer >::acquire ( const Memory *  toAcquire)
inline

Observe a new memory structure.

Parameters
[in]toAcquirethe memory structure to observe.

If the memory is already observed, nothing is done. Otherwise, if *this observes a memory, it is released.

Definition at line 253 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 Observer >
bool TuringSim::Memory::MemoryObserver< Memory, Observer >::empty ( ) const
inlinenoexcept

Check if *this observes a memory.

Returns
true if and only if *this does not observe anything.

Definition at line 284 of file memoryStructure.h.

◆ operator=() [1/2]

template<typename Memory , typename Observer >
MemoryObserver& TuringSim::Memory::MemoryObserver< Memory, Observer >::operator= ( MemoryObserver< Memory, Observer > &&  other)
inline

Move assignment operator.

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

Definition at line 233 of file memoryStructure.h.

Here is the call graph for this function:

◆ operator=() [2/2]

template<typename Memory , typename Observer >
MemoryObserver& TuringSim::Memory::MemoryObserver< Memory, Observer >::operator= ( MemoryObserver< Memory, Observer > &  other)
inline

Copy assignment operator.

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

Definition at line 222 of file memoryStructure.h.

Here is the call graph for this function:

◆ unsafe_release()

template<typename Memory , typename Observer >
void TuringSim::Memory::MemoryObserver< Memory, Observer >::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 268 of file memoryStructure.h.

Here is the caller graph for this function:

Member Data Documentation

◆ memory

template<typename Memory , typename Observer >
const Memory* TuringSim::Memory::MemoryObserver< Memory, Observer >::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 set of observers, for instance.

Definition at line 294 of file memoryStructure.h.


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