#ifndef __POST_H__ #define __POST_H__ #include "Comment.h" #include "Tag.h" #include #include #include class User; typedef Wt::Dbo::collection> Comments; typedef Wt::Dbo::collection> Tags; class Post : public Wt::Dbo::Dbo { public: enum State { Unpublished = 0, Published = 1, }; std::string permaLink() const; std::string commentCount() const; std::string titleToUrl() const; Wt::Dbo::ptr rootComment() const; template void persist(Action &a) { Wt::Dbo::field(a, state, "state"); Wt::Dbo::field(a, date, "date"); Wt::Dbo::field(a, title, "title"); Wt::Dbo::field(a, briefSrc, "brief_src"); Wt::Dbo::field(a, briefHtml, "brief_html"); Wt::Dbo::field(a, bodySrc, "body_src"); Wt::Dbo::field(a, bodyHtml, "body_html"); Wt::Dbo::belongsTo(a, author, "author"); Wt::Dbo::hasMany(a, comments, Wt::Dbo::ManyToOne, "post"); Wt::Dbo::hasMany(a, tags, Wt::Dbo::ManyToMany, "post_tag"); } Wt::Dbo::ptr author; State state; Wt::WDateTime date; Wt::WString title; Wt::WString briefSrc; Wt::WString briefHtml; Wt::WString bodySrc; Wt::WString bodyHtml; Comments comments; Tags tags; }; DBO_EXTERN_TEMPLATES(Post) #endif // __POST_H__