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#include <vector>
15
16namespace Mantid {
17namespace API {
18
20struct ScriptInfo {
22 std::string author;
24 Types::Core::DateAndTime pub_date;
29};
30
52 REMOTE_ONLY = (1u << 0),
53 LOCAL_ONLY = (1u << 1),
54 REMOTE_CHANGED = (1u << 2),
55 LOCAL_CHANGED = (1u << 3),
57};
58
97class MANTID_API_DLL ScriptRepoException : public std::exception {
98
99public:
101 ScriptRepoException(const std::string &info = std::string("Unknown Exception"))
102 : m_systemError(""), m_userInfo(info), m_filepath(""){};
103
104 ScriptRepoException(const std::string &info, const std::string &system, const std::string &file = std::string(),
105 int line = -1);
106
108 const char *what() const noexcept override;
109
112 const std::string &systemError() const { return m_systemError; };
114 const std::string &filePath() const { return m_filepath; };
115
116private:
118 std::string m_systemError;
119 std::string m_userInfo;
120 std::string m_filepath;
121};
122
123//----------------------------------------------------------------------
291class MANTID_API_DLL ScriptRepository {
292public:
294 virtual ~ScriptRepository() = default;
313 virtual ScriptInfo info(const std::string &path) = 0;
314
321 virtual const std::string &description(const std::string &path) = 0;
322
324 ScriptInfo fileInfo(const std::string &path) { return info(path); }
325
367 virtual std::vector<std::string> listFiles() = 0;
368
389 virtual void download(const std::string &file_path) = 0;
390
399 virtual SCRIPTSTATUS fileStatus(const std::string &file_path) = 0;
400
405 virtual bool isValid() = 0;
406
423 virtual void install(const std::string &local_path) = 0;
424
436 virtual void connect(const std::string &webserverurl = "") = 0;
437
462 virtual std::vector<std::string> check4Update() = 0;
463
503 virtual void upload(const std::string &file_path, const std::string &comment, const std::string &author,
504 const std::string &email) = 0;
505
538 virtual void remove(const std::string &file_path, const std::string &comment, const std::string &author,
539 const std::string &email) = 0;
540
560 virtual void setIgnorePatterns(const std::string &patterns) = 0;
561
564 virtual std::string ignorePatterns() = 0;
565
584 virtual int setAutoUpdate(const std::string &path, bool option = true) = 0;
585};
586
588using ScriptRepository_sptr = std::shared_ptr<ScriptRepository>;
589} // namespace API
590} // namespace Mantid
The ScriptRepository class is intended to be used mainly by the users, who will be willing to share a...
std::string m_systemError
The message returned by what()
const std::string & filePath() const
Returns the file and position where the error was caused.
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 in listFiles.
virtual bool isValid()=0
Check if the local repository exists.
virtual int setAutoUpdate(const std::string &path, bool option=true)=0
Define the AutoUpdate option, which define if a file will be updated as soon as new versions are avai...
virtual void remove(const std::string &file_path, const std::string &comment, const std::string &author, const std::string &email)=0
Delete the file from the remote repository (it does not touch the local copy).
virtual void install(const std::string &local_path)=0
Install the necessary resources at the local_path given that allows the ScriptRepository to operate l...
virtual const std::string & description(const std::string &path)=0
Provide the description of the file given the path.
virtual std::string ignorePatterns()=0
Return the ignore patters that was defined through ScriptRepository::setIgnorePatterns.
virtual void upload(const std::string &file_path, const std::string &comment, const std::string &author, const std::string &email)=0
Upload the local file/folder to be available at the remote repository.
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 the 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
Connects to the remote repository checking 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 function 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 update of this file (remotelly)
bool auto_update
Marked for auto update.
std::string author
Identification of the author of the script.
bool directory
Directory Flag to indicate if the entry is a directory.