action.h

Go to the documentation of this file.
00001 /* -*- Mode: c++ -*- */
00002 /*
00003  *  this is part of Spm
00004  *
00005  *  Copyright (c) 2008 Guillaume Chevallereau
00006  *
00007  *  This program is free software. You can redistribute it and/or modify it 
00008  *  under the terms of the GNU General Public License as published by the 
00009  *  Free Software Foundation. Either version 2 of the license or (at your 
00010  *  option) any later version.
00011  *
00012  *  This program is distributed in the hope that it will be usefull but WITHOUT
00013  *  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 
00014  *  FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for 
00015  *  more details.
00016  *
00017  *  You should have received a copy of the GNU General Public License along 
00018  *  with this program; if not, write to the Free Software Foundation, Inc., 
00019  *  59 Temple Place - Suite 330, Boston, MA  02111-1307, USA
00020  */
00021 #ifndef ACTION_H
00022 #define ACTION_H
00023 
00024 #include <boost/signals.hpp>
00025 #include <miniXml/ustring.h>
00026 #include <util/utilException.h>
00027 
00028 namespace Spm
00029 {
00030   namespace Core
00031   {
00032     class Action
00033     {
00034     protected:
00035       boost::signal<void (Action *)> begin_;
00036       boost::signal<void (Action *)> end_;
00037       virtual void doRun () = 0;
00038       miniXml::ustring err_;
00039     public:
00040       virtual ~Action()
00041       {
00042       }
00043       void run()
00044       {
00045         try
00046           {
00047             begin_(this);
00048             doRun ();
00049             end_(this);
00050           }
00051         catch (Spm::Exception & e)
00052           {
00053             err_= e.what();
00054           }
00055       }
00056 
00057       boost::signal<void (Action *)> & signalBegin ()
00058       {
00059         return begin_;
00060       }
00061       
00062       boost::signal<void (Action *)> & signalEnd ()
00063       {
00064         return end_;
00065       }
00066 
00067       const miniXml::ustring error()
00068       {
00069         return err_;
00070       }
00071     };
00072   };
00073 };
00074 
00075 #endif

Generated on Sat Mar 21 17:00:14 2009 for libSpm by  doxygen 1.5.2