Channel.h 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  1. //
  2. // Channel.h
  3. //
  4. // $Id: //poco/1.4/Foundation/include/Poco/Channel.h#1 $
  5. //
  6. // Library: Foundation
  7. // Package: Logging
  8. // Module: Channel
  9. //
  10. // Definition of the Channel class.
  11. //
  12. // Copyright (c) 2004-2006, Applied Informatics Software Engineering GmbH.
  13. // and Contributors.
  14. //
  15. // SPDX-License-Identifier: BSL-1.0
  16. //
  17. #ifndef Foundation_Channel_INCLUDED
  18. #define Foundation_Channel_INCLUDED
  19. #include "Poco/Foundation.h"
  20. #include "Poco/Configurable.h"
  21. #include "Poco/Mutex.h"
  22. #include "Poco/RefCountedObject.h"
  23. namespace Poco {
  24. class Message;
  25. class Foundation_API Channel: public Configurable, public RefCountedObject
  26. /// The base class for all Channel classes.
  27. ///
  28. /// Supports reference counting based garbage
  29. /// collection and provides trivial implementations
  30. /// of getProperty() and setProperty().
  31. {
  32. public:
  33. Channel();
  34. /// Creates the channel and initializes
  35. /// the reference count to one.
  36. virtual void open();
  37. /// Does whatever is necessary to open the channel.
  38. /// The default implementation does nothing.
  39. virtual void close();
  40. /// Does whatever is necessary to close the channel.
  41. /// The default implementation does nothing.
  42. virtual void log(const Message& msg) = 0;
  43. /// Logs the given message to the channel. Must be
  44. /// overridden by subclasses.
  45. ///
  46. /// If the channel has not been opened yet, the log()
  47. /// method will open it.
  48. void setProperty(const std::string& name, const std::string& value);
  49. /// Throws a PropertyNotSupportedException.
  50. std::string getProperty(const std::string& name) const;
  51. /// Throws a PropertyNotSupportedException.
  52. protected:
  53. virtual ~Channel();
  54. private:
  55. Channel(const Channel&);
  56. Channel& operator = (const Channel&);
  57. };
  58. } // namespace Poco
  59. #endif // Foundation_Channel_INCLUDED