Jouni's Incremental BWT integrated into TextCollection
[SXSI/TextCollection.git] / TextCollectionBuilder.h
diff --git a/TextCollectionBuilder.h b/TextCollectionBuilder.h
new file mode 100644 (file)
index 0000000..3c72512
--- /dev/null
@@ -0,0 +1,68 @@
+/******************************************************************************
+ *   Copyright (C) 2009 by Niko Valimaki <nvalimak@cs.helsinki.fi>            *
+ *   Text collection interface for an in-memory XQuery/XPath engine           *
+ *                                                                            *
+ *   This program is free software; you can redistribute it and/or modify     *
+ *   it under the terms of the GNU Lesser General Public License as published *
+ *   by the Free Software Foundation; either version 2 of the License, or     *
+ *   (at your option) any later version.                                      *
+ *                                                                            *
+ *   This program is distributed in the hope that it will be useful,          *
+ *   but WITHOUT ANY WARRANTY; without even the implied warranty of           *
+ *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the            *
+ *   GNU Lesser General Public License for more details.                      *
+ *                                                                            *
+ *   You should have received a copy of the GNU Lesser General Public License *
+ *   along with this program; if not, write to the                            *
+ *   Free Software Foundation, Inc.,                                          *
+ *   59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.                *
+ ******************************************************************************/ 
+
+#ifndef _SXSI_TextCollectionBuilder_h_
+#define _SXSI_TextCollectionBuilder_h_
+
+#include "TextCollection.h"
+#include "Tools.h" // Defines ulong and uchar.
+#include <vector>
+#include <utility> // Defines std::pair.
+
+namespace SXSI
+{
+    struct TCBuilderRep; // Pimpl
+    
+    /**
+     * Build an instance of the TextCollection class.
+     */
+    class TextCollectionBuilder
+    {
+    public:
+        explicit TextCollectionBuilder(unsigned);
+        ~TextCollectionBuilder();
+        
+        /** 
+         * Insert text
+         *
+         * Must be a zero-terminated string from alphabet [1,255].
+         * Can not be called after makeStatic().
+         * The i'th text insertion gets an identifier value i-1.
+         * In other words, document identifiers start from 0.
+         */
+        void InsertText(uchar const *);
+        /**
+         * Make static
+         *
+         * Convert to a static collection; reduces space and time complexities.
+         * New texts can not be inserted after this operation.
+         */
+        TextCollection * InitTextCollection();
+        
+    private:
+        struct TCBuilderRep * p_;
+
+        // No copy constructor or assignment
+        TextCollectionBuilder();
+        TextCollectionBuilder(TextCollectionBuilder const&);
+        TextCollectionBuilder& operator = (TextCollectionBuilder const&);
+    };
+}
+#endif