carl  24.04
Computer ARithmetic Library
Context.h
Go to the documentation of this file.
1 #pragma once
2 
3 #include "../../core/Variable.h"
5 #include <memory>
6 
7 namespace carl {
8 
9 class Context {
10  std::shared_ptr<std::vector<Variable>> m_variable_order;
11 
12 public:
13  Context() = delete;
14 
16 
17  Context(Context&& ctx) : m_variable_order(std::move(ctx.m_variable_order)) {}
18 
19  Context& operator=(const Context& rhs) {
21  return *this;
22  }
23 
24  Context(const std::vector<Variable>& var_order) : m_variable_order(std::make_shared<std::vector<Variable>>(var_order)) {};
25 
26  const std::vector<Variable>& variable_ordering() const {
27  return *m_variable_order;
28  }
29 
30  bool has(const Variable& var) const {
31  return std::find(variable_ordering().begin(), variable_ordering().end(), var) != variable_ordering().end();
32  };
33 
34  inline bool operator==(const Context& rhs) const {
35  return m_variable_order == rhs.m_variable_order;
36  }
37 };
38 
39 inline std::ostream& operator<<(std::ostream& os, const Context& ctx) {
40  os << ctx.variable_ordering();
41  return os;
42 }
43 
44 } // namespace carl
carl is the main namespace for the library.
std::ostream & operator<<(std::ostream &os, const BasicConstraint< Poly > &c)
Prints the given constraint on the given stream.
A Variable represents an algebraic variable that can be used throughout carl.
Definition: Variable.h:85
Context(const Context &ctx)
Definition: Context.h:15
bool operator==(const Context &rhs) const
Definition: Context.h:34
Context & operator=(const Context &rhs)
Definition: Context.h:19
bool has(const Variable &var) const
Definition: Context.h:30
Context(Context &&ctx)
Definition: Context.h:17
Context(const std::vector< Variable > &var_order)
Definition: Context.h:24
const std::vector< Variable > & variable_ordering() const
Definition: Context.h:26
Context()=delete
std::shared_ptr< std::vector< Variable > > m_variable_order
Definition: Context.h:10