switch to new MPL based Fraunhofer FOKUS Public License
[senf.git] / senf / Utils / Termlib / AbstractTerminal.hh
1 // $Id$
2 //
3 // Copyright (C) 2009
4 // Fraunhofer Institute for Open Communication Systems (FOKUS)
5 //
6 // The contents of this file are subject to the Fraunhofer FOKUS Public License
7 // Version 1.0 (the "License"); you may not use this file except in compliance
8 // with the License. You may obtain a copy of the License at 
9 // http://senf.berlios.de/license.html
10 //
11 // The Fraunhofer FOKUS Public License Version 1.0 is based on, 
12 // but modifies the Mozilla Public License Version 1.1.
13 // See the full license text for the amendments.
14 //
15 // Software distributed under the License is distributed on an "AS IS" basis, 
16 // WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License 
17 // for the specific language governing rights and limitations under the License.
18 //
19 // The Original Code is Fraunhofer FOKUS code.
20 //
21 // The Initial Developer of the Original Code is Fraunhofer-Gesellschaft e.V. 
22 // (registered association), Hansastraße 27 c, 80686 Munich, Germany.
23 // All Rights Reserved.
24 //
25 // Contributor(s):
26 //   Stefan Bund <g0dil@berlios.de>
27
28 /** \file
29     \brief Terminal public header */
30
31 #ifndef HH_SENF_Utils_Termlib_AbstractTerminal_
32 #define HH_SENF_Utils_Termlib_AbstractTerminal_ 1
33
34 // Custom includes
35 #include <string>
36
37 //#include "AbstractTerminal.mpp"
38 //-/////////////////////////////////////////////////////////////////////////////////////////////////
39
40 namespace senf {
41 namespace term {
42
43     /** \brief Abstract terminal interface
44
45         This abstract interface base class provides an abstract interface to a terminal. There are
46         two parts to this interface:
47
48         \li The interface which allows the terminal user to get information about the terminal
49         \li The interface which allows the terminal to send messages to the terminal user
50
51         The first part is implemented by providing abstract virtual members in AbstractTerminal. To
52         allow the terminal to send messages to the terminal user, the terminal user implements the
53         AbstractTerminal::Callbacks interface. The terminal user must register himself with the
54         AbstractTerminal by calling setCallbacks(). Afterwards, the AbstractTerminal implementation
55         will send calls to the terminal user via the AbstractTerminal::Callbacks API.
56      */
57     struct AbstractTerminal
58     {
59         /** \brief AbstractTerminal callbacks
60
61             \see AbastractTerminal
62          */
63         struct Callbacks {
64             virtual ~Callbacks() {}
65             virtual bool cb_init() = 0; ///< Called after terminal initialization is complete
66                                         /**< This member may return \c false. In this case, the
67                                              terminal setup is considered to have failed. */
68             virtual void cb_charReceived(char ch) = 0; ///< Called whenever a char is received
69             virtual void cb_windowSizeChanged() = 0; ///< Called when the terminal window is changed
70         };
71
72         virtual ~AbstractTerminal() {}
73
74         virtual void setCallbacks(Callbacks & cb) = 0; ///< Register terminal callbacks
75
76         virtual std::string terminalType() = 0; ///< Get the terminal type
77         virtual unsigned width() const = 0;   ///< Get current terminal window width
78         virtual unsigned height() const = 0;  ///< Get current terminal window height
79
80         virtual void write(char ch) = 0; ///< Write character to terminal
81     };
82
83 }}
84
85 //-/////////////////////////////////////////////////////////////////////////////////////////////////
86 //#include "AbstractTerminal.cci"
87 //#include "AbstractTerminal.ct"
88 //#include "AbstractTerminal.cti"
89 #endif
90
91 \f
92 // Local Variables:
93 // mode: c++
94 // fill-column: 100
95 // comment-column: 40
96 // c-file-style: "senf"
97 // indent-tabs-mode: nil
98 // ispell-local-dictionary: "american"
99 // compile-command: "scons -u test"
100 // End: