diff options
Diffstat (limited to 'generator/notion.h')
-rw-r--r-- | generator/notion.h | 91 |
1 files changed, 91 insertions, 0 deletions
diff --git a/generator/notion.h b/generator/notion.h new file mode 100644 index 0000000..76210de --- /dev/null +++ b/generator/notion.h | |||
@@ -0,0 +1,91 @@ | |||
1 | #ifndef NOTION_H_221DE2BC | ||
2 | #define NOTION_H_221DE2BC | ||
3 | |||
4 | #include <cassert> | ||
5 | #include <list> | ||
6 | #include <string> | ||
7 | #include "enums.h" | ||
8 | |||
9 | namespace verbly { | ||
10 | namespace generator { | ||
11 | |||
12 | class database; | ||
13 | |||
14 | class notion { | ||
15 | public: | ||
16 | |||
17 | // Constructors | ||
18 | |||
19 | explicit notion(part_of_speech partOfSpeech); | ||
20 | |||
21 | notion(part_of_speech partOfSpeech, int wnid); | ||
22 | |||
23 | // Mutators | ||
24 | |||
25 | void incrementNumOfImages(); | ||
26 | |||
27 | void setPrepositionGroups(std::list<std::string> groups); | ||
28 | |||
29 | // Accessors | ||
30 | |||
31 | int getId() const | ||
32 | { | ||
33 | return id_; | ||
34 | } | ||
35 | |||
36 | part_of_speech getPartOfSpeech() const | ||
37 | { | ||
38 | return partOfSpeech_; | ||
39 | } | ||
40 | |||
41 | bool hasWnid() const | ||
42 | { | ||
43 | return hasWnid_; | ||
44 | } | ||
45 | |||
46 | int getWnid() const | ||
47 | { | ||
48 | // Calling code should always call hasWnid first. | ||
49 | assert(hasWnid_); | ||
50 | |||
51 | return wnid_; | ||
52 | } | ||
53 | |||
54 | int getNumOfImages() const | ||
55 | { | ||
56 | // Calling code should always call hasWnid and check that the notion is a noun first. | ||
57 | assert(hasWnid_ && (partOfSpeech_ == part_of_speech::noun)); | ||
58 | |||
59 | return numOfImages_; | ||
60 | } | ||
61 | |||
62 | std::list<std::string> getPrepositionGroups() const | ||
63 | { | ||
64 | // Calling code should always check that the notion is a preposition first. | ||
65 | assert(partOfSpeech_ == part_of_speech::preposition); | ||
66 | |||
67 | return prepositionGroups_; | ||
68 | } | ||
69 | |||
70 | private: | ||
71 | |||
72 | static int nextId_; | ||
73 | |||
74 | const int id_; | ||
75 | const part_of_speech partOfSpeech_; | ||
76 | const int wnid_ = 0; | ||
77 | const bool hasWnid_ = false; | ||
78 | |||
79 | int numOfImages_ = 0; | ||
80 | std::list<std::string> prepositionGroups_; | ||
81 | |||
82 | }; | ||
83 | |||
84 | // Serializer | ||
85 | |||
86 | database& operator<<(database& db, const notion& arg); | ||
87 | |||
88 | }; | ||
89 | }; | ||
90 | |||
91 | #endif /* end of include guard: NOTION_H_221DE2BC */ | ||