// action.hpp -- the base class for actions // // Written by Frederic Bouvier, started May 2002. // // Copyright (C) 2002 Frederic Bouvier - fredb@users.sourceforge.net // // This program is free software; you can redistribute it and/or // modify it under the terms of the GNU General Public License as // published by the Free Software Foundation; either version 2 of the // License, or (at your option) any later version. // // This program is distributed in the hope that it will be useful, but // WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU // General Public License for more details. // // You should have received a copy of the GNU General Public License // along with this program; if not, write to the Free Software // Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. // // $Id: action.hpp,v 1.8 2002/07/14 23:05:45 fredb Exp $ #ifndef _action_hpp_ #define _action_hpp_ #include class SGPropertyNode; class FGSD_MainWindow; class FGSD_ActionID { public: FGSD_ActionID(); bool operator==( const FGSD_ActionID &right ) const; private: static long _currentId; long _id; }; class FGSD_Action { public: FGSD_Action() : _isUndoable( true ) {} virtual ~FGSD_Action() {} virtual bool undo() = 0; virtual bool redo( bool __step = false ) = 0; virtual std::string name() const = 0; virtual std::string description() const = 0; virtual bool combine( FGSD_Action *__action ); virtual FGSD_ActionID type() const = 0; virtual void *convertTo( FGSD_ActionID __id ) = 0; virtual FGSD_Action *clone() const = 0; virtual bool getPosition( bool undo, double &lon, double &lat ) const; virtual bool savable() const; virtual bool save( const char *__project, SGPropertyNode *__node ) = 0; virtual bool load( const char *__project, SGPropertyNode *__node ) = 0; virtual size_t weight( SGPropertyNode *__node ); virtual double timeoutForCombine() const; bool isUndoable() const; protected: void step( size_t n ) const; bool _isUndoable; static FGSD_MainWindow *_mainWindow; static void (*_step)( size_t, void * ); friend class FGSD_MainWindow; friend class FGSD_ActionManager; }; inline bool FGSD_Action::isUndoable() const { return _isUndoable; } #endif