source: trunk/lib/Node.h @ 100

Last change on this file since 100 was 100, checked in by Peter Johansson, 15 years ago

closes #9 and move create function from svnstat.cc to lib/utility and also move rmdirhier to lib

  • Property svn:eol-style set to native
  • Property svn:keywords set to Id
File size: 2.9 KB
Line 
1// $Id: Node.h 100 2006-06-19 09:53:16Z peter $
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#include "utility.h"
29
30#include <ostream>
31#include <sstream>
32#include <stdexcept>
33#include <string>
34
35namespace theplu{
36namespace svnstat{
37
38  ///
39  /// If something goes wrong in the use of the Node or its derived
40  /// classes, a NodeException is thrown.
41  ///
42  struct NodeException : public std::runtime_error
43  { inline NodeException(const std::string& msg) : runtime_error(msg) {} };
44
45  ///
46  /// Abstract Base Class for files.
47  ///
48  class Node
49  {
50  public:
51
52    ///
53    /// @brief Constructor
54    ///
55    //    Node(void) : path_("JARI_trixar"), stats_("JARI_trixar") { };
56
57    ///
58    /// @brief Constructor
59    ///
60    Node(const std::string&, const std::string&);
61
62    ///
63    /// @brief Destructor
64    ///
65    virtual inline ~Node(void) {};
66
67    ///
68    /// @return A properly formatted html link to this node.
69    ///
70    virtual std::string html_link(void) const=0;
71
72    inline std::string html_tablerow(void) const
73    {
74      std::stringstream ss;
75      ss << "<tr><td>" << html_link() << "</td><td align=right>" << stats_.rows()
76         << "</td></tr>\n";
77      return ss.str();
78    }
79
80    ///
81    /// @return
82    ///
83    inline const std::string& output_name(void) const { return output_name_; }
84
85    ///
86    /// @brief parsing file using svn blame.
87    ///
88    virtual const Stats& parse(const bool verbose=false)=0;
89
90    inline const std::string& path(void) const { return path_; }
91
92    ///
93    /// Function printing HTML in current working directory
94    ///
95    virtual void print(const bool verbose=false) const=0;
96
97  protected:
98    ///
99    /// Function returning everything after the last '/'
100    ///
101    /// @return name of node (not full path)
102    ///
103    inline std::string name(void) const { return file_name(path_); }
104
105    ///
106    /// @brief print html footer of page
107    ///
108    void print_footer(std::ostream&) const;
109   
110    ///
111    /// @brief print html header of page
112    ///
113    void print_header(std::ostream&) const;
114
115    std::string output_name_; //without suffix
116    std::string path_;
117    Stats stats_;
118
119  private:
120    ///
121    /// @brief Copy Constructor, not implemented
122    ///
123    Node(const Node&);
124
125  };
126
127}} // end of namespace svnstat and namespace theplu
128
129#endif
Note: See TracBrowser for help on using the repository browser.