From 0ec165e85b313588d43dbdc2450da9838c4c528f Mon Sep 17 00:00:00 2001 From: Mark Tiefenbruck Date: Thu, 27 Dec 2007 22:22:38 -0800 Subject: move STLUtil to FbTk --- src/AttentionNoticeHandler.cc | 4 ++-- src/FbTk/Makefile.am | 2 +- src/FbTk/STLUtil.hh | 55 ++++++++++++++++++++++++++++++++++++++++++ src/IconbarTool.cc | 4 ++-- src/Makefile.am | 1 - src/STLUtil.hh | 56 ------------------------------------------- src/Screen.cc | 5 ++-- 7 files changed, 62 insertions(+), 65 deletions(-) create mode 100644 src/FbTk/STLUtil.hh delete mode 100644 src/STLUtil.hh diff --git a/src/AttentionNoticeHandler.cc b/src/AttentionNoticeHandler.cc index 3f28695..a28c7fb 100644 --- a/src/AttentionNoticeHandler.cc +++ b/src/AttentionNoticeHandler.cc @@ -25,8 +25,8 @@ #include "Window.hh" #include "Screen.hh" -#include "STLUtil.hh" +#include "FbTk/STLUtil.hh" #include "FbTk/Subject.hh" #include "FbTk/Timer.hh" #include "FbTk/Resource.hh" @@ -50,7 +50,7 @@ private: AttentionNoticeHandler::~AttentionNoticeHandler() { - STLUtil::destroyAndClearSecond(m_attentions); + FbTk::STLUtil::destroyAndClearSecond(m_attentions); } void AttentionNoticeHandler::addAttention(Focusable &client) { diff --git a/src/FbTk/Makefile.am b/src/FbTk/Makefile.am index 5f1c246..f5970fd 100644 --- a/src/FbTk/Makefile.am +++ b/src/FbTk/Makefile.am @@ -57,7 +57,7 @@ libFbTk_a_SOURCES = App.hh App.cc Color.cc Color.hh Command.hh \ MenuSeparator.hh MenuSeparator.cc \ stringstream.hh \ TypeAhead.hh SearchResult.hh SearchResult.cc ITypeAheadable.hh \ - Select2nd.hh \ + Select2nd.hh STLUtil.hh \ CachedPixmap.hh CachedPixmap.cc \ ${xpm_SOURCE} \ ${xft_SOURCE} \ diff --git a/src/FbTk/STLUtil.hh b/src/FbTk/STLUtil.hh new file mode 100644 index 0000000..ec783d9 --- /dev/null +++ b/src/FbTk/STLUtil.hh @@ -0,0 +1,55 @@ +// STLUtil.cc for FbTk +// Copyright (c) 2006 Fluxbox Team (fluxgen at fluxbox dot org) +// +// Permission is hereby granted, free of charge, to any person obtaining a +// copy of this software and associated documentation files (the "Software"), +// to deal in the Software without restriction, including without limitation +// the rights to use, copy, modify, merge, publish, distribute, sublicense, +// and/or sell copies of the Software, and to permit persons to whom the +// Software is furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL +// THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER +// DEALINGS IN THE SOFTWARE. + +#ifndef FBTK_STLUTIL_HH +#define FBTK_STLUTIL_HH + +/// contains useful utilities for STL +namespace FbTk { +namespace STLUtil { + +/// calls delete on each item in the container and then clears the container +template +void destroyAndClear(A &a) { + typedef typename A::iterator iterator; + iterator it = a.begin(); + iterator it_end = a.end(); + for (; it != it_end; ++it) + delete (*it); + + a.clear(); +} + +/// calls delete on each item value in the map and then clears the map +template +void destroyAndClearSecond(A &a) { + typedef typename A::iterator iterator; + iterator it = a.begin(); + iterator it_end = a.end(); + for (; it != it_end; ++it) + delete it->second; + a.clear(); +} + +}; // end namespace STLUtil +}; // end namespace FbTk + +#endif // STLUTIL_Hh diff --git a/src/IconbarTool.cc b/src/IconbarTool.cc index de56569..4275ec9 100644 --- a/src/IconbarTool.cc +++ b/src/IconbarTool.cc @@ -37,8 +37,8 @@ #include "FocusControl.hh" #include "FbCommands.hh" #include "Layer.hh" -#include "STLUtil.hh" +#include "FbTk/STLUtil.hh" #include "FbTk/I18n.hh" #include "FbTk/Menu.hh" #include "FbTk/MenuItem.hh" @@ -523,7 +523,7 @@ void IconbarTool::renderButton(IconButton &button, bool clear) { void IconbarTool::deleteIcons() { m_icon_container.removeAll(); - STLUtil::destroyAndClearSecond(m_icons); + FbTk::STLUtil::destroyAndClearSecond(m_icons); } void IconbarTool::removeWindow(Focusable &win) { diff --git a/src/Makefile.am b/src/Makefile.am index b40affd..312d52a 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -143,7 +143,6 @@ fluxbox_SOURCES = AtomHandler.hh ArrowButton.hh ArrowButton.cc \ AttentionNoticeHandler.hh AttentionNoticeHandler.cc \ IconButton.hh IconButton.cc \ IconbarTheme.hh IconbarTheme.cc \ - STLUtil.hh \ Focusable.hh FocusableList.hh FocusableList.cc \ ${newwmspec_SOURCE} ${gnome_SOURCE} \ ${REMEMBER_SOURCE} ${TOOLBAR_SOURCE} diff --git a/src/STLUtil.hh b/src/STLUtil.hh deleted file mode 100644 index a9b08e0..0000000 --- a/src/STLUtil.hh +++ /dev/null @@ -1,56 +0,0 @@ -// STLUtil.cc for fluxbox -// Copyright (c) 2006 Fluxbox Team (fluxgen at fluxbox dot org) -// -// Permission is hereby granted, free of charge, to any person obtaining a -// copy of this software and associated documentation files (the "Software"), -// to deal in the Software without restriction, including without limitation -// the rights to use, copy, modify, merge, publish, distribute, sublicense, -// and/or sell copies of the Software, and to permit persons to whom the -// Software is furnished to do so, subject to the following conditions: -// -// The above copyright notice and this permission notice shall be included in -// all copies or substantial portions of the Software. -// -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL -// THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING -// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER -// DEALINGS IN THE SOFTWARE. - -// $Id$ - - -#ifndef STLUTIL_HH -#define STLUTIL_HH - -/// contains useful utilities for STL -namespace STLUtil { - -/// calls delete on each item in the container and then clears the container -template -void destroyAndClear(A &a) { - typedef typename A::iterator iterator; - iterator it = a.begin(); - iterator it_end = a.end(); - for (; it != it_end; ++it) - delete (*it); - - a.clear(); -} - -/// calls delete on each item value in the map and then clears the map -template -void destroyAndClearSecond(A &a) { - typedef typename A::iterator iterator; - iterator it = a.begin(); - iterator it_end = a.end(); - for (; it != it_end; ++it) - delete it->second; - a.clear(); -} - -}; - -#endif // STLUTIL_Hh diff --git a/src/Screen.cc b/src/Screen.cc index c304b7e..03d8fd2 100644 --- a/src/Screen.cc +++ b/src/Screen.cc @@ -37,8 +37,6 @@ #include "FocusControl.hh" #include "ScreenPlacement.hh" -#include "STLUtil.hh" - // themes #include "FbWinFrameTheme.hh" #include "MenuTheme.hh" @@ -79,6 +77,7 @@ #include "FbTk/Select2nd.hh" #include "FbTk/Compose.hh" #include "FbTk/FbString.hh" +#include "FbTk/STLUtil.hh" //use GNU extensions #ifndef _GNU_SOURCE @@ -588,7 +587,7 @@ BScreen::~BScreen() { imageControl().removeImage(pos_pixmap); removeWorkspaceNames(); - using namespace STLUtil; + using namespace FbTk::STLUtil; destroyAndClear(m_workspaces_list); destroyAndClear(m_managed_resources); -- cgit v0.11.2