libyui  3.10.0
YMacro.cc
1 /*
2  Copyright (C) 2000-2012 Novell, Inc
3  This library is free software; you can redistribute it and/or modify
4  it under the terms of the GNU Lesser General Public License as
5  published by the Free Software Foundation; either version 2.1 of the
6  License, or (at your option) version 3.0 of the License. This library
7  is distributed in the hope that it will be useful, but WITHOUT ANY
8  WARRANTY; without even the implied warranty of MERCHANTABILITY or
9  FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
10  License for more details. You should have received a copy of the GNU
11  Lesser General Public License along with this library; if not, write
12  to the Free Software Foundation, Inc., 51 Franklin Street, Fifth
13  Floor, Boston, MA 02110-1301 USA
14 */
15 
16 
17 /*-/
18 
19  File: YMacro.cc
20 
21  Author: Stefan Hundhammer <sh@suse.de>
22 
23 /-*/
24 
25 
26 #include "YMacro.h"
27 #include "YMacroRecorder.h"
28 #include "YMacroPlayer.h"
29 
30 using std::string;
31 
32 
33 YMacroRecorder * YMacro::_recorder = 0;
34 YMacroPlayer * YMacro::_player = 0;
35 
36 
38 {
39  if ( _recorder )
40  delete _recorder;
41 
42  _recorder = recorder;
43 }
44 
45 
47 {
48  if ( _player )
49  delete _player;
50 
51  _player = player;
52 }
53 
54 
55 void YMacro::record( const string & macroFile )
56 {
57  if ( _recorder )
58  _recorder->record( macroFile );
59 }
60 
61 
63 {
64  if ( _recorder )
65  _recorder->endRecording();
66 }
67 
68 
70 {
71  if ( _recorder )
72  return _recorder->recording();
73  else
74  return false;
75 }
76 
77 
78 void YMacro::play( const string & macroFile )
79 {
80  if ( _player )
81  _player->play( macroFile );
82 }
83 
84 
86 {
87  if ( _player && _player->playing() )
88  _player->playNextBlock();
89 }
90 
91 
93 {
94  if ( _player )
95  return _player->playing();
96  else
97  return false;
98 }
99 
100 
102 {
103  if ( _recorder )
104  delete _recorder;
105 }
106 
107 
109 {
110  if ( _player )
111  delete _player;
112 }
YMacro::setPlayer
static void setPlayer(YMacroPlayer *player)
Set a macro player.
Definition: YMacro.cc:46
YMacroRecorder::recording
virtual bool recording() const =0
Return 'true' if a macro is currently being recorded.
YMacroPlayer
Abstract base class for macro player.
Definition: YMacroPlayer.h:36
YMacroPlayer::play
virtual void play(const std::string &macroFile)=0
Play a macro from the specified macro file.
YMacro::endRecording
static void endRecording()
End macro recording.
Definition: YMacro.cc:62
YMacroRecorder::endRecording
virtual void endRecording()=0
End recording and close the current macro file (if there is any).
YMacroPlayer::playNextBlock
virtual void playNextBlock()=0
Play the next block from the current macro, if there is one playing.
YMacro::setRecorder
static void setRecorder(YMacroRecorder *recorder)
Set a macro recorder.
Definition: YMacro.cc:37
YMacro::playNextBlock
static void playNextBlock()
Play the next block from the current macro, if there is one playing.
Definition: YMacro.cc:85
YMacro::play
static void play(const std::string &macroFile)
Play a macro from the specified macro file.
Definition: YMacro.cc:78
YMacroRecorder::record
virtual void record(const std::string &macroFileName)=0
Start recording a macro to the specified file.
YMacro::deleteRecorder
static void deleteRecorder()
Delete the current macro recorder if there is one.
Definition: YMacro.cc:101
YMacro::playing
static bool playing()
Return 'true' if a macro is currently being played.
Definition: YMacro.cc:92
YMacro::record
static void record(const std::string &macroFile)
Record a macro to the specified macro file.
Definition: YMacro.cc:55
YMacro::player
static YMacroPlayer * player()
Return the current macro player or 0 if there is none.
Definition: YMacro.h:106
YMacro::recording
static bool recording()
Return 'true' if a macro is currently being recorded.
Definition: YMacro.cc:69
YMacroPlayer::playing
virtual bool playing() const =0
Return 'true' if a macro is currently being played.
YMacroRecorder
Abstract base class for macro recorders.
Definition: YMacroRecorder.h:39
YMacro::deletePlayer
static void deletePlayer()
Delete the current macro player if there is one.
Definition: YMacro.cc:108
YMacro::recorder
static YMacroRecorder * recorder()
Return the current macro recorder or 0 if there is none.
Definition: YMacro.h:101