source: trunk/lib/Node.h @ 84

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

Added copyright statement. Bumped version number to pre0.3. Cleaned up code.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Id
File size: 2.9 KB
Line 
1// $Id: Node.h 84 2006-03-13 22:04:34Z jari $
2
3/*
4  Copyright (C) 2005, 2006 Jari Häkkinen, Peter Johansson
5
6  This file is part of svnstat, http://lev.thep.lu.se/trac/svnstat
7
8  svnstat is free software; you can redistribute it and/or modify it
9  under the terms of the GNU General Public License as published by
10  the Free Software Foundation; either version 2 of the License, or
11  (at your option) any later version.
12
13  svnstat is distributed in the hope that it will be useful, but
14  WITHOUT ANY WARRANTY; without even the implied warranty of
15  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
16  General Public License for more details.
17
18  You should have received a copy of the GNU General Public License
19  along with this program; if not, write to the Free Software
20  Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
21  02111-1307, USA.
22*/
23
24#ifndef _theplu_svnstat_node_
25#define _theplu_svnstat_node_
26
27#include "Stats.h"
28
29#include <ostream>
30#include <sstream>
31#include <string>
32
33namespace theplu{
34namespace svnstat{
35
36  ///
37  /// Abstract Base Class for files.
38  ///
39  class Node
40  {
41  public:
42    ///
43    /// @brief Constructor
44    ///
45    Node(const std::string& path, const std::string& output="")
46      : path_(path), stats_(path)
47      { output_name_ = output + name(); }
48
49    ///
50    /// @brief Destructor
51    ///
52    virtual inline ~Node(void) {};
53
54    ///
55    /// @return A properly formatted html link to this node.
56    ///
57    inline std::string html_link(void) const
58    { return "<a href=\"" + output_name() + ".html\">" + name() + "</a>"; }
59
60    inline std::string html_tablerow(void) const
61    {
62      std::stringstream ss;
63      ss << "<tr><td>" << html_link() << "</td><td align=right>" << stats_.rows()
64         << "</td></tr>\n";
65      return ss.str();
66    }
67
68    inline const std::string& output_name(void) const { return output_name_; }
69
70    ///
71    /// @brief parsing file using svn blame.
72    ///
73    virtual const Stats& parse(const bool verbose=false)=0;
74
75    ///
76    /// Function printing HTML in current working directory
77    ///
78    virtual void print(const bool verbose=false) const=0;
79
80    ///
81    ///
82    ///
83    inline virtual void purge(const bool verbose=false) 
84    { /* Nothing to be done */ };
85
86    ///
87    /// Check if the node is under subversion control. This is done by
88    /// checking the return status of 'svn proplist <Node>.
89    ///
90    /// @return True if subversion controlled, false otherwise.
91    ///
92    bool subversion_controlled(void) const;
93
94  protected:
95    ///
96    /// Function returning everything after the last '/'
97    ///
98    /// @return name of node (not full path)
99    ///
100    std::string name(void) const;
101
102    ///
103    /// @brief print html footer of page
104    ///
105    void print_footer(std::ostream&) const;
106   
107    ///
108    /// @brief print html header of page
109    ///
110    void print_header(std::ostream&) const;
111
112    std::string output_name_; //without suffix
113    std::string path_;
114    Stats stats_;
115
116  private:
117    ///
118    /// @brief Copy Constructor, not implemented
119    ///
120    Node(const Node&);
121
122  };
123
124}} // end of namespace svnstat and namespace theplu
125
126#endif
Note: See TracBrowser for help on using the repository browser.