initializer.h 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. // Copyright (C) 2015-2017, Vaclav Haisman. All rights reserved.
  2. //
  3. // Redistribution and use in source and binary forms, with or without modifica-
  4. // tion, are permitted provided that the following conditions are met:
  5. //
  6. // 1. Redistributions of source code must retain the above copyright notice,
  7. // this list of conditions and the following disclaimer.
  8. //
  9. // 2. Redistributions in binary form must reproduce the above copyright notice,
  10. // this list of conditions and the following disclaimer in the documentation
  11. // and/or other materials provided with the distribution.
  12. //
  13. // THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES,
  14. // INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
  15. // FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
  16. // APACHE SOFTWARE FOUNDATION OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
  17. // INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLU-
  18. // DING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
  19. // OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
  20. // ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  21. // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
  22. // THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  23. #ifndef LOG4CPLUS_INITIALIZER_HXX
  24. #define LOG4CPLUS_INITIALIZER_HXX
  25. #include <log4cplus/config.hxx>
  26. #if defined (LOG4CPLUS_HAVE_PRAGMA_ONCE)
  27. #pragma once
  28. #endif
  29. #include <memory>
  30. namespace log4cplus
  31. {
  32. /**
  33. This class helps with initialization and shutdown of log4cplus. Its
  34. constructor calls `log4cplus::initialize()` and its destructor calls
  35. `log4cplus::Logger::shutdown()`. Use this class as the first thing in your
  36. `main()`. It will ensure shutdown of log4cplus at the end of
  37. `main()`. This is particularly important on Windows, where shutdown of
  38. standard threads outside `main()` is impossible.
  39. */
  40. class LOG4CPLUS_EXPORT Initializer
  41. {
  42. public:
  43. Initializer ();
  44. ~Initializer ();
  45. Initializer (Initializer const &) = delete;
  46. Initializer (Initializer &&) = delete;
  47. Initializer & operator = (Initializer const &) = delete;
  48. Initializer & operator = (Initializer &&) = delete;
  49. };
  50. } // namespace log4cplus
  51. #endif // LOG4CPLUS_INITIALIZER_HXX