SplitterChannel.h 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  1. //
  2. // SplitterChannel.h
  3. //
  4. // $Id: //poco/1.4/Foundation/include/Poco/SplitterChannel.h#1 $
  5. //
  6. // Library: Foundation
  7. // Package: Logging
  8. // Module: SplitterChannel
  9. //
  10. // Definition of the SplitterChannel 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_SplitterChannel_INCLUDED
  18. #define Foundation_SplitterChannel_INCLUDED
  19. #include "Poco/Foundation.h"
  20. #include "Poco/Channel.h"
  21. #include "Poco/Mutex.h"
  22. #include <vector>
  23. namespace Poco {
  24. class Foundation_API SplitterChannel: public Channel
  25. /// This channel sends a message to multiple
  26. /// channels simultaneously.
  27. {
  28. public:
  29. SplitterChannel();
  30. /// Creates the SplitterChannel.
  31. void addChannel(Channel* pChannel);
  32. /// Attaches a channel, which may not be null.
  33. void removeChannel(Channel* pChannel);
  34. /// Removes a channel.
  35. void log(const Message& msg);
  36. /// Sends the given Message to all
  37. /// attaches channels.
  38. void setProperty(const std::string& name, const std::string& value);
  39. /// Sets or changes a configuration property.
  40. ///
  41. /// Only the "channel" property is supported, which allows
  42. /// adding a comma-separated list of channels via the LoggingRegistry.
  43. /// The "channel" property is set-only.
  44. /// To simplify file-based configuration, all property
  45. /// names starting with "channel" are treated as "channel".
  46. void close();
  47. /// Removes all channels.
  48. int count() const;
  49. /// Returns the number of channels in the SplitterChannel.
  50. protected:
  51. ~SplitterChannel();
  52. private:
  53. typedef std::vector<Channel*> ChannelVec;
  54. ChannelVec _channels;
  55. mutable FastMutex _mutex;
  56. };
  57. } // namespace Poco
  58. #endif // Foundation_SplitterChannel_INCLUDED