Fleet  0.0.9
Inference in the LOT
ShapeColorSizeObject.h
Go to the documentation of this file.
1 #pragma once
2 
3 #include<assert.h>
4 
5 #include "Object.h"
6 #include "Strings.h"
7 #include "IO.h"
8 
9 // Define features
10 enum class Shape { Rectangle, Triangle, Circle};
11 enum class Color { Blue, Yellow, Green};
12 enum class Size { size1, size2, size3};
13 
21 struct ShapeColorSizeObject : public Object<Shape,Color,Size> {
23  using Super::Super;
24 
26 
33  ShapeColorSizeObject(const std::string _shape, const std::string _color, const std::string _size) {
34  set(_shape, _color, _size);
35  }
36 
37  ShapeColorSizeObject(const std::string s) {
38  auto [_shape, _color, _size] = split<3>(s, '-');
39  set(_shape,_color,_size);
40  }
41 
42  void set(const std::string _shape, const std::string _color, const std::string _size) {
43  // NOT: we could use magic_enum, but haven't here to avoid a dependency
44  if (_shape == "triangle") Super::set(Shape::Triangle);
45  else if(_shape == "rectangle") Super::set(Shape::Rectangle);
46  else if(_shape == "circle") Super::set(Shape::Circle);
47  else { CERR _shape ENDL; assert(0); }
48 
49  if (_color == "blue") Super::set(Color::Blue);
50  else if(_color == "yellow") Super::set(Color::Yellow);
51  else if(_color == "green") Super::set(Color::Green);
52  else { CERR _color ENDL; assert(0); }
53 
54  if (_size == "1") Super::set(Size::size1);
55  else if(_size == "2") Super::set(Size::size2);
56  else if(_size == "3") Super::set(Size::size3);
57  else { CERR _size ENDL; assert(0); }
58  }
59 };
60 
Size
Definition: ShapeColorSizeObject.h:12
Definition: ShapeColorSizeObject.h:21
ShapeColorSizeObject(const std::string s)
Definition: ShapeColorSizeObject.h:37
ShapeColorSizeObject()
Definition: ShapeColorSizeObject.h:25
ShapeColorSizeObject(const std::string _shape, const std::string _color, const std::string _size)
Mainly we just define a constructor which takes strings.
Definition: ShapeColorSizeObject.h:33
#define CERR
Definition: IO.h:23
#define ENDL
Definition: IO.h:21
Definition: Object.h:20
Color
Definition: ShapeColorSizeObject.h:11
std::bitset< 16 > set
Definition: Main.cpp:10
Shape
Definition: ShapeColorSizeObject.h:10