Systematic use of tm_ostream class instead of ostream (removing dependency on std)
[texmacs.git] / src / src / Kernel / Abstractions / command.cpp
blob37763966d21522ae63127afe135e269f48d8b057
2 /******************************************************************************
3 * MODULE : command.cpp
4 * DESCRIPTION: Abstract dynamic commands
5 * COPYRIGHT : (C) 1999 Joris van der Hoeven
6 *******************************************************************************
7 * This software falls under the GNU general public license version 3 or later.
8 * It comes WITHOUT ANY WARRANTY WHATSOEVER. For details, see the file LICENSE
9 * in the root directory or <http://www.gnu.org/licenses/gpl-3.0.html>.
10 ******************************************************************************/
12 #include "command.hpp"
14 /******************************************************************************
15 * standard commands without arguments
16 ******************************************************************************/
18 class std_command_rep: public command_rep {
19 void (*routine) (void);
20 public:
21 std_command_rep (void (*routine) (void));
22 void apply ();
25 std_command_rep::std_command_rep (void (*routine2) (void)):
26 routine (routine2) {}
27 void std_command_rep::apply () { routine (); }
29 command::command (void (*routine) (void)) :
30 rep (tm_new<std_command_rep> (routine)) { INC_COUNT(rep); }
33 class generic_command_rep: public command_rep {
34 void (*callback) (void*, void*); // callback
35 void *obj; // argument for callback
36 void *info; // additional info
38 public:
39 generic_command_rep (void (*_callback) (void*, void*), void *_obj, void *_info)
40 : callback (_callback), obj (_obj), info (_info) {}
41 void apply () { if (callback) callback (obj, info); }
42 tm_ostream& print (tm_ostream& out) { return out << "generic_command_rep"; }
45 command::command (void (*_callback) (void*, void*), void *_obj, void *_info) :
46 rep (tm_new<generic_command_rep> (_callback, _obj, _info)) { INC_COUNT(rep); }