From 322d2ca9c02e9e3b4622951bc92bd23fdbf18d0a Mon Sep 17 00:00:00 2001
From: Adam Radziszewski <adam.radziszewski@pwr.wroc.pl>
Date: Tue, 11 Dec 2012 13:09:42 +0100
Subject: [PATCH] ann sent rm chan, use with care

---
 CMakeLists.txt                     | 4 ++--
 libcorpus2/ann/annotatedsentence.h | 8 ++++++++
 swig/annotatedsentence.i           | 6 ++++++
 3 files changed, 16 insertions(+), 2 deletions(-)

diff --git a/CMakeLists.txt b/CMakeLists.txt
index 9f337a4..c44aa9a 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -1,8 +1,8 @@
 PROJECT(Corpus2Library)
 
 set(corpus2_ver_major "1")
-set(corpus2_ver_minor "2")
-set(corpus2_ver_patch "3")
+set(corpus2_ver_minor "3")
+set(corpus2_ver_patch "0")
 
 cmake_minimum_required(VERSION 2.8.0)
 
diff --git a/libcorpus2/ann/annotatedsentence.h b/libcorpus2/ann/annotatedsentence.h
index 65b3a03..1b3a335 100644
--- a/libcorpus2/ann/annotatedsentence.h
+++ b/libcorpus2/ann/annotatedsentence.h
@@ -125,6 +125,14 @@ public:
 		return true;
 	}
 
+    /**
+     * Remove channel having a given name. Returns whether removed
+     * (will return false if no channel of the given name exists).
+     */
+    bool remove_channel(const std::string& name) {
+        return (channels_.erase(name) > 0);
+    }
+
 	const chan_map_t& all_channels() const {
 		return channels_;
 	}
diff --git a/swig/annotatedsentence.i b/swig/annotatedsentence.i
index c158c4a..f3d2b4e 100644
--- a/swig/annotatedsentence.i
+++ b/swig/annotatedsentence.i
@@ -50,6 +50,12 @@ namespace Corpus2 {
     AnnotationChannel& get_channel(const std::string& name);
     const AnnotationChannel& get_channel(const std::string& name) const;
     bool add_channel(const std::string& name, const AnnotationChannel& chan);
+
+    /* Use with care. Note that get_channel returns a reference to the original
+       channel, hence it is strongly recommended to del the channel ref object
+       before attempting to call remove_channel. */
+    bool remove_channel(const std::string& name);
+
     const chan_map_t& all_channels() const;
 
     /* --------------------------------------------------------------------- */
-- 
GitLab