8 #include "../initialize.h"
27 CARL_LOG_DEBUG(
"carl.varpool",
"New variable of type " << type <<
" with id " << tmp);
33 CARL_LOG_WARN(
"carl",
"The prefix for auxiliary variable names \"" <<
mVariablePrefix <<
"\" is a prefix for the variable name \"" << name <<
"\".");
41 Variable res = get_fresh_variable(type);
42 if (res.
id() >= mPersistentVariables.size()) {
45 mPersistentVariables[res.
id()] = std::make_pair(res,
"");
57 for (
const auto& v: mVariableNames) {
58 if (v.second == name)
return v.first;
64 if (v.
id() == 0)
return "NO_VARIABLE";
#define FRESHVAR_LOCK_GUARD
#define SETNAME_LOCK_GUARD
A small wrapper that configures logging for carl.
#define CARL_LOG_WARN(channel, msg)
#define CARL_LOG_ERROR(channel, msg)
#define CARL_LOG_DEBUG(channel, msg)
#define CARL_LOG_INFO(channel, msg)
carl is the main namespace for the library.
VariableType
Several types of variables are supported.
A Variable represents an algebraic variable that can be used throughout carl.
static const Variable NO_VARIABLE
Instance of an invalid variable.
constexpr std::size_t id() const noexcept
Retrieves the id of the variable.
constexpr VariableType type() const noexcept
Retrieves the type of the variable.
void set_name(Variable v, const std::string &name)
Add a name for a given Variable.
std::string get_name(Variable v, bool variableName=true) const
Get a human-readable name for the given variable.
Variable get_fresh_variable(VariableType type=VariableType::VT_REAL) noexcept
Get a variable which was not used before.
Variable get_fresh_persistent_variable(VariableType type=VariableType::VT_REAL) noexcept
Variable find_variable_with_name(const std::string &name) const noexcept
Searches in the friendly names list for a variable with the given name.
VariablePool() noexcept
Private default constructor.
std::string mVariablePrefix
Stores a prefix for printing variables that have no human-readable name.
void clear() noexcept
Clears everything already created in this pool.
std::map< Variable, std::string > mVariableNames
Stores human-readable names for variables that can be set via setVariableName().
void set_prefix(std::string prefix="_") noexcept
Sets the prefix used when printing anonymous variables.
std::vector< std::pair< Variable, std::string > > mPersistentVariables
Contains persistent variables that are restored after clear was called.