~ubuntu-branches/ubuntu/raring/lurker/raring

« back to all changes in this revision

Viewing changes to render/Threading.h

  • Committer: Bazaar Package Importer
  • Author(s): Jonas Meurer
  • Date: 2004-09-26 16:27:51 UTC
  • Revision ID: james.westby@ubuntu.com-20040926162751-z1ohcjltv7ojtg6z
Tags: upstream-1.2
ImportĀ upstreamĀ versionĀ 1.2

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*  $Id: Threading.h,v 1.5 2004/08/24 21:52:39 terpstra Exp $
 
2
 *  
 
3
 *  Threading.h - Helper which can load a thread tree
 
4
 *  
 
5
 *  Copyright (C) 2002 - Wesley W. Terpstra
 
6
 *  
 
7
 *  License: GPL
 
8
 *  
 
9
 *  Authors: 'Wesley W. Terpstra' <wesley@terpstra.ca>
 
10
 *  
 
11
 *    This program is free software; you can redistribute it and/or modify
 
12
 *    it under the terms of the GNU General Public License as published by
 
13
 *    the Free Software Foundation; version 2.1.
 
14
 *    
 
15
 *    This program is distributed in the hope that it will be useful,
 
16
 *    but WITHOUT ANY WARRANTY; without even the implied warranty of
 
17
 *    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 
18
 *    GNU General Public License for more details.
 
19
 *    
 
20
 *    You should have received a copy of the GNU General Public License
 
21
 *    along with this program; if not, write to the Free Software
 
22
 *    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 
23
 */
 
24
 
 
25
#ifndef THREADING_H
 
26
#define THREADING_H
 
27
 
 
28
#include <MessageId.h>
 
29
#include <esort.h>
 
30
#include <set>
 
31
#include <map>
 
32
#include <vector>
 
33
#include <memory>
 
34
 
 
35
#include "Summary.h"
 
36
 
 
37
using std::set;
 
38
using std::map;
 
39
using std::ostream;
 
40
 
 
41
class Threading
 
42
{
 
43
 public:
 
44
        struct Node
 
45
        {
 
46
                Summary         summary;
 
47
                
 
48
                int             replies;
 
49
                int             replyee;
 
50
                int             replyor_first;
 
51
                int             replyor_next;
 
52
                
 
53
                int             depth;
 
54
                int             consumed;
 
55
                int             column;
 
56
                int             draw_next;
 
57
                
 
58
                string          in_reply_tos;
 
59
                
 
60
                Node(const MessageId& id_) : summary(id_) { }
 
61
                Node() : summary(MessageId()) { }
 
62
        };
 
63
        
 
64
 protected:
 
65
        typedef std::vector<Node> Nodes;
 
66
        Nodes nodes;
 
67
        map<string, int> hashes;
 
68
        
 
69
 public:
 
70
        typedef Nodes::size_type Key;
 
71
        
 
72
        string load(ESort::Reader* r, const Summary& sum, Key& out); // "" = ok
 
73
        
 
74
        Key     size()      const { return nodes.size(); }
 
75
        string  findprev(Key m, ESort::Reader* r, const Config& cfg, Summary& s);
 
76
        string  findnext(Key m, ESort::Reader* r, const Config& cfg, Summary& s);
 
77
        
 
78
        bool hasMessage(string hash) { return hashes.find(hash) != hashes.end(); }
 
79
        
 
80
        set<Summary> replies(Key k);
 
81
        Summary& getSummary(Key m);
 
82
        
 
83
        string draw_tree   (ESort::Reader* db); // prepare for row drawing
 
84
        string draw_snippet(ESort::Reader* db, Key root, const Config& cfg);
 
85
        
 
86
        void draw_tree_row   (ostream& o, int* h, Key row); // "" = ok
 
87
        void draw_snippet_row(ostream& o, int* h, Key row, Key root); // "" = ok
 
88
};
 
89
 
 
90
#endif