Introduce version 0.1
[dueringa_WikiWalker.git] / src / Article.h
blob47bd03136de4d365013be3087d653b56f69223d8
1 //! \file Article.h
3 #ifndef _ARTICLE_H
4 #define _ARTICLE_H
6 #include <string>
8 // forward_list has no size :(
9 #include <list>
11 /*!
12 * represents a Wikipedia (Mediawiki) article and its links
14 class Article
16 public:
17 //! representation of links to other articles
18 typedef std::list<Article*> storage;
19 //! representation of iterator over links
20 typedef storage::iterator ArticleLinkIterator;
21 //! representation of const iterator over links
22 typedef storage::const_iterator ArticleLinkConstIterator;
24 /*! Create a new article from a title
25 * \param articleTitle The title of the article
27 Article(std::string articleTitle)
28 : title(articleTitle), analyzed(false), marked(false) {}
30 /*! Get the title of the article
31 * \return title of the article
33 std::string getTitle() const
35 return title;
38 /*! get the number of links the article has.
39 * This throws an exception if state has not been set to anaylzed.
40 * \return number of links the article has.
41 * \see setAnalyzed
42 * \see addLink
44 size_t getNumLinks() const;
46 /*! Add a link to another article.
47 * \param[in] article Pointer to the article this article links
48 * to
49 * \returns Whether adding woth successful. Returns false if
50 * instance / pointer is already included.
52 * Automatically sets state to analyzed
53 * \see setAnalyzed
54 * \see isAnalyzed
56 bool addLink(Article* article);
58 /*! Set article to be analyzed.
59 * State is automatically set by #addLink, but if
60 * article has no outgoing links, this must be called,
61 * otherwise #getNumLinks will throw an exception
62 * \param analyzed whether article has been analyzed
63 * \see addLink
65 void setAnalyzed(bool analyzed);
67 //! Get state if article was analyzed (for out links)
68 bool isAnalyzed() const;
70 /*! Set article to be marked.
71 * Some kind of "marking" for output usage. May be start point,
72 * may be end point, may be point of special interest.
73 * \param marked whether article os marked
75 void setMarked(bool marked);
77 /*! Get state whether article was marked.
78 * \returns Whether article is marked.
80 bool isMarked() const;
82 /*! Get const_iterator to first linked article */
83 ArticleLinkConstIterator linkBegin() const;
85 /*! Get const_iterator to last linked article */
86 ArticleLinkConstIterator linkEnd() const;
88 private:
89 std::string title;
90 storage links;
91 bool analyzed;
92 bool marked;
95 #endif //_ARTICLE_H