User Guide
nmodl::utils::SingletonRandomString< SIZE > Class Template Reference

Singleton class for random strings. More...

Detailed Description

template<unsigned int SIZE = 4>
class nmodl::utils::SingletonRandomString< SIZE >

Singleton class for random strings.

Singleton class for random strings that are appended to the Eigen matrices names that are used in the solutions of nmodl::visitor::SympySolverVisitor and need to be the same to be printed by the nmodl::codegen::CodegenCoreneuronCppVisitor

Definition at line 67 of file common_utils.hpp.

#include <common_utils.hpp>

Public Member Functions

 SingletonRandomString (SingletonRandomString const &)=delete
 Delete public constructor needed for the singleton pattern to work. More...
 
SingletonRandomStringoperator= (SingletonRandomString const &)=delete
 Delete public "=" operator. More...
 
bool random_string_exists (const std::string &var_name) const
 Check if there is a random string assigned as suffix for the var_name variable. More...
 
const std::string & get_random_string (const std::string &var_name) const
 Get the random string of the var_name variable. More...
 
const std::string & reset_random_string (const std::string &var_name, UseNumbersInString use_numbers)
 If var_name has already got a random string assigned remove it from map and assign a new one, else simply insert a new random string for var_name. More...
 

Static Public Member Functions

static SingletonRandomStringinstance ()
 Function to instantiate the SingletonRandomString class. More...
 

Private Member Functions

Ctor & dtor
 SingletonRandomString ()=default
 Constructor used by instance() More...
 

Private Attributes

std::map< std::string, std::string > random_strings
 std::map that keeps the random strings assigned to variables as suffix More...
 

Constructor & Destructor Documentation

◆ SingletonRandomString() [1/2]

template<unsigned int SIZE = 4>
nmodl::utils::SingletonRandomString< SIZE >::SingletonRandomString ( SingletonRandomString< SIZE > const &  )
delete

Delete public constructor needed for the singleton pattern to work.

◆ SingletonRandomString() [2/2]

template<unsigned int SIZE = 4>
nmodl::utils::SingletonRandomString< SIZE >::SingletonRandomString ( )
privatedefault

Constructor used by instance()

Member Function Documentation

◆ get_random_string()

template<unsigned int SIZE = 4>
const std::string& nmodl::utils::SingletonRandomString< SIZE >::get_random_string ( const std::string &  var_name) const
inline

Get the random string of the var_name variable.

Parameters
var_nameVariable name for which to get the random string
Returns
Random string assigned to var_name

Definition at line 94 of file common_utils.hpp.

◆ instance()

template<unsigned int SIZE = 4>
static SingletonRandomString& nmodl::utils::SingletonRandomString< SIZE >::instance ( )
inlinestatic

Function to instantiate the SingletonRandomString class.

Definition at line 75 of file common_utils.hpp.

◆ operator=()

template<unsigned int SIZE = 4>
SingletonRandomString& nmodl::utils::SingletonRandomString< SIZE >::operator= ( SingletonRandomString< SIZE > const &  )
delete

Delete public "=" operator.

◆ random_string_exists()

template<unsigned int SIZE = 4>
bool nmodl::utils::SingletonRandomString< SIZE >::random_string_exists ( const std::string &  var_name) const
inline

Check if there is a random string assigned as suffix for the var_name variable.

Parameters
var_nameVariable name to check if exists in the std::map of random strings
Returns
true if it exists, false if not

Definition at line 85 of file common_utils.hpp.

◆ reset_random_string()

template<unsigned int SIZE = 4>
const std::string& nmodl::utils::SingletonRandomString< SIZE >::reset_random_string ( const std::string &  var_name,
UseNumbersInString  use_numbers 
)
inline

If var_name has already got a random string assigned remove it from map and assign a new one, else simply insert a new random string for var_name.

Parameters
var_nameVariable name for which to reset the random string
use_numberscontrol whether random string can include numeric characters or not
Returns
Random string assigned to var_name

Definition at line 105 of file common_utils.hpp.

Member Data Documentation

◆ random_strings

template<unsigned int SIZE = 4>
std::map<std::string, std::string> nmodl::utils::SingletonRandomString< SIZE >::random_strings
private

std::map that keeps the random strings assigned to variables as suffix

Definition at line 126 of file common_utils.hpp.


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