From 38c17f093615a16a4b4ec6dc2b5d3edb5c1d3895 Mon Sep 17 00:00:00 2001 From: Kelly Rauchenberger Date: Thu, 27 Sep 2018 21:40:52 -0400 Subject: More hkutil refactoring All database access goes through hatkirby::database now. verbly::token, verbly::statement::condition, and verbly::part have been converted to use mpark::variant now. verbly::binding has been deleted, and replaced with a mpark::variant typedef in statement.h. This means that the only remaining tagged union class is verbly::generator::part. refs #5 --- lib/notion.h | 118 +++++++++++++++++++++++++++++------------------------------ 1 file changed, 57 insertions(+), 61 deletions(-) (limited to 'lib/notion.h') diff --git a/lib/notion.h b/lib/notion.h index 5388e17..63afd2f 100644 --- a/lib/notion.h +++ b/lib/notion.h @@ -3,120 +3,119 @@ #include #include +#include #include "field.h" #include "filter.h" -struct sqlite3_stmt; - namespace verbly { - + class database; - + class notion { public: - + // Default constructor - + notion() = default; - + // Construct from database - - notion(const database& db, sqlite3_stmt* row); - + + notion(const database& db, hatkirby::row row); + // Accessors - + bool isValid() const { return valid_; } - + int getId() const { if (!valid_) { throw std::domain_error("Bad access to uninitialized notion"); } - + return id_; } - + part_of_speech getPartOfSpeech() const { if (!valid_) { throw std::domain_error("Bad access to uninitialized notion"); } - + return partOfSpeech_; } - + bool hasWnid() const { if (!valid_) { throw std::domain_error("Bad access to uninitialized notion"); } - + return hasWnid_; } - + int getWnid() const { if (!valid_) { throw std::domain_error("Bad access to uninitialized notion"); } - + if (!hasWnid_) { throw std::domain_error("Notion has no wnid"); } - + return wnid_; } - + bool hasNumOfImages() const { if (!valid_) { throw std::domain_error("Bad access to uninitialized notion"); } - + return hasNumOfImages_; } - + int getNumOfImages() const { if (!valid_) { throw std::domain_error("Bad access to uninitialized notion"); } - + if (!hasNumOfImages_) { throw std::domain_error("Notion does not have a number of images"); } - + return numOfImages_; } - + // Convenience - + std::string getImageNetUrl() const; - + // Type info - + static const object objectType; - + static const std::list select; - + // Query fields - + static const field id; static const field partOfSpeech; static const field wnid; static const field numOfImages; - + operator filter() const { if (!valid_) @@ -126,7 +125,7 @@ namespace verbly { return (id == id_); } - + filter operator!() const { if (!valid_) @@ -138,78 +137,75 @@ namespace verbly { } // Relationships with other objects - + static const field words; - + // Relationships with self - + static const field hypernyms; static const field hyponyms; - + static const field fullHypernyms; static const field fullHyponyms; - + static const field instances; static const field classes; - + static const field memberMeronyms; static const field memberHolonyms; - + static const field fullMemberMeronyms; static const field fullMemberHolonyms; - + static const field partMeronyms; static const field partHolonyms; - + static const field fullPartMeronyms; static const field fullPartHolonyms; - + static const field substanceMeronyms; static const field substanceHolonyms; - + static const field fullSubstanceMeronyms; static const field fullSubstanceHolonyms; - + static const field variants; static const field attributes; - + static const field similarAdjectives; - + static const field entails; static const field entailedBy; - + static const field causes; static const field effects; - + // Preposition group relationship - + class preposition_group_field { public: - + filter operator==(std::string groupName) const; - + private: - + static const field isA; static const field groupNameField; }; - + static const preposition_group_field prepositionGroups; - + private: + bool valid_ = false; - int id_; part_of_speech partOfSpeech_; bool hasWnid_ = false; int wnid_; bool hasNumOfImages_ = false; int numOfImages_; - - const database* db_; - }; - + }; #endif /* end of include guard: NOTION_H_FD1C7646 */ -- cgit 1.4.1