Mantid
Loading...
Searching...
No Matches
ScriptRepository.h
Go to the documentation of this file.
1// Mantid Repository : https://github.com/mantidproject/mantid
2//
3// Copyright © 2007 ISIS Rutherford Appleton Laboratory UKRI,
4// NScD Oak Ridge National Laboratory, European Spallation Source,
5// Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS
6// SPDX-License-Identifier: GPL-3.0+
7#pragma once
8
9#include <string>
10#include <vector>
11
12#include "MantidAPI/DllConfig.h"
14
15namespace Mantid {
16namespace API {
17
19struct ScriptInfo {
21 std::string author;
23 Types::Core::DateAndTime pub_date;
28};
29
56
94class MANTID_API_DLL ScriptRepoException : public std::exception {
95
96public:
98 ScriptRepoException(const std::string &info = std::string("Unknown Exception"))
99 : m_systemError(""), m_userInfo(info), m_filepath("") {};
100
101 ScriptRepoException(const std::string &info, const std::string &system, const std::string &file = std::string(),
102 int line = -1);
103
105 const char *what() const noexcept override;
106
109 const std::string &systemError() const { return m_systemError; };
111 const std::string &filePath() const { return m_filepath; };
112
113private:
115 std::string m_systemError;
117 std::string m_userInfo;
119 std::string m_filepath;
120};
121
122//----------------------------------------------------------------------
267class MANTID_API_DLL ScriptRepository {
268public:
270 virtual ~ScriptRepository() = default;
290 virtual ScriptInfo info(const std::string &path) = 0;
291
298 virtual const std::string &description(const std::string &path) = 0;
299
301 ScriptInfo fileInfo(const std::string &path) { return info(path); }
302
342 virtual std::vector<std::string> listFiles() = 0;
343
362 virtual void download(const std::string &file_path) = 0;
363
372 virtual SCRIPTSTATUS fileStatus(const std::string &file_path) = 0;
373
378 virtual bool isValid() = 0;
379
393 virtual void install(const std::string &local_path) = 0;
394
405 virtual void connect(const std::string &webserverurl = "") = 0;
406
427 virtual std::vector<std::string> check4Update() = 0;
428
447 virtual void setIgnorePatterns(const std::string &patterns) = 0;
448
451 virtual std::string ignorePatterns() = 0;
452
470 virtual int setAutoUpdate(const std::string &path, bool option = true) = 0;
471};
472
474using ScriptRepository_sptr = std::shared_ptr<ScriptRepository>;
475} // namespace API
476} // namespace Mantid
The ScriptRepository class is intended to be used mainly by users, who will want to share and downloa...
std::string m_systemError
Technical description of the error, returned by systemError().
const std::string & filePath() const
Returns the file and position where the error was caused.
std::string m_filepath
Path to the file where the error originated, returned by filePath().
std::string m_userInfo
User-facing message, returned by what().
ScriptRepoException(const std::string &info=std::string("Unknown Exception"))
default constructor
virtual void setIgnorePatterns(const std::string &patterns)=0
Define the file patterns that will not be listed by listFiles.
virtual bool isValid()=0
Check whether the local repository exists.
virtual int setAutoUpdate(const std::string &path, bool option=true)=0
Define the AutoUpdate option, which determines whether a file is updated as soon as new versions are ...
virtual void install(const std::string &local_path)=0
Install, at the given local_path, the resources that allow the ScriptRepository to operate locally.
virtual const std::string & description(const std::string &path)=0
Provide the description of the file at the given path.
virtual std::string ignorePatterns()=0
Return the ignore patterns that were defined through ScriptRepository::setIgnorePatterns.
virtual SCRIPTSTATUS fileStatus(const std::string &file_path)=0
Return the status of the file, according to the status defined in Mantid::API::SCRIPTSTATUS.
virtual ScriptInfo info(const std::string &path)=0
Return information about the script through the Mantid::API::ScriptInfo struct.
virtual std::vector< std::string > listFiles()=0
Return the list of files inside the repository.
virtual void download(const std::string &file_path)=0
Create a copy of the remote file/folder inside the local repository.
virtual void connect(const std::string &webserverurl="")=0
Allow the ScriptRepository to double-check the connection with the web server.
virtual std::vector< std::string > check4Update()=0
Connect to the remote repository and check for updates.
ScriptInfo fileInfo(const std::string &path)
virtual ~ScriptRepository()=default
Virtual destructor (always needed for abstract classes)
std::shared_ptr< ScriptRepository > ScriptRepository_sptr
shared pointer to the ScriptRepository base class
SCRIPTSTATUS
Represent the possible states for a given file:
Helper class which provides the Collimation Length for SANS instruments.
STL namespace.
Information about the files inside the repository.
Types::Core::DateAndTime pub_date
Time of the last (remote) update of this file.
bool auto_update
Whether the file is marked for auto-update.
std::string author
Identification of the author of the script.
bool directory
Flag to indicate whether the entry is a directory.