libyui  3.3.1
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 
31 YMacroRecorder * YMacro::_recorder = 0;
32 YMacroPlayer * YMacro::_player = 0;
33 
35 {
36  if ( _recorder )
37  delete _recorder;
38 
39  _recorder = recorder;
40 }
41 
42 
44 {
45  if ( _player )
46  delete _player;
47 
48  _player = player;
49 }
50 
51 
52 void YMacro::record( const std::string & macroFile )
53 {
54  if ( _recorder )
55  _recorder->record( macroFile );
56 }
57 
58 
60 {
61  if ( _recorder )
62  _recorder->endRecording();
63 }
64 
65 
67 {
68  if ( _recorder )
69  return _recorder->recording();
70  else
71  return false;
72 }
73 
74 
75 void YMacro::play( const std::string & macroFile )
76 {
77  if ( _player )
78  _player->play( macroFile );
79 }
80 
81 
83 {
84  if ( _player && _player->playing() )
85  _player->playNextBlock();
86 }
87 
88 
90 {
91  if ( _player )
92  return _player->playing();
93  else
94  return false;
95 }
96 
97 
99 {
100  if ( _recorder )
101  delete _recorder;
102 }
103 
104 
106 {
107  if ( _player )
108  delete _player;
109 }
static void setPlayer(YMacroPlayer *player)
Set a macro player.
Definition: YMacro.cc:43
Abstract base class for macro recorders.
virtual void playNextBlock()=0
Play the next block from the current macro, if there is one playing.
virtual void record(const std::string &macroFileName)=0
Start recording a macro to the specified file.
Abstract base class for macro player.
Definition: YMacroPlayer.h:35
virtual void play(const std::string &macroFile)=0
Play a macro from the specified macro file.
static void deletePlayer()
Delete the current macro player if there is one.
Definition: YMacro.cc:105
static YMacroRecorder * recorder()
Return the current macro recorder or 0 if there is none.
Definition: YMacro.h:101
virtual void endRecording()=0
End recording and close the current macro file (if there is any).
static YMacroPlayer * player()
Return the current macro player or 0 if there is none.
Definition: YMacro.h:106
static void endRecording()
End macro recording.
Definition: YMacro.cc:59
static bool recording()
Return &#39;true&#39; if a macro is currently being recorded.
Definition: YMacro.cc:66
static void setRecorder(YMacroRecorder *recorder)
Set a macro recorder.
Definition: YMacro.cc:34
virtual bool recording() const =0
Return &#39;true&#39; if a macro is currently being recorded.
static void play(const std::string &macroFile)
Play a macro from the specified macro file.
Definition: YMacro.cc:75
static void playNextBlock()
Play the next block from the current macro, if there is one playing.
Definition: YMacro.cc:82
static void record(const std::string &macroFile)
Record a macro to the specified macro file.
Definition: YMacro.cc:52
virtual bool playing() const =0
Return &#39;true&#39; if a macro is currently being played.
static bool playing()
Return &#39;true&#39; if a macro is currently being played.
Definition: YMacro.cc:89
static void deleteRecorder()
Delete the current macro recorder if there is one.
Definition: YMacro.cc:98