Skip to content
Snippets Groups Projects
CodeExecution.h 1.1 KiB
Newer Older
// Mantid Repository : https://github.com/mantidproject/mantid
//
// Copyright © 2020 ISIS Rutherford Appleton Laboratory UKRI,
//     NScD Oak Ridge National Laboratory, European Spallation Source
//     & Institut Laue - Langevin
// SPDX - License - Identifier: GPL - 3.0 +
#ifndef MANTIDQTWIDGETS_LINETRACKINGEXECUTOR_H
#define MANTIDQTWIDGETS_LINETRACKINGEXECUTOR_H

#include "MantidPythonInterface/core/WrapPython.h"
#include "MantidQtWidgets/Common/DllOption.h"
#include <QString>

class ScriptEditor;

namespace MantidQt::Widgets::Common::Python {

/**
 * The CodeExecution class support execution of arbitrary Python code
 * with the option to install a trace handler to track lines executed and
 * tell an editor to mark them appropriately.
 */
class EXPORT_OPT_MANTIDQT_COMMON CodeExecution {
public:
  CodeExecution(ScriptEditor *editor);
  PyObject *execute(const QString &codeStr, const QString &filename, int flags,
                    PyObject *globals) const;

private:
  ScriptEditor *m_editor{nullptr};
};

} // namespace MantidQt::Widgets::Common::Python

#endif // MANTIDQTWIDGETS_LINETRACKINGEXECUTOR_H