diff options
Diffstat (limited to 'generator/part.h')
-rw-r--r-- | generator/part.h | 30 |
1 files changed, 20 insertions, 10 deletions
diff --git a/generator/part.h b/generator/part.h index b010f62..39ba1e7 100644 --- a/generator/part.h +++ b/generator/part.h | |||
@@ -4,21 +4,16 @@ | |||
4 | #include <string> | 4 | #include <string> |
5 | #include <set> | 5 | #include <set> |
6 | #include "../lib/selrestr.h" | 6 | #include "../lib/selrestr.h" |
7 | #include "../lib/enums.h" | ||
7 | 8 | ||
8 | namespace verbly { | 9 | namespace verbly { |
10 | |||
9 | namespace generator { | 11 | namespace generator { |
10 | 12 | ||
11 | class part { | 13 | class part { |
12 | public: | 14 | public: |
13 | enum class type { | 15 | |
14 | invalid = -1, | 16 | using type = part_type; |
15 | noun_phrase = 0, | ||
16 | verb = 1, | ||
17 | preposition = 2, | ||
18 | adjective = 3, | ||
19 | adverb = 4, | ||
20 | literal = 5 | ||
21 | }; | ||
22 | 17 | ||
23 | // Static factories | 18 | // Static factories |
24 | 19 | ||
@@ -34,6 +29,10 @@ namespace verbly { | |||
34 | 29 | ||
35 | static part createLiteral(std::string value); | 30 | static part createLiteral(std::string value); |
36 | 31 | ||
32 | // Duplication | ||
33 | |||
34 | static part duplicate(const part& other); | ||
35 | |||
37 | // Copy and move constructors | 36 | // Copy and move constructors |
38 | 37 | ||
39 | part(const part& other); | 38 | part(const part& other); |
@@ -54,6 +53,11 @@ namespace verbly { | |||
54 | 53 | ||
55 | // General accessors | 54 | // General accessors |
56 | 55 | ||
56 | int getId() const | ||
57 | { | ||
58 | return id_; | ||
59 | } | ||
60 | |||
57 | type getType() const | 61 | type getType() const |
58 | { | 62 | { |
59 | return type_; | 63 | return type_; |
@@ -79,13 +83,19 @@ namespace verbly { | |||
79 | 83 | ||
80 | private: | 84 | private: |
81 | 85 | ||
86 | static int nextId_; | ||
87 | |||
88 | int id_; | ||
89 | |||
82 | // Private constructors | 90 | // Private constructors |
83 | 91 | ||
84 | part() | 92 | part() |
85 | { | 93 | { |
86 | } | 94 | } |
87 | 95 | ||
88 | part(type t) : type_(t) | 96 | part(type t) : |
97 | id_(nextId_++), | ||
98 | type_(t) | ||
89 | { | 99 | { |
90 | } | 100 | } |
91 | 101 | ||