ICG 2
Electric Boogaloo
Public Member Functions | List of all members
MemoryManager Class Reference

Keep track of allocations and their type. More...

#include <MemoryManager.hpp>

Public Member Functions

 MemoryManager (DataTypeInator *dataTypeInator)
 Construct a new Memory Manager. More...
 
 ~MemoryManager ()
 
 MemoryManager (const MemoryManager &other)=delete
 
void * declare_var (const std::string &declaration, void *suppliedAllocation=NULL)
 Declare a new allocation of given type with the memory manager. More...
 
bool var_exists (const std::string &var_name)
 Check if a variable is registered with the memory manager. More...
 
void clear_var (void *address)
 Clear the value at the given address, if it is registered with the memorymanager. More...
 
void clear_var (const std::string &var_name)
 Clear the variable with the given name, if it is registered with the memorymanager. More...
 
void clear_all_vars ()
 Clear all variables registered with the memory manager. More...
 
void delete_var (void *address)
 Delete the variable. More...
 
void delete_var (std::string var_name)
 Delete the variable. More...
 
void write_checkpoint (std::ostream &out_s)
 Write checkpoint to an output stream. More...
 
void write_checkpoint (const std::string &filename)
 Open a file and then write a checkpoint to it. More...
 
void restore_checkpoint (const std::string &filename)
 Restore a checkpoint from file with given name. More...
 
void restore_checkpoint (std::istream &in_s)
 Restore a checkpoint from the given input stream. More...
 
AllocInfogetAllocInfoOf (void *address)
 Get the AllocInfo that contains the given address. More...
 
AllocInfogetAllocInfoAt (void *address)
 Get the AllocInfo that starts at the given address. More...
 
AllocInfogetAllocInfoNamed (const std::string &name)
 Get the AllocInfo with the given name. More...
 
std::shared_ptr< const DataTypegetDataTypeOf (const std::string &name)
 Get the DataType of the given variable. More...
 
void setCheckPointAgent (CheckpointAgentBase *agent)
 Set the CheckPointAgent. More...
 

Detailed Description

Keep track of allocations and their type.

Constructor & Destructor Documentation

◆ MemoryManager() [1/2]

MemoryManager::MemoryManager ( DataTypeInator dataTypeInator)

Construct a new Memory Manager.

Parameters
dataTypeInatortype resolver machine

◆ ~MemoryManager()

MemoryManager::~MemoryManager ( )

◆ MemoryManager() [2/2]

MemoryManager::MemoryManager ( const MemoryManager other)
delete

Member Function Documentation

◆ clear_all_vars()

void MemoryManager::clear_all_vars ( )

Clear all variables registered with the memory manager.

◆ clear_var() [1/2]

void MemoryManager::clear_var ( const std::string &  var_name)

Clear the variable with the given name, if it is registered with the memorymanager.

Parameters
var_namename of variable to clear

◆ clear_var() [2/2]

void MemoryManager::clear_var ( void *  address)

Clear the value at the given address, if it is registered with the memorymanager.

Parameters
addressaddress of variable to clear

◆ declare_var()

void * MemoryManager::declare_var ( const std::string &  declaration,
void *  suppliedAllocation = NULL 
)

Declare a new allocation of given type with the memory manager.

Parameters
declarationstring representation of the type of this allocation
suppliedAllocationpre-existing allocation. If not given, the memory manager will allocate one
Returns
void* address of the allocation (same as suppliedAllocation if one was given). NULL if something goes wrong

◆ delete_var() [1/2]

void MemoryManager::delete_var ( std::string  var_name)

Delete the variable.

Parameters
var_namename of variable to delete

◆ delete_var() [2/2]

void MemoryManager::delete_var ( void *  address)

Delete the variable.

Parameters
addressaddress of variable to delete

◆ getAllocInfoAt()

AllocInfo * MemoryManager::getAllocInfoAt ( void *  address)

Get the AllocInfo that starts at the given address.

Parameters
addressaddress to search for
Returns
AllocInfo* Alloc info that starts at this address, or NULL if not found

◆ getAllocInfoNamed()

AllocInfo * MemoryManager::getAllocInfoNamed ( const std::string &  name)

Get the AllocInfo with the given name.

Parameters
namename to search for
Returns
AllocInfo* AllocInfo with the given name, or NULL if not found

◆ getAllocInfoOf()

AllocInfo * MemoryManager::getAllocInfoOf ( void *  address)

Get the AllocInfo that contains the given address.

Parameters
addressaddress to search for
Returns
AllocInfo* Alloc info that contains this address, or NULL if not found

◆ getDataTypeOf()

std::shared_ptr< const DataType > MemoryManager::getDataTypeOf ( const std::string &  name)

Get the DataType of the given variable.

Parameters
namevariable name to search for
Returns
std::shared_ptr<const DataType> type of variable, or NULL if not found

◆ restore_checkpoint() [1/2]

void MemoryManager::restore_checkpoint ( const std::string &  filename)

Restore a checkpoint from file with given name.

Parameters
filenamename of file to read from

◆ restore_checkpoint() [2/2]

void MemoryManager::restore_checkpoint ( std::istream &  in_s)

Restore a checkpoint from the given input stream.

Parameters
in_sstream to restore from

◆ setCheckPointAgent()

void MemoryManager::setCheckPointAgent ( CheckpointAgentBase agent)

Set the CheckPointAgent.

Parameters
agentnew CheckpointAgent object to use

◆ var_exists()

bool MemoryManager::var_exists ( const std::string &  var_name)

Check if a variable is registered with the memory manager.

Parameters
var_namevariable to look for
Returns
true if var exists, false otherwise

◆ write_checkpoint() [1/2]

void MemoryManager::write_checkpoint ( const std::string &  filename)

Open a file and then write a checkpoint to it.

Parameters
filenamename of file to write to

◆ write_checkpoint() [2/2]

void MemoryManager::write_checkpoint ( std::ostream &  out_s)

Write checkpoint to an output stream.

Parameters
out_sstream to write to

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