RMM API 2.0.0
Loading...
Searching...
No Matches
RegMutex Class Reference

A class that stores a map of mutexes, one for each register address. Each mutex can be locked or unlocked. The lock and unlock functions receive the register address. More...

#include <RegMutex.h>

Inheritance diagram for RegMutex:
Collaboration diagram for RegMutex:

Public Member Functions

bool lock (std::string reg, bool critic=true)
 Receives a string representing a register address. Locks the mutex associated with it. If critic is true, throw exception if can't find register in list.
 
bool unlock (std::string reg, bool critic=true)
 Receives a string representing a register address. Unlocks the mutex associated with it. If critic is true, throw exception if can't find register in list.
 
bool addReg (std::string reg, std::string tag="NoTag", bool critic=true)
 Adds a register to the map, initializing a mutex to it.
 
unsigned int addRegs (std::list< std::string > regs, bool critic=true)
 Calls addReg for each register address of a list of strings.
 
unsigned int removeReg (std::string reg, bool critic=true)
 Removes a register from the map, destroying it's mutex.
 
unsigned int removeRegs (std::list< std::string > regs, bool critic=true)
 Calls removeReg for each register address of a list of strings.
 
RegLockGuard lockGuard (std::string reg, std::string tag="NoTag")
 returns a lock guard object for that register mutex.
 
 RegMutex (FENRegMap map)
 Constructor that uses one register map. It will throw an exception if there are duplicate register addresses.
 
 RegMutex (std::list< FENRegMap > registers)
 Constructor that uses a list of register maps. It will throw an exception if there are duplicate register addresses.
 
 RegMutex (std::list< std::shared_ptr< FENRegMap > > registers)
 Constructor that uses a list of shared pointers to address maps. It will throw an exception if there are duplicate register addresses.
 
void printRegisters ()
 prints registers and addresses inside internal list. Mostly used for debugging purposes.
 
- Public Member Functions inherited from RMMLog
 RMMLog (const char *name)
 Constructs the RMMLog object with a name for the log.
 
 ~RMMLog ()
 Destructor for the RMMLog object.
 
void debug (const char *sender, const char *printer...)
 Logs a debug message.
 
void info (const char *sender, const char *printer...)
 Logs an info message.
 
void warn (const char *sender, const char *printer...)
 Logs a warning message.
 
void error (const char *sender, const char *printer...)
 Logs an error message.
 
void critical (const char *sender, const char *printer...)
 Logs a critical message.
 
void logRelay (std::string logLevel, FILE *out)
 Relays log output to a specified file for a given log level.
 
void getTimestamp (char message[MAX_CHAR_LOG_MESSAGE])
 Retrieves the current timestamp in a formatted string.
 
void getLogMask (int *mask)
 Gets the current log mask.
 
void getLogMask (char *mask)
 Gets the current log mask as a string.
 
rmmStatus setLogMask (int mask)
 Sets the log mask to the given value.
 
void setLogTimeout (int milliseconds)
 Sets the timeout for logging operations.
 
void setFileWriteTimeout (int milliseconds)
 Sets the timeout for file write operations.
 
int getFailedWrites ()
 Gets the count of failed write attempts to the log file.
 
rmmStatus putMsg (std::string msg)
 Store message in a buffer.
 
rmmStatus putInfo (const char *sender, std::string msg)
 Calls both putMsg and info methods.
 
rmmStatus putMsg (const char *message...)
 Store message in a buffer.
 
rmmStatus putInfo (const char *sender, const char *msg...)
 Calls both putMsg and info methods.
 
rmmStatus getMsg (std::string *msg)
 Get the message stored in object container.
 
rmmStatus getLogFilePath (std::string *filePath)
 Get filepath to log.
 
rmmStatus getLogFilePath (std::string *path, std::string *name)
 Retrieves the directory and filename of the log file.
 
rmmStatus setLogFilePath (std::string filePath, bool useName=false)
 Sets the log file path for the log file.
 
rmmStatus setLogFilePath (std::string path, std::string name)
 Sets the log file path using a directory and a custom file name.
 
rmmStatus setWriteToFile (bool option, char mode='w')
 Enable/disable writing to log.
 

Friends

class RMMRegisterAccess
 

Detailed Description

A class that stores a map of mutexes, one for each register address. Each mutex can be locked or unlocked. The lock and unlock functions receive the register address.

NOT THREAD SAFE!

Constructor & Destructor Documentation

◆ RegMutex() [1/3]

RegMutex::RegMutex ( FENRegMap map)

Constructor that uses one register map. It will throw an exception if there are duplicate register addresses.

Parameters
mapa register map to copy the addresses from. It should not have duplicate addresses.

◆ RegMutex() [2/3]

RegMutex::RegMutex ( std::list< FENRegMap > registerMaps)

Constructor that uses a list of register maps. It will throw an exception if there are duplicate register addresses.

Parameters
registerMapsa list of register maps. They should not have duplicate addresses.

◆ RegMutex() [3/3]

RegMutex::RegMutex ( std::list< std::shared_ptr< FENRegMap > > registerMaps)

Constructor that uses a list of shared pointers to address maps. It will throw an exception if there are duplicate register addresses.

Parameters
registerMapsa list of shared pointers to register maps. They should not have duplicate addresses.

Member Function Documentation

◆ addReg()

bool RegMutex::addReg ( std::string reg,
std::string tag = "NoTag",
bool critic = true )

Adds a register to the map, initializing a mutex to it.

Parameters
[in]regstring representing register address to add.
[in]criticif true, throw exception if register is already there.
Returns
bool indicating operation success.

◆ addRegs()

unsigned int RegMutex::addRegs ( std::list< std::string > regs,
bool critic = true )

Calls addReg for each register address of a list of strings.

Parameters
[in]regslist of strings representing register addresses to add.
[in]criticif true, throw exception if register is already there.
Returns
number of registers added.

◆ lock()

bool RegMutex::lock ( std::string reg,
bool critic = true )

Receives a string representing a register address. Locks the mutex associated with it. If critic is true, throw exception if can't find register in list.

Parameters
[in]regstring representing register address to look.
[in]criticif true, throw exception when can't find register mutex.

◆ lockGuard()

RegLockGuard RegMutex::lockGuard ( std::string reg,
std::string tag = "NoTag" )

returns a lock guard object for that register mutex.

Parameters
[in]regstring representing register address to look.
Returns
RegLockGuard object which will keep mutex locked until it's destroyed.

◆ removeReg()

unsigned int RegMutex::removeReg ( std::string reg,
bool critic = true )

Removes a register from the map, destroying it's mutex.

Parameters
[in]regstring representing register address to remove.
[in]criticif true, throw exception if register is not in the map.
Returns
number of elements removed.

◆ removeRegs()

unsigned int RegMutex::removeRegs ( std::list< std::string > regs,
bool critic = true )

Calls removeReg for each register address of a list of strings.

Parameters
[in]regslist of strings representing register addresses to remove.
[in]criticif true, throw exception if register is already there.
Returns
number of registers removed.

◆ unlock()

bool RegMutex::unlock ( std::string reg,
bool critic = true )

Receives a string representing a register address. Unlocks the mutex associated with it. If critic is true, throw exception if can't find register in list.

Parameters
[in]regstring representing register address to look.
[in]criticif true, throw exception when can't find register mutex.

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