Debug swcsa
[SXSI/TextCollection.git] / RLCSABuilder.h
1 /******************************************************************************
2  *   Copyright (C) 2009 by Niko Valimaki <nvalimak@cs.helsinki.fi>            *
3  *                                                                            *
4  *   This program is free software; you can redistribute it and/or modify     *
5  *   it under the terms of the GNU Lesser General Public License as published *
6  *   by the Free Software Foundation; either version 2 of the License, or     *
7  *   (at your option) any later version.                                      *
8  *                                                                            *
9  *   This program is distributed in the hope that it will be useful,          *
10  *   but WITHOUT ANY WARRANTY; without even the implied warranty of           *
11  *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the            *
12  *   GNU Lesser General Public License for more details.                      *
13  *                                                                            *
14  *   You should have received a copy of the GNU Lesser General Public License *
15  *   along with this program; if not, write to the                            *
16  *   Free Software Foundation, Inc.,                                          *
17  *   59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.                *
18  ******************************************************************************/ 
19
20 #ifndef _SXSI_RLCSABuilder_h_
21 #define _SXSI_RLCSABuilder_h_
22
23 #include "TextCollectionBuilder.h"
24 #include "TextStorage.h"
25 #include "Tools.h" // Defines ulong and uchar.
26
27 #include <string>
28 #include <vector>
29 #include <utility> // Defines std::pair.
30 #include <cstring> // Defines std::strlen, added by Kim
31
32 namespace SXSI
33 {
34     struct TCBuilderRep; // Pimpl
35     
36     /**
37      * Build an instance of the TextCollection class.
38      */
39     class RLCSABuilder : public TextCollectionBuilder
40     {
41     public:
42         RLCSABuilder(unsigned samplerate, ulong estimatedInputLength);
43
44         virtual ~RLCSABuilder();
45         
46         /** 
47          * Insert text
48          *
49          * Must be a zero-terminated string from alphabet [1,255].
50          * Can not be called after makeStatic().
51          * The i'th text insertion gets an identifier value i-1.
52          * In other words, document identifiers start from 0.
53          *
54          * Second parameter tells if the text will be added to the
55          * index also. If false, text is added only to the TextCollection
56          * and can not be searched for.
57          */
58         virtual void InsertText(uchar const *, bool index = true);
59
60         /**
61          * Make static
62          *
63          * Convert to a static collection.
64          * New texts can not be inserted after this operation.
65          *
66          * TextStorage type defaults to TYPE_PLAIN_TEXT, another
67          * possible type is TYPE_LZ_INDEX.
68          */
69         virtual TextCollection * InitTextCollection(char type = TextStorage::TYPE_PLAIN_TEXT);
70         
71     private:
72         RLCSABuilder();
73         
74         // Using Pimpl idiom to hide RLCSA implementation.
75         struct TCBuilderRep * p_;
76
77         // No copy constructor or assignment
78         RLCSABuilder(RLCSABuilder const&);
79         RLCSABuilder& operator = (RLCSABuilder const&);
80     };
81 }
82 #endif