Curl return code handling
[dueringa_WikiWalker.git] / src / Article.h
blobf50e4c67bcba8f7e3c1b043087b27a9c1b8323c3
1 #ifndef _ARTICLE_H
2 #define _ARTICLE_H
4 #include <string>
5 #include <vector>
7 /*!
8 * represents a Wikipedia (Mediawiki) article and its links
9 */
10 class Article
12 public:
13 //! representation of links to other articles
14 typedef std::vector<Article*> ArticleLinkStorage;
15 //! representation of iterator over links
16 typedef std::vector<Article*>::iterator ArticleLinkIterator;
17 //! representation of const iterator over links
18 typedef std::vector<Article*>::const_iterator ArticleLinkConstIterator;
20 /*! Create a new article from a title
21 * \param articleTitle The title of the article
23 Article(std::string articleTitle)
24 : title(articleTitle), analyzed(false) {}
26 //! Get the title of the article
27 std::string getTitle() const {
28 return title;
31 //! get the number of links the article has
32 size_t getNumLinks() const;
34 /*! Add a link to another article.
35 * \param[in] article Pointer to the article this article links
36 * to
37 * \returns Whether adding woth successful. Returns false if
38 * instance / pointer is already included.
40 bool addLink(Article* article);
42 /*! Set article to be analyzed.
43 * State is automatically set by #addLink, but if
44 * article has no outgoing links, this must be called,
45 * otherwise #getNumLinks will throw an exception
46 * \param analyzed whether article has been analyzed
48 void setAnalyzed(bool analyzed);
50 //! Get state if article was analyzed (for out links)
51 bool isAnalyzed() const;
53 /*! Get const_iterator to first linked article */
54 ArticleLinkConstIterator linkBegin() const;
56 /*! Get const_iterator to last linked article */
57 ArticleLinkConstIterator linkEnd() const;
59 private:
60 std::string title;
61 ArticleLinkStorage links;
62 bool analyzed;
65 #endif //_ARTICLE_H