48 assert(
static_cast<std::size_t
>(vt) <
mNextIDs.size());
49 return mNextIDs[
static_cast<std::size_t
>(vt)];
52 assert(
static_cast<std::size_t
>(vt) <
mNextIDs.size());
53 return mNextIDs[
static_cast<std::size_t
>(vt)];
72 #define FRESHVAR_LOCK_GUARD std::lock_guard<std::mutex> lock1(freshVarMutex);
73 #define SETNAME_LOCK_GUARD std::lock_guard<std::mutex> lock2(set_nameMutex);
75 #define FRESHVAR_LOCK_GUARD
76 #define SETNAME_LOCK_GUARD
117 if (!pv.second.empty()) {
carl is the main namespace for the library.
Variable fresh_bitvector_variable() noexcept
Variable fresh_variable(VariableType vt) noexcept
VariableType
Several types of variables are supported.
Variable fresh_real_variable() noexcept
Variable fresh_integer_variable() noexcept
Variable fresh_boolean_variable() noexcept
Variable fresh_uninterpreted_variable() noexcept
A Variable represents an algebraic variable that can be used throughout carl.
constexpr std::size_t id() const noexcept
Retrieves the id of the variable.
constexpr VariableType type() const noexcept
Retrieves the type of the variable.
This class generates new variables and stores human-readable names for them.
std::mutex set_nameMutex
Mutex for calling setVariableName().
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.
std::size_t nextID(VariableType vt) const noexcept
VariablePool() noexcept
Private default constructor.
friend Variable fresh_variable(VariableType vt) noexcept
std::size_t & nextID(VariableType vt) noexcept
std::mutex freshVarMutex
Mutex for calling get_fresh_variable().
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().
std::array< std::size_t, static_cast< std::size_t >VariableType::TYPE_SIZE)> mNextIDs
Contains the id of the next variable to be created for each type.
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.
Base class that implements a singleton.
static VariablePool & getInstance()
Returns the single instance of this class by reference.