1//
2// Channel.h
3//
4// Library: Foundation
5// Package: Logging
6// Module: Channel
7//
8// Definition of the Channel 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_Channel_INCLUDED
18#define Foundation_Channel_INCLUDED
19
20
21#include "Poco/Foundation.h"
22#include "Poco/Configurable.h"
23#include "Poco/Mutex.h"
24#include "Poco/RefCountedObject.h"
25
26
27namespace Poco {
28
29
30class Message;
31
32
33class Foundation_API Channel: public Configurable, public RefCountedObject
34 /// The base class for all Channel classes.
35 ///
36 /// Supports reference counting based garbage
37 /// collection and provides trivial implementations
38 /// of getProperty() and setProperty().
39{
40public:
41 Channel();
42 /// Creates the channel and initializes
43 /// the reference count to one.
44
45 virtual void open();
46 /// Does whatever is necessary to open the channel.
47 /// The default implementation does nothing.
48
49 virtual void close();
50 /// Does whatever is necessary to close the channel.
51 /// The default implementation does nothing.
52
53 virtual void log(const Message& msg) = 0;
54 /// Logs the given message to the channel. Must be
55 /// overridden by subclasses.
56 ///
57 /// If the channel has not been opened yet, the log()
58 /// method will open it.
59
60 void setProperty(const std::string& name, const std::string& value);
61 /// Throws a PropertyNotSupportedException.
62
63 std::string getProperty(const std::string& name) const;
64 /// Throws a PropertyNotSupportedException.
65
66protected:
67 virtual ~Channel();
68
69private:
70 Channel(const Channel&);
71 Channel& operator = (const Channel&);
72};
73
74
75} // namespace Poco
76
77
78#endif // Foundation_Channel_INCLUDED
79