[gnome-commander] Generic GnomeCmd::Collection<T*> container
- From: Piotr Eljasiak <epiotr src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-commander] Generic GnomeCmd::Collection<T*> container
- Date: Tue, 22 Feb 2011 19:01:33 +0000 (UTC)
commit 0caaa0939a4db1b97fc2c077aab98c1e654b6ff0
Author: Piotr Eljasiak <epiotr src gnome org>
Date: Tue Feb 22 19:52:34 2011 +0100
Generic GnomeCmd::Collection<T*> container
src/Makefile.am | 1 +
src/gnome-cmd-collection.h | 57 ++++++++++++++++++++++++++++++++++++++++++++
2 files changed, 58 insertions(+), 0 deletions(-)
---
diff --git a/src/Makefile.am b/src/Makefile.am
index 3e281c6..f317e20 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -29,6 +29,7 @@ gnome_commander_SOURCES = \
gnome-cmd-chown-dialog.h gnome-cmd-chown-dialog.cc \
gnome-cmd-clist.h gnome-cmd-clist.cc \
gnome-cmd-cmdline.h gnome-cmd-cmdline.cc \
+ gnome-cmd-collection.h \
gnome-cmd-combo.h gnome-cmd-combo.cc \
gnome-cmd-con-device.h gnome-cmd-con-device.cc \
gnome-cmd-con-dialog.h gnome-cmd-con-dialog.cc \
diff --git a/src/gnome-cmd-collection.h b/src/gnome-cmd-collection.h
new file mode 100755
index 0000000..ad8086f
--- /dev/null
+++ b/src/gnome-cmd-collection.h
@@ -0,0 +1,57 @@
+/*
+ GNOME Commander - A GNOME based file manager
+ Copyright (C) 2001-2006 Marcus Bjurman
+ Copyright (C) 2007-2011 Piotr Eljasiak
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU 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 General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software
+ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.
+*/
+
+#ifndef __GNOME_CMD_COLLECTION_H__
+#define __GNOME_CMD_COLLECTION_H__
+
+#include <glib.h>
+
+#include <set>
+
+namespace GnomeCmd
+{
+ template <typename T>
+ struct Collection: std::set<T>
+ {
+ };
+
+ template <typename T>
+ struct Collection<T *>: std::set<T *>
+ {
+ void add(T *t) { insert(t); }
+ void remove(T *t) { erase(t); }
+ bool contain(T *t) const { return find(t)!=Collection::end(); }
+
+ GList *get_list();
+ };
+
+ template <typename T>
+ inline GList *Collection<T *>::get_list()
+ {
+ GList *list = NULL;
+
+ for (typename Collection::const_iterator i=Collection::begin(); i!=Collection::end(); ++i)
+ list = g_list_prepend (list, *i);
+
+ return list;
+ }
+}
+
+#endif // __GNOME_CMD_COLLECTION_H__
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]