Dynalib Utils
TestObject.h
Go to the documentation of this file.
1 //
2 // Created by Ken Kopelson on 16/10/17.
3 //
4 
5 #ifndef ROBOCHEFEMULATOR_TESTOBJECT_H
6 #define ROBOCHEFEMULATOR_TESTOBJECT_H
7 
8 #include "../Utilities/IHashable.h"
9 #include "../Utilities/HashCoder.h"
10 #include "../Utilities/ICopyable.h"
11 
12 class TestObject : public IHashable<TestObject>, public ICopyable<TestObject> {
13  long _value;
14 public:
15  TestObject() : _value(0) {}
16  explicit TestObject(long value);
17  virtual ~TestObject();
18 
19  void test();
20  long getValue() const { return _value; }
21  TestObject* setValue(long value) {
22  _value = value;
23  return this;
24  }
25 
26  TestObject* copy() override {
27  return new TestObject(_value);
28  }
29 
30  int hashCode() const override {
31  auto code = HashCoder();
32  code.add(_value);
33  return code.getCode();
34  }
35 
36  bool operator== (const TestObject &other) const override {
37  return _value == other.getValue();
38  }
39 
40 };
41 
42 #endif //ROBOCHEFEMULATOR_TESTOBJECT_H
Definition: IHashable.h:10
Definition: HashCoder.h:41
GeneratorWrapper< T > value(T &&value)
Definition: catch.hpp:4005
TestObject * setValue(long value)
Definition: TestObject.h:21
TestObject()
Definition: TestObject.h:15
Definition: TestObject.h:12
long getValue() const
Definition: TestObject.h:20
int hashCode() const override
Definition: TestObject.h:30
TestObject * copy() override
Definition: TestObject.h:26
Definition: ICopyable.h:8
void test()
Definition: TestObject.cpp:24
bool operator==(const TestObject &other) const override
Definition: TestObject.h:36
virtual ~TestObject()
Definition: TestObject.cpp:20