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 <vector>
25
26
27namespace Poco {
28
29
30class Foundation_API SplitterChannel: public Channel
31 /// This channel sends a message to multiple
32 /// channels simultaneously.
33{
34public:
35 SplitterChannel();
36 /// Creates the SplitterChannel.
37
38 void addChannel(Channel* pChannel);
39 /// Attaches a channel, which may not be null.
40
41 void removeChannel(Channel* pChannel);
42 /// Removes a channel.
43
44 void log(const Message& msg);
45 /// Sends the given Message to all
46 /// attaches channels.
47
48 void setProperty(const std::string& name, const std::string& value);
49 /// Sets or changes a configuration property.
50 ///
51 /// Only the "channel" property is supported, which allows
52 /// adding a comma-separated list of channels via the LoggingRegistry.
53 /// The "channel" property is set-only.
54 /// To simplify file-based configuration, all property
55 /// names starting with "channel" are treated as "channel".
56
57 void close();
58 /// Removes all channels.
59
60 int count() const;
61 /// Returns the number of channels in the SplitterChannel.
62
63protected:
64 ~SplitterChannel();
65
66private:
67 typedef std::vector<Channel*> ChannelVec;
68
69 ChannelVec _channels;
70 mutable FastMutex _mutex;
71};
72
73
74} // namespace Poco
75
76
77#endif // Foundation_SplitterChannel_INCLUDED
78