source: trunk/lib/Node.h @ 101

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

closes #28 #18 and added some lippstick to the node daughters table output

  • Property svn:eol-style set to native
  • Property svn:keywords set to Id
File size: 3.1 KB
Line 
1// $Id: Node.h 101 2006-06-22 09:00:06Z 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 true if directory
69    ///
70    virtual bool dir(void) const;
71
72    ///
73    /// @return A properly formatted html link to this node.
74    ///
75    virtual std::string html_link(void) const=0;
76
77    ///
78    ///
79    ///
80    std::string html_tablerow(const std::string&) const;
81
82    ///
83    /// @return
84    ///
85    inline const std::string& output_name(void) const { return output_name_; }
86
87    ///
88    /// @brief parsing file using svn blame.
89    ///
90    virtual const Stats& parse(const bool verbose=false)=0;
91
92    inline const std::string& path(void) const { return path_; }
93
94    ///
95    /// Function printing HTML in current working directory
96    ///
97    virtual void print(const bool verbose=false) const=0;
98
99  protected:
100    ///
101    /// Function returning everything after the last '/'
102    ///
103    /// @return name of node (not full path)
104    ///
105    inline std::string name(void) const { return file_name(path_); }
106
107    ///
108    /// @brief print html footer of page
109    ///
110    void print_footer(std::ostream&) const;
111   
112    ///
113    /// @brief print html header of page
114    ///
115    void print_header(std::ostream&) const;
116
117    std::string output_name_; //without suffix
118    std::string path_;
119    Stats stats_;
120
121  private:
122    ///
123    /// @brief Copy Constructor, not implemented
124    ///
125    Node(const Node&);
126
127  };
128
129  struct NodePtrLess
130  {
131    inline bool operator()(const Node* first, const Node* second) const
132    {   
133      if (first->dir()==second->dir())
134        return first->output_name()<second->output_name();
135      return first->dir();
136    }
137  };
138
139}} // end of namespace svnstat and namespace theplu
140
141#endif
Note: See TracBrowser for help on using the repository browser.