Executor.h

Go to the documentation of this file.
00001 
00008 /*  This is free software; you can redistribute it and/or
00009  *  modify it under the terms of the GNU General Public
00010  *  License as published by the Free Software Foundation; either
00011  *  version 2 of the License, or (at your option) any later version.
00012  *
00013  *  This software is distributed in the hope that it will be useful,
00014  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
00015  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00016  *  Lesser General Public License for more details.
00017  *
00018  *  You should have received a copy of the GNU General Public
00019  *  License along with this software. If not, see
00020  *  <http://www.gnu.org/licenses/>.
00021  *
00022  */
00023 
00024 #ifndef EXECUTOR_H
00025 #define EXECUTOR_H
00026 
00027 #include <hugin_shared.h>
00028 #include <vector>
00029 #include <wx/string.h>
00030 #include <wx/config.h>
00031 #include "base_wx/wxPlatform.h"
00032 
00033 namespace HuginQueue
00034 {
00035 
00037     class WXIMPEX NormalCommand 
00038     {
00039     public:
00040         NormalCommand(wxString prog, wxString args, wxString comment=wxEmptyString) : m_prog(prog), m_args(args), m_comment(comment) {};
00041         virtual ~NormalCommand() {};
00042         virtual bool Execute(bool dryRun);
00043         virtual bool CheckReturnCode() const;
00044         virtual wxString GetCommand() const;
00045         wxString GetComment() const;
00046     protected:
00047         wxString m_prog;
00048         wxString m_args;
00049         wxString m_comment;
00050     };
00051 
00053     class OptionalCommand : public NormalCommand
00054     {
00055     public:
00056         OptionalCommand(wxString prog, wxString args, wxString comment=wxEmptyString) : NormalCommand(prog, args, comment) {};
00057         virtual bool Execute(bool dryRun);
00058         virtual bool CheckReturnCode() const;
00059     };
00060 
00061     typedef std::vector<NormalCommand*> CommandQueue;
00062 
00065     WXIMPEX bool RunCommandsQueue(CommandQueue* queue, size_t threads, bool dryRun);
00067     WXIMPEX void CleanQueue(CommandQueue* queue);
00068 
00070     WXIMPEX wxString GetInternalProgram(const wxString& bindir, const wxString& name);
00072     WXIMPEX wxString GetExternalProgram(wxConfigBase * config, const wxString& bindir, const wxString& name);
00073 
00075     WXIMPEX wxString wxStringFromCDouble(double val, int precision=-1);
00076     
00078     template <class str>
00079     str wxEscapeFilename(const str & arg)
00080     {
00081 #ifdef __WXMSW__
00082         // on Windows we return the string enclosed in quotes "
00083         // the quote itself is not allowed in filenames, so no further handling is required
00084         return str(wxT("\"")) + arg + str(wxT("\""));
00085 #else
00086         // we use UNIX style escaping, escape all special chars with backslash
00087         return hugin_utils::wxQuoteStringInternal(arg, str(wxT("\\")), str(wxT("\\ ~$\"|'`{}[]()")));
00088 #endif
00089     };
00090     
00091 #ifdef __WXMSW__
00092 
00093     WXIMPEX wxString MSWGetProgname(const wxString& bindir, const wxString& name);
00094 #endif
00095 
00097     WXIMPEX const wxString GetSettingString(wxConfigBase* setting, const wxString& name, const wxString defaultValue = wxEmptyString);
00098 
00099 }; //namespace
00100 
00101 #endif

Generated on 20 Jan 2018 for Hugintrunk by  doxygen 1.4.7