carl  24.04
Computer ARithmetic Library
Variable.cpp
Go to the documentation of this file.
1 #include "Variable.h"
2 #include "VariablePool.h"
3 
4 namespace carl
5 {
6  const Variable Variable::NO_VARIABLE = Variable();
7 
8  std::string Variable::name() const {
9  return carl::VariablePool::getInstance().get_name(*this, true);
10  }
11  std::string Variable::safe_name() const {
12  switch (type()) {
14  return "b" + std::to_string(id());
16  return "r" + std::to_string(id());
18  return "i" + std::to_string(id());
20  return "u" + std::to_string(id());
22  return "bv" + std::to_string(id());
23  default:
24  CARL_LOG_ERROR("carl", "Variable has invalid type: " << type());
25  assert(false);
26  return "";
27  }
28  }
29 }
#define CARL_LOG_ERROR(channel, msg)
Definition: carl-logging.h:40
carl is the main namespace for the library.
std::string safe_name() const
Retrieves a unique name of the variable of the form <type><id>.
Definition: Variable.cpp:11
std::string name() const
Retrieves the name of the variable.
Definition: Variable.cpp:8
static const Variable NO_VARIABLE
Instance of an invalid variable.
Definition: Variable.h:203
constexpr VariableType type() const noexcept
Retrieves the type of the variable.
Definition: Variable.h:131
std::string get_name(Variable v, bool variableName=true) const
Get a human-readable name for the given variable.
static VariablePool & getInstance()
Returns the single instance of this class by reference.
Definition: Singleton.h:45