b7b96ad43c47f829dc9a5e01bbaa0633112ebbbf
[senf.git] / senf / Utils / Termlib / AbstractTerminal.hh
1 // $Id$
2 //
3 // Copyright (C) 2009
4 // Fraunhofer Institute for Open Communication Systems (FOKUS)
5 // Competence Center NETwork research (NET), St. Augustin, GERMANY
6 //     Stefan Bund <g0dil@berlios.de>
7 //
8 // This program is free software; you can redistribute it and/or modify
9 // it under the terms of the GNU General Public License as published by
10 // the Free Software Foundation; either version 2 of the License, or
11 // (at your option) any later version.
12 //
13 // This program is distributed in the hope that it will be useful,
14 // but WITHOUT ANY WARRANTY; without even the implied warranty of
15 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16 // GNU General Public License for more details.
17 //
18 // You should have received a copy of the GNU General Public License
19 // along with this program; if not, write to the
20 // Free Software Foundation, Inc.,
21 // 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
22
23 /** \file
24     \brief Terminal public header */
25
26 #ifndef HH_SENF_Utils_Termlib_AbstractTerminal_
27 #define HH_SENF_Utils_Termlib_AbstractTerminal_ 1
28
29 // Custom includes
30 #include <string>
31
32 //#include "AbstractTerminal.mpp"
33 //-/////////////////////////////////////////////////////////////////////////////////////////////////
34
35 namespace senf {
36 namespace term {
37
38     /** \brief Abstract terminal interface
39
40         This abstract interface base class provides an abstract interface to a terminal. There are
41         two parts to this interface:
42
43         \li The interface which allows the terminal user to get information about the terminal
44         \li The interface which allows the terminal to send messages to the terminal user
45
46         The first part is implemented by providing abstract virtual members in AbstractTerminal. To
47         allow the terminal to send messages to the terminal user, the terminal user implements the
48         AbstractTerminal::Callbacks interface. The terminal user must register himself with the
49         AbstractTerminal by calling setCallbacks(). Afterwards, the AbstractTerminal implementation
50         will send calls to the terminal user via the AbstractTerminal::Callbacks API.
51      */
52     struct AbstractTerminal
53     {
54         /** \brief AbstractTerminal callbacks
55
56             \see AbastractTerminal
57          */
58         struct Callbacks {
59             virtual ~Callbacks() {}
60             virtual bool cb_init() = 0; ///< Called after terminal initialization is complete
61                                         /**< This member may return \c false. In this case, the
62                                              terminal setup is considered to have failed. */
63             virtual void cb_charReceived(char ch) = 0; ///< Called whenever a char is received
64             virtual void cb_windowSizeChanged() = 0; ///< Called when the terminal window is changed
65         };
66
67         virtual ~AbstractTerminal() {}
68
69         virtual void setCallbacks(Callbacks & cb) = 0; ///< Register terminal callbacks
70
71         virtual std::string terminalType() = 0; ///< Get the terminal type
72         virtual unsigned width() const = 0;   ///< Get current terminal window width
73         virtual unsigned height() const = 0;  ///< Get current terminal window height
74
75         virtual void write(char ch) = 0; ///< Write character to terminal
76     };
77
78 }}
79
80 //-/////////////////////////////////////////////////////////////////////////////////////////////////
81 //#include "AbstractTerminal.cci"
82 //#include "AbstractTerminal.ct"
83 //#include "AbstractTerminal.cti"
84 #endif
85
86 \f
87 // Local Variables:
88 // mode: c++
89 // fill-column: 100
90 // comment-column: 40
91 // c-file-style: "senf"
92 // indent-tabs-mode: nil
93 // ispell-local-dictionary: "american"
94 // compile-command: "scons -u test"
95 // End: