HierarchyMaintainer.hh 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. /*
  2. * HierarchyMaintainer.hh
  3. *
  4. * Copyright 2000, LifeLine Networks BV (www.lifeline.nl). All rights reserved.
  5. * Copyright 2000, Bastiaan Bakker. All rights reserved.
  6. *
  7. * See the COPYING file for the terms of usage and distribution.
  8. */
  9. #ifndef _LOG4CPP_HIERARCHYMAINTAINER_HH
  10. #define _LOG4CPP_HIERARCHYMAINTAINER_HH
  11. #include <log4cpp/Portability.hh>
  12. #include <string>
  13. #include <map>
  14. #include <vector>
  15. #include <log4cpp/Category.hh>
  16. #include <log4cpp/threading/Threading.hh>
  17. LOG4CPP_NS_BEGIN
  18. /**
  19. * HierarchyMaintainer is an internal log4cpp class. It is responsible
  20. * for maintaining the hierarchy of Categories. Applications should
  21. * not have to use this class directly.
  22. **/
  23. class HierarchyMaintainer {
  24. friend class Log4cppCleanup;
  25. public:
  26. typedef std::map<std::string, Category*> CategoryMap;
  27. typedef void(*shutdown_fun_ptr)();
  28. static HierarchyMaintainer& getDefaultMaintainer();
  29. HierarchyMaintainer();
  30. virtual ~HierarchyMaintainer();
  31. virtual Category* getExistingInstance(const std::string& name);
  32. virtual Category& getInstance(const std::string& name);
  33. virtual std::vector<Category*>* getCurrentCategories() const;
  34. virtual void shutdown();
  35. void register_shutdown_handler(shutdown_fun_ptr handler);
  36. virtual void deleteAllCategories();
  37. protected:
  38. virtual Category* _getExistingInstance(const std::string& name);
  39. virtual Category& _getInstance(const std::string& name);
  40. CategoryMap _categoryMap;
  41. mutable threading::Mutex _categoryMutex;
  42. private:
  43. typedef std::vector<shutdown_fun_ptr> handlers_t;
  44. static HierarchyMaintainer* _defaultMaintainer;
  45. handlers_t handlers_;
  46. };
  47. LOG4CPP_NS_END
  48. #endif // _LOG4CPP_HIERARCHYMAINTAINER_HH