codac 1.5.6
Loading...
Searching...
No Matches
codac2_set_variables.h
Go to the documentation of this file.
1
9
10#pragma once
11
12#include <iostream>
13#include "codac2_SetExpr.h"
14#include "codac2_VarBase.h"
15
16namespace codac2
17{
18 class SetVar : public SetExpr, public VarBase
19 {
20 public:
21
22 explicit SetVar(Index n)
23 : _n(n)
24 { }
25
26 virtual const ExprID& unique_id() const
27 {
28 return SetExpr::unique_id();
29 }
30
31 std::shared_ptr<VarBase> arg_copy() const
32 {
33 return std::make_shared<SetVar>(*this);
34 }
35
36 std::shared_ptr<ExprBase> copy() const
37 {
38 return std::make_shared<SetVar>(*this);
39 }
40
41 Index size() const
42 {
43 return _n;
44 }
45
46 void replace_expr(const ExprID& old_expr_id, const std::shared_ptr<ExprBase>& new_expr)
47 { }
48
49 operator std::shared_ptr<SetExpr>() const
50 {
51 return std::dynamic_pointer_cast<SetExpr>(this->copy());
52 }
53
54 virtual bool belongs_to_args_list(const FunctionArgsList& args) const
55 {
56 for(const auto& xi : args)
57 if(xi->unique_id() == this->unique_id())
58 return true;
59 return false;
60 }
61
62 std::shared_ptr<CtcBase<IntervalVector>> create_ctc(const FunctionArgsList& args, const std::vector<std::shared_ptr<CtcBase<IntervalVector>>>& x) const
63 {
64 for(Index i = 0 ; i < args.size() ; i++)
65 if(args[i]->unique_id() == unique_id())
66 return x[i];
67 assert(false);
68 return nullptr;
69 }
70
71 std::shared_ptr<SepBase> create_sep(const FunctionArgsList& args, const std::vector<std::shared_ptr<SepBase>>& x) const
72 {
73 for(Index i = 0 ; i < args.size() ; i++)
74 if(args[i]->unique_id() == unique_id())
75 return x[i];
76 assert(false);
77 return nullptr;
78 }
79
80 protected:
81
82 Index _n;
83 };
84}