Hugintrunk  0.1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Executor.h
Go to the documentation of this file.
1 
8 /* This is free software; you can redistribute it and/or
9  * modify it under the terms of the GNU General Public
10  * License as published by the Free Software Foundation; either
11  * version 2 of the License, or (at your option) any later version.
12  *
13  * This software is distributed in the hope that it will be useful,
14  * but WITHOUT ANY WARRANTY; without even the implied warranty of
15  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16  * Lesser General Public License for more details.
17  *
18  * You should have received a copy of the GNU General Public
19  * License along with this software. If not, see
20  * <http://www.gnu.org/licenses/>.
21  *
22  */
23 
24 #ifndef EXECUTOR_H
25 #define EXECUTOR_H
26 
27 #include <hugin_shared.h>
28 #include <vector>
29 #include <wx/string.h>
30 #include <wx/config.h>
31 #include "base_wx/wxPlatform.h"
32 
33 namespace HuginQueue
34 {
35 
38  {
39  public:
40  NormalCommand(wxString prog, wxString args, wxString comment=wxEmptyString) : m_prog(prog), m_args(args), m_comment(comment) {};
41  virtual ~NormalCommand() {};
42  virtual bool Execute(bool dryRun);
43  virtual bool CheckReturnCode() const;
44  virtual wxString GetCommand() const;
45  wxString GetComment() const;
46  protected:
47  wxString m_prog;
48  wxString m_args;
49  wxString m_comment;
50  };
51 
54  {
55  public:
56  OptionalCommand(wxString prog, wxString args, wxString comment=wxEmptyString) : NormalCommand(prog, args, comment) {};
57  virtual bool Execute(bool dryRun);
58  virtual bool CheckReturnCode() const;
59  };
60 
61  typedef std::vector<NormalCommand*> CommandQueue;
62 
65  WXIMPEX bool RunCommandsQueue(CommandQueue* queue, size_t threads, bool dryRun);
67  WXIMPEX void CleanQueue(CommandQueue* queue);
68 
70  WXIMPEX wxString GetInternalProgram(const wxString& bindir, const wxString& name);
72  WXIMPEX wxString GetExternalProgram(wxConfigBase * config, const wxString& bindir, const wxString& name);
73 
75  WXIMPEX wxString wxStringFromCDouble(double val, int precision=-1);
76 
78  template <class str>
79  str wxEscapeFilename(const str & arg)
80  {
81 #ifdef __WXMSW__
82  // on Windows we return the string enclosed in quotes "
83  // the quote itself is not allowed in filenames, so no further handling is required
84  return str(wxT("\"")) + arg + str(wxT("\""));
85 #else
86  // we use UNIX style escaping, escape all special chars with backslash
87  return hugin_utils::wxQuoteStringInternal(arg, str(wxT("\\")), str(wxT("\\ ~$\"|'`{}[]()")));
88 #endif
89  };
90 
91 #ifdef __WXMSW__
92 
93  WXIMPEX wxString MSWGetProgname(const wxString& bindir, const wxString& name);
94 #endif
95 
97  WXIMPEX const wxString GetSettingString(wxConfigBase* setting, const wxString& name, const wxString defaultValue = wxEmptyString);
99  WXIMPEX const wxString GetSettingStringTranslated(wxConfigBase* setting, const wxString& name, const wxString defaultValue = wxEmptyString);
100 
102  WXIMPEX const wxString GetConfigTempDir(const wxConfigBase* config);
103 
104 }; //namespace
105 
106 #endif
const wxString GetSettingString(wxConfigBase *setting, const wxString &name, const wxString defaultValue)
read a string from setting and remove all whitespaces
Definition: Executor.cpp:281
normal command for queue, processing is stopped if an error occurred in program
Definition: Executor.h:37
str wxQuoteStringInternal(const str &arg, const str &quotechar, const str &replacements)
Definition: wxPlatform.h:36
const wxString GetConfigTempDir(const wxConfigBase *config)
return the temp dir from the preferences, ensure that it ends with path separator ...
Definition: Executor.cpp:302
optional command for queue, processing of queue is always continued, also if an error occurred ...
Definition: Executor.h:53
wxString GetInternalProgram(const wxString &bindir, const wxString &name)
return path and name of external program, which comes bundled with Hugin
Definition: Executor.cpp:129
OptionalCommand(wxString prog, wxString args, wxString comment=wxEmptyString)
Definition: Executor.h:56
#define WXIMPEX
Definition: hugin_shared.h:40
bool RunCommandsQueue(CommandQueue *queue, size_t threads, bool dryRun)
execute the given, set environment variable OMP_NUM_THREADS to threads (ignored for 0) after running ...
Definition: Executor.cpp:83
NormalCommand(wxString prog, wxString args, wxString comment=wxEmptyString)
Definition: Executor.h:40
void CleanQueue(CommandQueue *queue)
clean the queue, delete all entries, but not the queue itself
Definition: Executor.cpp:118
virtual ~NormalCommand()
Definition: Executor.h:41
const wxString GetSettingStringTranslated(wxConfigBase *setting, const wxString &name, const wxString defaultValue)
read a translated string from settings and remove all whitespaces
Definition: Executor.cpp:288
str wxEscapeFilename(const str &arg)
special escaping routine for CommandQueues
Definition: Executor.h:79
platform/compiler specific stuff.
wxString GetExternalProgram(wxConfigBase *config, const wxString &bindir, const wxString &name)
return path and name of external program, which can be overwritten by the user
Definition: Executor.cpp:148
std::vector< NormalCommand * > CommandQueue
Definition: Executor.h:61
wxString wxStringFromCDouble(double val, int precision)
convert double to wxString, it is always using a &#39;.
Definition: Executor.cpp:238