-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathenumoption.h
More file actions
63 lines (52 loc) · 1.47 KB
/
enumoption.h
File metadata and controls
63 lines (52 loc) · 1.47 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
#ifndef ENUMOPTION_H_
#define ENUMOPTION_H_
#include <option.h>
#include <cstdint>
#include <list>
#include <memory>
namespace NaoControl {
class EnumItem {
private:
uint8_t* buffer;
int len;
public:
/** This class is not intended to by copied */
EnumItem(const EnumItem& s) = delete;
EnumItem(EnumItem&&) = delete;
EnumItem& operator=(const EnumItem&) = delete;
EnumItem& operator=(EnumItem&&) = delete;
~EnumItem() {
free(buffer);
}
EnumItem(const char* name, int value);
size_t size() const {
return len;
}
uint8_t* save(uint8_t* ptr);
};
using EnumItemPtr = std::shared_ptr<EnumItem>;
class EnumOption : public Option {
private:
int* value;
std::function<void(int)> callback;
std::list<EnumItemPtr> enumItems;
public:
/** This class is not intended to by copied */
EnumOption(EnumOption& s) = delete;
EnumOption(EnumOption&& s) = delete;
EnumOption& operator=(const EnumOption&) = delete;
EnumOption& operator=(EnumOption&&) = delete;
~EnumOption() override = default;
EnumOption(const char* cname, int* val, std::function<void(int)> callb = nullptr);
uint8_t* save(uint8_t* start) override;
void setValue(const uint8_t* buffer, int len) override;
void addEnumItem(EnumItem* item);
OptionType getOptionType() override {
return O_ENUM;
}
void* getValuePtr() override {
return value;
}
};
} /* namespace NaoControl */
#endif /* ENUMOPTION_H_ */