1//
2// SplitterChannel.h
3//
4// Library: Foundation
5// Package: Logging
6// Module: SplitterChannel
7//
8// Definition of the SplitterChannel class.
9//
10// Copyright (c) 2004-2006, Applied Informatics Software Engineering GmbH.
11// and Contributors.
12//
13// SPDX-License-Identifier: BSL-1.0
14//
15
16
17#ifndef Foundation_SplitterChannel_INCLUDED
18#define Foundation_SplitterChannel_INCLUDED
19
20
21#include "Poco/Foundation.h"
22#include "Poco/Channel.h"
23#include "Poco/Mutex.h"
24#include "Poco/AutoPtr.h"
25#include <vector>
26
27
28namespace Poco {
29
30
31class Foundation_API SplitterChannel: public Channel
32 /// This channel sends a message to multiple
33 /// channels simultaneously.
34{
35public:
36 typedef AutoPtr<SplitterChannel> Ptr;
37
38 SplitterChannel();
39 /// Creates the SplitterChannel.
40
41 void addChannel(Channel::Ptr pChannel);
42 /// Attaches a channel, which may not be null.
43
44 void removeChannel(Channel::Ptr pChannel);
45 /// Removes a channel.
46
47 void log(const Message& msg);
48 /// Sends the given Message to all
49 /// attaches channels.
50
51 void setProperty(const std::string& name, const std::string& value);
52 /// Sets or changes a configuration property.
53 ///
54 /// Only the "channel" property is supported, which allows
55 /// adding a comma-separated list of channels via the LoggingRegistry.
56 /// The "channel" property is set-only.
57 /// To simplify file-based configuration, all property
58 /// names starting with "channel" are treated as "channel".
59
60 void close();
61 /// Removes all channels.
62
63 int count() const;
64 /// Returns the number of channels in the SplitterChannel.
65
66protected:
67 ~SplitterChannel();
68
69private:
70 typedef std::vector<Channel::Ptr> ChannelVec;
71
72 ChannelVec _channels;
73 mutable FastMutex _mutex;
74};
75
76
77} // namespace Poco
78
79
80#endif // Foundation_SplitterChannel_INCLUDED
81