Lodestar
An integrated real-time control package in C++
SetExpression.hpp
1 //
2 // Created by Hamza El-Kebir on 6/21/21.
3 //
4 
5 #ifndef LODESTAR_SETEXPRESSION_HPP
6 #define LODESTAR_SETEXPRESSION_HPP
7 
8 #include "SetEnum.hpp"
9 #include <Eigen/Dense>
10 
11 namespace ls {
12  namespace primitives {
13  namespace sets {
14  template<typename TType>
15  class SetExpression {
16  public:
17  using type = TType;
18 
19  SetExpression() : sEnum_(SetEnum::Unknown)
20  {}
21 
22  SetExpression(const SetEnum setEnum) : sEnum_(setEnum)
23  {}
24 
25  template<typename TElementType>
26  bool operator==(const TElementType &el) const
27  {
28  return static_cast<TType const &>(*this).operator==(el);
29  }
30 
31  template<typename TElementType>
32  bool operator!=(const TElementType &el) const
33  {
34  return static_cast<TType const &>(*this).operator!=(el);
35  }
36 
37  template<typename TElementType>
38  bool contains(const TElementType &el) const
39  {
40  return static_cast<TType const &>(*this).contains(el);
41  }
42 
43  template<typename TElementType>
44  bool isSubset(const TElementType &el) const
45  {
46  return static_cast<TType const &>(*this).isSubset(el);
47  }
48 
49  template<typename TElementType>
50  bool isSuperset(const TElementType &el) const
51  {
52  return static_cast<TType const &>(*this).isSuperset(el);
53  }
54 
55  bool isEmpty() const
56  {
57  return static_cast<TType const &>(*this).isEmpty();
58  }
59 
60  template<typename TReturnType, typename TElementType>
61  SetExpression<TReturnType> relComplement(const TElementType &el) const
62  {
63  return static_cast<TType const &>(*this).relComplement(el);
64  }
65 
66  template<typename TReturnType, typename TOtherExpr>
67  SetExpression<TReturnType> unionize(const TOtherExpr &expr)
68  {
69  return static_cast<TType const &>(*this).unionize(expr);
70  }
71 
72  template<typename Derived>
73  double sdf(Eigen::MatrixBase<Derived> &p) const
74  {
75  return static_cast<TType const &>(*this).sdf(p);
76  }
77 
78  SetEnum getEnum() const
79  {
80  return sEnum_;
81  }
82 
83  protected:
84  SetEnum sEnum_;
85  };
86  }
87  }
88 }
89 
90 #endif //LODESTAR_SETEXPRESSION_HPP
ls::primitives::sets::SetExpression
Definition: SetExpression.hpp:15
ls
Main Lodestar code.
Definition: BilinearTransformation.hpp:12