00001 // 00002 // Author: Lorenzo Bettini <http://www.lorenzobettini.it>, (C) 2004-2008 00003 // 00004 // Copyright: See COPYING file that comes with this distribution 00005 // 00006 00007 #ifndef FORMATTERMANAGER_H_ 00008 #define FORMATTERMANAGER_H_ 00009 00010 #include <string> 00011 #include <map> 00012 00013 #include "formatter.h" 00014 00015 namespace srchilite { 00016 00018 typedef std::map<std::string, FormatterPtr> FormatterMap; 00019 00024 class FormatterManager { 00026 mutable FormatterMap formatterMap; 00027 00030 FormatterPtr defaultFormatter; 00031 public: 00036 FormatterManager(FormatterPtr _defaultFormatter); 00037 ~FormatterManager(); 00038 00046 FormatterPtr getFormatter(const std::string &elem) const; 00047 00048 FormatterPtr getDefaultFormatter() const { 00049 return defaultFormatter; 00050 } 00051 00052 void setDefaultFormatter(FormatterPtr def) { 00053 defaultFormatter = def; 00054 } 00055 00062 FormatterPtr hasFormatter(const std::string &elem) const; 00063 00070 void addFormatter(const std::string &elem, FormatterPtr formatter); 00071 00075 void reset() { 00076 formatterMap.clear(); 00077 } 00078 00082 const FormatterMap &getFormatterMap() const { 00083 return formatterMap; 00084 } 00085 }; 00086 00087 } 00088 00089 #endif /*FORMATTERMANAGER_H_*/