From 25a143ac11baebc9ecaf5c2c05d4808f20d54e3c Mon Sep 17 00:00:00 2001 From: Andrei Karas Date: Sat, 18 May 2013 18:49:27 +0300 Subject: rename listender to depricatedlistener. --- src/CMakeLists.txt | 4 ++-- src/Makefile.am | 4 ++-- src/depricatedevent.cpp | 20 ++++++++++--------- src/depricatedevent.h | 16 ++++++++------- src/depricatedlistener.cpp | 39 +++++++++++++++++++++++++++++++++++++ src/depricatedlistener.h | 42 ++++++++++++++++++++++++++++++++++++++++ src/gui/chatwindow.h | 4 ++-- src/gui/inventorywindow.h | 4 ++-- src/gui/killstats.h | 4 ++-- src/gui/ministatuswindow.h | 4 ++-- src/gui/statuswindow.h | 4 ++-- src/listener.cpp | 39 ------------------------------------- src/listener.h | 42 ---------------------------------------- src/localplayer.h | 4 ++-- src/net/eathena/generalhandler.h | 2 -- src/net/tmwa/generalhandler.h | 2 -- src/playerinfo.cpp | 2 +- 17 files changed, 118 insertions(+), 118 deletions(-) create mode 100644 src/depricatedlistener.cpp create mode 100644 src/depricatedlistener.h delete mode 100644 src/listener.cpp delete mode 100644 src/listener.h (limited to 'src') diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index faf54448f..a90dbc212 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -568,6 +568,8 @@ SET(SRCS defaults.h depricatedevent.cpp depricatedevent.h + depricatedlistener.cpp + depricatedlistener.h effectmanager.cpp effectmanager.h emoteshortcut.cpp @@ -617,8 +619,6 @@ SET(SRCS keyevent.h keyinput.cpp keyinput.h - listener.cpp - listener.h localconsts.h localplayer.cpp localplayer.h diff --git a/src/Makefile.am b/src/Makefile.am index 773d86761..afef46e1b 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -571,6 +571,8 @@ manaplus_SOURCES += gui/widgets/avatarlistbox.cpp \ defaults.h \ depricatedevent.cpp \ depricatedevent.h \ + depricatedlistener.cpp \ + depricatedlistener.h \ effectmanager.cpp \ effectmanager.h \ emoteshortcut.cpp \ @@ -620,8 +622,6 @@ manaplus_SOURCES += gui/widgets/avatarlistbox.cpp \ keyevent.h \ keyinput.cpp \ keyinput.h \ - listener.cpp \ - listener.h \ localconsts.h \ localplayer.cpp \ localplayer.h \ diff --git a/src/depricatedevent.cpp b/src/depricatedevent.cpp index 11ea29311..b303db4dd 100644 --- a/src/depricatedevent.cpp +++ b/src/depricatedevent.cpp @@ -21,12 +21,12 @@ #include "depricatedevent.h" -#include "listener.h" +#include "depricatedlistener.h" #include "variabledata.h" #include "debug.h" -ListenMap DepricatedEvent::mBindings; +DepricatedListenMap DepricatedEvent::mBindings; DepricatedEvent::~DepricatedEvent() { @@ -107,15 +107,15 @@ double DepricatedEvent::getFloat(const std::string &key) const void DepricatedEvent::trigger(const Channels channel, const DepricatedEvent &event) { - const ListenMap::const_iterator it = mBindings.find(channel); + const DepricatedListenMap::const_iterator it = mBindings.find(channel); // Make sure something is listening if (it == mBindings.end()) return; // Loop though all listeners - ListenerSet::const_iterator lit = it->second.begin(); - const ListenerSet::const_iterator lit_end = it->second.end(); + DepricatedListenerSet::const_iterator lit = it->second.begin(); + const DepricatedListenerSet::const_iterator lit_end = it->second.end(); while (lit != lit_end) { if (*lit) @@ -124,9 +124,9 @@ void DepricatedEvent::trigger(const Channels channel, } } -void DepricatedEvent::remove(Listener *const listener) +void DepricatedEvent::remove(DepricatedListener *const listener) { - ListenMap::iterator it = mBindings.begin(); + DepricatedListenMap::iterator it = mBindings.begin(); while (it != mBindings.end()) { it->second.erase(listener); @@ -134,12 +134,14 @@ void DepricatedEvent::remove(Listener *const listener) } } -void DepricatedEvent::bind(Listener *const listener, const Channels channel) +void DepricatedEvent::bind(DepricatedListener *const listener, + const Channels channel) { mBindings[channel].insert(listener); } -void DepricatedEvent::unbind(Listener *const listener, const Channels channel) +void DepricatedEvent::unbind(DepricatedListener *const listener, + const Channels channel) { mBindings[channel].erase(listener); } diff --git a/src/depricatedevent.h b/src/depricatedevent.h index c142ec0b1..1c31cea57 100644 --- a/src/depricatedevent.h +++ b/src/depricatedevent.h @@ -39,12 +39,12 @@ enum DepricatedEvents EVENT_UPDATESTAT }; -class Listener; +class DepricatedListener; class VariableData; typedef std::map VariableMap; -typedef std::set ListenerSet; -typedef std::map ListenMap; +typedef std::set DepricatedListenerSet; +typedef std::map DepricatedListenMap; class DepricatedEvent final { @@ -84,17 +84,19 @@ class DepricatedEvent final const DepricatedEvent &event); // Removes a listener from all channels - static void remove(Listener *const listener); + static void remove(DepricatedListener *const listener); // Adds or removes a listener to a channel. - static void bind(Listener *const listener, const Channels channel); + static void bind(DepricatedListener *const listener, + const Channels channel); - static void unbind(Listener *const listener, const Channels channel); + static void unbind(DepricatedListener *const listener, + const Channels channel); private: DepricatedEvents mDepricatedEventName; - static ListenMap mBindings; + static DepricatedListenMap mBindings; VariableMap mData; }; diff --git a/src/depricatedlistener.cpp b/src/depricatedlistener.cpp new file mode 100644 index 000000000..376a85d92 --- /dev/null +++ b/src/depricatedlistener.cpp @@ -0,0 +1,39 @@ +/* + * The ManaPlus Client + * Copyright (C) 2010 The Mana Developers + * Copyright (C) 2011-2013 The ManaPlus Developers + * + * This file is part of The ManaPlus Client. + * + * 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 + * 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, see . + */ + +#include "depricatedlistener.h" + +#include "debug.h" + +DepricatedListener::~DepricatedListener() +{ + DepricatedEvent::remove(this); +} + +void DepricatedListener::listen(Channels channel) +{ + DepricatedEvent::bind(this, channel); +} + +void DepricatedListener::ignore(Channels channel) +{ + DepricatedEvent::unbind(this, channel); +} diff --git a/src/depricatedlistener.h b/src/depricatedlistener.h new file mode 100644 index 000000000..3914cac25 --- /dev/null +++ b/src/depricatedlistener.h @@ -0,0 +1,42 @@ +/* + * The ManaPlus Client + * Copyright (C) 2010 The Mana Developers + * Copyright (C) 2011-2013 The ManaPlus Developers + * + * This file is part of The ManaPlus Client. + * + * 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 + * 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, see . + */ + +#ifndef DEPRICATEDLISTENER_H +#define DEPRICATEDLISTENER_H + +#include "depricatedevent.h" + +#include + +class DepricatedListener +{ + public: + virtual ~DepricatedListener(); + + void listen(Channels channel); + + void ignore(Channels channel); + + virtual void processEvent(Channels channel, + const DepricatedEvent &event) = 0; +}; + +#endif diff --git a/src/gui/chatwindow.h b/src/gui/chatwindow.h index 39ca8ede9..e0a60a82d 100644 --- a/src/gui/chatwindow.h +++ b/src/gui/chatwindow.h @@ -23,7 +23,7 @@ #ifndef CHATWINDOW_H #define CHATWINDOW_H -#include "listener.h" +#include "depricatedlistener.h" #include "configlistener.h" @@ -92,7 +92,7 @@ struct CHATLOG final class ChatWindow final : public Window, public gcn::ActionListener, public gcn::KeyListener, - public Listener, + public DepricatedListener, public ConfigListener { public: diff --git a/src/gui/inventorywindow.h b/src/gui/inventorywindow.h index 48c097f88..952eb2afc 100644 --- a/src/gui/inventorywindow.h +++ b/src/gui/inventorywindow.h @@ -24,7 +24,7 @@ #define INVENTORYWINDOW_H #include "inventory.h" -#include "listener.h" +#include "depricatedlistener.h" #include "gui/widgets/window.h" @@ -56,7 +56,7 @@ class InventoryWindow final : public Window, public gcn::KeyListener, public gcn::SelectionListener, public InventoryListener, - public Listener + public DepricatedListener { public: /** diff --git a/src/gui/killstats.h b/src/gui/killstats.h index f2aa19e81..78c793077 100644 --- a/src/gui/killstats.h +++ b/src/gui/killstats.h @@ -25,7 +25,7 @@ #include -#include "listener.h" +#include "depricatedlistener.h" #include "gui/widgets/window.h" @@ -34,7 +34,7 @@ class Button; class KillStats final : public Window, private gcn::ActionListener, - public Listener + public DepricatedListener { public: /** diff --git a/src/gui/ministatuswindow.h b/src/gui/ministatuswindow.h index ea807f462..c95bb7602 100644 --- a/src/gui/ministatuswindow.h +++ b/src/gui/ministatuswindow.h @@ -24,7 +24,7 @@ #define MINISTATUSWINDOW_H #include "inventory.h" -#include "listener.h" +#include "depricatedlistener.h" #include "gui/widgets/popup.h" @@ -43,7 +43,7 @@ class TextPopup; */ class MiniStatusWindow final : public Popup, public InventoryListener, - public Listener + public DepricatedListener { public: MiniStatusWindow(); diff --git a/src/gui/statuswindow.h b/src/gui/statuswindow.h index 2c9e3d3f7..384c4f494 100644 --- a/src/gui/statuswindow.h +++ b/src/gui/statuswindow.h @@ -23,7 +23,7 @@ #ifndef STATUS_H #define STATUS_H -#include "listener.h" +#include "depricatedlistener.h" #include "gui/widgets/window.h" @@ -45,7 +45,7 @@ class VertContainer; */ class StatusWindow final : public Window, public gcn::ActionListener, - public Listener + public DepricatedListener { public: /** diff --git a/src/listener.cpp b/src/listener.cpp deleted file mode 100644 index 137ff66ec..000000000 --- a/src/listener.cpp +++ /dev/null @@ -1,39 +0,0 @@ -/* - * The ManaPlus Client - * Copyright (C) 2010 The Mana Developers - * Copyright (C) 2011-2013 The ManaPlus Developers - * - * This file is part of The ManaPlus Client. - * - * 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 - * 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, see . - */ - -#include "listener.h" - -#include "debug.h" - -Listener::~Listener() -{ - DepricatedEvent::remove(this); -} - -void Listener::listen(Channels channel) -{ - DepricatedEvent::bind(this, channel); -} - -void Listener::ignore(Channels channel) -{ - DepricatedEvent::unbind(this, channel); -} diff --git a/src/listener.h b/src/listener.h deleted file mode 100644 index 263e1bf97..000000000 --- a/src/listener.h +++ /dev/null @@ -1,42 +0,0 @@ -/* - * The ManaPlus Client - * Copyright (C) 2010 The Mana Developers - * Copyright (C) 2011-2013 The ManaPlus Developers - * - * This file is part of The ManaPlus Client. - * - * 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 - * 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, see . - */ - -#ifndef LISTENER_H -#define LISTENER_H - -#include "depricatedevent.h" - -#include - -class Listener -{ - public: - virtual ~Listener(); - - void listen(Channels channel); - - void ignore(Channels channel); - - virtual void processEvent(Channels channel, - const DepricatedEvent &event) = 0; -}; - -#endif diff --git a/src/localplayer.h b/src/localplayer.h index eaa7cdb10..8f5a16367 100644 --- a/src/localplayer.h +++ b/src/localplayer.h @@ -25,7 +25,7 @@ #include "actorspritelistener.h" #include "being.h" -#include "listener.h" +#include "depricatedlistener.h" #include "localconsts.h" #include "gui/userpalette.h" @@ -68,7 +68,7 @@ enum */ class LocalPlayer final : public Being, public ActorSpriteListener, - public Listener + public DepricatedListener { public: /** diff --git a/src/net/eathena/generalhandler.h b/src/net/eathena/generalhandler.h index fc86beff2..3f817ab3a 100644 --- a/src/net/eathena/generalhandler.h +++ b/src/net/eathena/generalhandler.h @@ -23,8 +23,6 @@ #ifndef NET_EATHENA_GENERALHANDLER_H #define NET_EATHENA_GENERALHANDLER_H -#include "listener.h" - #include "net/generalhandler.h" #include "net/net.h" diff --git a/src/net/tmwa/generalhandler.h b/src/net/tmwa/generalhandler.h index ea9952fa2..2290dbe38 100644 --- a/src/net/tmwa/generalhandler.h +++ b/src/net/tmwa/generalhandler.h @@ -23,8 +23,6 @@ #ifndef NET_TMWA_GENERALHANDLER_H #define NET_TMWA_GENERALHANDLER_H -#include "listener.h" - #include "net/generalhandler.h" #include "net/net.h" diff --git a/src/playerinfo.cpp b/src/playerinfo.cpp index 7439aee60..673e6f8cf 100644 --- a/src/playerinfo.cpp +++ b/src/playerinfo.cpp @@ -24,7 +24,7 @@ #include "client.h" #include "depricatedevent.h" #include "inventory.h" -#include "listener.h" +#include "depricatedlistener.h" #include "logger.h" #include "gui/inventorywindow.h" -- cgit v1.2.3-70-g09d2