From bfaec62d795ffe17ef82640efa06be6b056475cc Mon Sep 17 00:00:00 2001 From: Mark Tiefenbruck Date: Tue, 3 Jun 2008 00:15:37 -0700 Subject: remove some unnecessary architecture --- src/CommandDialog.cc | 4 +-- src/FbTk/CommandParser.hh | 24 ++++++++++++++---- src/FbTk/Makefile.am | 2 +- src/FbTk/ObjectRegistry.hh | 63 ---------------------------------------------- 4 files changed, 22 insertions(+), 71 deletions(-) delete mode 100644 src/FbTk/ObjectRegistry.hh diff --git a/src/CommandDialog.cc b/src/CommandDialog.cc index 37e7bdd..3746b98 100644 --- a/src/CommandDialog.cc +++ b/src/CommandDialog.cc @@ -167,8 +167,8 @@ void CommandDialog::tabComplete() { return; } - FbTk::ObjectRegistry::Creator>::CreatorMap::const_iterator it = FbTk::ObjectRegistry::Creator>::instance().creatorMap().begin(); - const FbTk::ObjectRegistry::Creator>::CreatorMap::const_iterator it_end = FbTk::ObjectRegistry::Creator>::instance().creatorMap().end(); + FbTk::CommandParser::CreatorMap::const_iterator it = FbTk::CommandParser::instance().creatorMap().begin(); + const FbTk::CommandParser::CreatorMap::const_iterator it_end = FbTk::CommandParser::instance().creatorMap().end(); vector matches; for (; it != it_end; ++it) { if ((*it).first.find(prefix) == 0) { diff --git a/src/FbTk/CommandParser.hh b/src/FbTk/CommandParser.hh index 006036d..45ce001 100644 --- a/src/FbTk/CommandParser.hh +++ b/src/FbTk/CommandParser.hh @@ -22,9 +22,11 @@ #ifndef CommandParser_HH #define CommandParser_HH -#include "ObjectRegistry.hh" #include "StringUtil.hh" +#include +#include + using std::string; namespace FbTk { @@ -86,6 +88,7 @@ template class CommandParser { public: typedef Command *(*Creator)(const string &, const string &, bool); + typedef std::map CreatorMap; static CommandParser &instance() { static CommandParser s_instance; @@ -93,9 +96,9 @@ public: } Command *parse(const string &name, const string &args, - bool trusted = true) const { + bool trusted = true) const { string lc = StringUtil::toLower(name); - Creator creator = ObjectRegistry::instance().lookup(lc); + Creator creator = lookup(lc); if (creator) return creator(lc, args, trusted); return 0; @@ -114,13 +117,24 @@ public: bool registerCommand(string name, Creator creator) { name = StringUtil::toLower(name); - return ObjectRegistry::instance().registerObject(name, - creator); + m_creators[name] = creator; + return true; + } + + Creator lookup(const std::string &name) const { + typename CreatorMap::const_iterator it = m_creators.find(name); + if (it == m_creators.end()) + return 0; + return it->second; } + const CreatorMap creatorMap() const { return m_creators; } + private: CommandParser() {} ~CommandParser() {} + + CreatorMap m_creators; }; } // end namespace FbTk diff --git a/src/FbTk/Makefile.am b/src/FbTk/Makefile.am index f830e4a..ad5a048 100644 --- a/src/FbTk/Makefile.am +++ b/src/FbTk/Makefile.am @@ -16,7 +16,7 @@ imlib2_SOURCE= ImageImlib2.hh ImageImlib2.cc endif libFbTk_a_SOURCES = App.hh App.cc Color.cc Color.hh Command.hh \ - ObjectRegistry.hh Accessor.hh DefaultValue.hh \ + Accessor.hh DefaultValue.hh \ FileUtil.hh FileUtil.cc \ EventHandler.hh EventManager.hh EventManager.cc \ FbWindow.hh FbWindow.cc Font.cc Font.hh FontImp.hh \ diff --git a/src/FbTk/ObjectRegistry.hh b/src/FbTk/ObjectRegistry.hh deleted file mode 100644 index 4f47b77..0000000 --- a/src/FbTk/ObjectRegistry.hh +++ /dev/null @@ -1,63 +0,0 @@ -// ObjectRegistry.hh for FbTk -// Copyright (c) 2007 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 OBJECTREGISTRY_HH -#define OBJECTREGISTRY_HH - -#include -#include - -namespace FbTk { - -template -class ObjectRegistry { -public: - typedef std::map CreatorMap; - - static ObjectRegistry &instance() { - static ObjectRegistry s_instance; - return s_instance; - } - - Creator lookup(const std::string &name) { - typename CreatorMap::const_iterator it = m_creators.find(name); - if (it == m_creators.end()) - return 0; - return it->second; - } - - bool registerObject(const std::string &name, Creator creator) { - m_creators[name] = creator; - return true; - } - - const CreatorMap creatorMap() const { return m_creators; } - -private: - ObjectRegistry() {} - ~ObjectRegistry() {} - - CreatorMap m_creators; -}; - -} // end namespace FbTk - -#endif // OBJECTREGISTRY_HH -- cgit v0.11.2