2 /******************************************************************************
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 ******************************************************************************/
16 extern int command_count
;
17 class command_rep
: public abstract_struct
{
19 inline command_rep () { TM_DEBUG(command_count
++); }
20 inline virtual ~command_rep () { TM_DEBUG(command_count
--); }
21 inline virtual tm_ostream
& print (tm_ostream
& out
);
22 virtual void apply () = 0;
27 ABSTRACT_NULL(command
);
28 command (void (*routine
) (void));
29 command (void (*_callback
) (void*, void*), void *_obj
, void *_info
= NULL
);
31 inline void operator () (void);
32 inline friend tm_ostream
& operator << (tm_ostream
& out
, command cmd
);
34 ABSTRACT_NULL_CODE(command
);
36 inline tm_ostream
& command_rep::print (tm_ostream
& out
) { return out
<< "command"; }
37 inline void command::operator () (void) { rep
->apply(); }
38 inline bool operator == (command cmd1
, command cmd2
) {
39 return cmd1
.rep
== cmd2
.rep
; }
40 inline tm_ostream
& operator << (tm_ostream
& out
, command cmd
) {
41 if (is_nil(cmd
)) return out
<< "(null)"; else return cmd
->print(out
); }
43 #endif // defined COMMAND_H