source: trunk/lib/Node.h @ 79

Last change on this file since 79 was 79, checked in by Jari Häkkinen, 16 years ago

Clean up code.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Id
File size: 2.1 KB
Line 
1// $Id: Node.h 79 2006-03-10 11:44:45Z jari $
2
3#ifndef _theplu_svnstat_node_
4#define _theplu_svnstat_node_
5
6#include "Stats.h"
7
8#include <ostream>
9#include <sstream>
10#include <string>
11
12namespace theplu{
13namespace svnstat{
14
15  ///
16  /// Abstract Base Class for files.
17  ///
18  class Node
19  {
20  public:
21    ///
22    /// @brief Constructor
23    ///
24    Node(const std::string& path, const std::string& output="") : path_(path)
25      { output_name_ = output + name(); }
26
27    ///
28    /// @brief Destructor
29    ///
30    virtual inline ~Node(void) {};
31
32    ///
33    /// @return A properly formatted html link to this node.
34    ///
35    inline std::string html_link(void) const
36    { return "<a href=\"" + output_name() + ".html\">" + name() + "</a>"; }
37
38    inline std::string html_tablerow(void) const
39    {
40      std::stringstream ss;
41      ss << "<tr><td>" << html_link() << "</td><td align=right>" << stats_.rows()
42         << "</td></tr>\n";
43      return ss.str();
44    }
45
46    inline const std::string& output_name(void) const { return output_name_; }
47
48    ///
49    /// @brief parsing file using svn blame.
50    ///
51    virtual const Stats& parse(const bool verbose=false)=0;
52
53    ///
54    /// Function printing HTML in current working directory
55    ///
56    virtual void print(const bool verbose=false) const=0;
57
58    ///
59    ///
60    ///
61    inline virtual void purge(const bool verbose=false) 
62    { /* Nothing to be done */ };
63
64    ///
65    /// Check if the node is under subversion control. This is done by
66    /// checking the return status of 'svn proplist <Node>.
67    ///
68    /// @return True if subversion controlled, false otherwise.
69    ///
70    bool subversion_controlled(void) const;
71
72  protected:
73    ///
74    /// Function returning everything after the last '/'
75    ///
76    /// @return name of node (not full path)
77    ///
78    std::string name(void) const;
79
80    ///
81    /// @brief print html footer of page
82    ///
83    void print_footer(std::ostream&) const;
84   
85    ///
86    /// @brief print html header of page
87    ///
88    void print_header(std::ostream&) const;
89
90    std::string output_name_; //without suffix
91    std::string path_;
92    Stats stats_;
93
94  private:
95    ///
96    /// @brief Copy Constructor, not implemented
97    ///
98    Node(const Node&);
99
100  };
101
102}} // end of namespace svnstat and namespace theplu
103
104#endif
Note: See TracBrowser for help on using the repository browser.