appenderattachable.h 2.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889
  1. // -*- C++ -*-
  2. // Module: Log4CPLUS
  3. // File: appenderattachable.h
  4. // Created: 6/2001
  5. // Author: Tad E. Smith
  6. //
  7. //
  8. // Copyright 2001-2017 Tad E. Smith
  9. //
  10. // Licensed under the Apache License, Version 2.0 (the "License");
  11. // you may not use this file except in compliance with the License.
  12. // You may obtain a copy of the License at
  13. //
  14. // http://www.apache.org/licenses/LICENSE-2.0
  15. //
  16. // Unless required by applicable law or agreed to in writing, software
  17. // distributed under the License is distributed on an "AS IS" BASIS,
  18. // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  19. // See the License for the specific language governing permissions and
  20. // limitations under the License.
  21. /** @file */
  22. #ifndef LOG4CPLUS_SPI_APPENDER_ATTACHABLE_HEADER_
  23. #define LOG4CPLUS_SPI_APPENDER_ATTACHABLE_HEADER_
  24. #include <log4cplus/config.hxx>
  25. #if defined (LOG4CPLUS_HAVE_PRAGMA_ONCE)
  26. #pragma once
  27. #endif
  28. #include <log4cplus/appender.h>
  29. #include <log4cplus/tstring.h>
  30. #include <log4cplus/helpers/pointer.h>
  31. #include <vector>
  32. namespace log4cplus {
  33. // Forward Declarations
  34. typedef std::vector<log4cplus::SharedAppenderPtr> SharedAppenderPtrList;
  35. namespace spi {
  36. /**
  37. * This Interface is for attaching Appenders to objects.
  38. */
  39. class LOG4CPLUS_EXPORT AppenderAttachable {
  40. public:
  41. // Methods
  42. /**
  43. * Add an appender.
  44. */
  45. virtual void addAppender(SharedAppenderPtr newAppender) = 0;
  46. /**
  47. * Get all previously added appenders as an Enumeration.
  48. */
  49. virtual SharedAppenderPtrList getAllAppenders() = 0;
  50. /**
  51. * Get an appender by name.
  52. */
  53. virtual SharedAppenderPtr getAppender(const log4cplus::tstring& name) = 0;
  54. /**
  55. * Remove all previously added appenders.
  56. */
  57. virtual void removeAllAppenders() = 0;
  58. /**
  59. * Remove the appender passed as parameter from the list of appenders.
  60. */
  61. virtual void removeAppender(SharedAppenderPtr appender) = 0;
  62. /**
  63. * Remove the appender with the name passed as parameter from the
  64. * list of appenders.
  65. */
  66. virtual void removeAppender(const log4cplus::tstring& name) = 0;
  67. // Dtor
  68. virtual ~AppenderAttachable() = 0;
  69. };
  70. } // end namespace spi
  71. } // end namespace log4cplus
  72. #endif // LOG4CPLUS_SPI_APPENDER_ATTACHABLE_HEADER_