OpenMS
Loading...
Searching...
No Matches
TempFiles.h
Go to the documentation of this file.
1// Copyright (c) 2002-present, OpenMS Inc. -- EKU Tuebingen, ETH Zurich, and FU Berlin
2// SPDX-License-Identifier: BSD-3-Clause
3//
4// --------------------------------------------------------------------------
5// $Maintainer: Chris Bielow $
6// $Authors: Andreas Bertsch, Chris Bielow, Marc Sturm $
7// --------------------------------------------------------------------------
8
9#pragma once
10
11#include <OpenMS/config.h>
12
13#include <mutex>
14#include <string>
15#include <vector>
16
17namespace OpenMS
18{
28 class OPENMS_DLLAPI TempDir
29 {
30 public:
33 TempDir(bool keep_dir = false);
34
40 TempDir(const std::string& base_dir, bool keep_dir = false);
41
44
46 TempDir(const TempDir&) = delete;
47 TempDir& operator=(const TempDir&) = delete;
48 TempDir(TempDir&&) = delete;
50
52 const std::string& getPath() const;
53
54 private:
55 std::string temp_dir_;
57 };
58
67 class OPENMS_DLLAPI TempFiles
68 {
69 public:
86 static std::string getTemporaryFile(const std::string& alternative_file = "");
87
88 private:
91 {
92 public:
93 Registry_(const Registry_&) = delete; // copy is forbidden
94 Registry_& operator=(const Registry_&) = delete;
97 std::string newFile();
98
100 private:
101 std::vector<std::string> filenames_;
102 std::mutex mtx_;
103 };
104
107 };
108}
A uniquely named temporary directory, removed when the object is destroyed.
Definition TempFiles.h:29
TempDir(const std::string &base_dir, bool keep_dir=false)
~TempDir()
Destroy temporary folder (can be prohibited in Constructor)
const std::string & getPath() const
Return path to temporary folder.
TempDir(bool keep_dir=false)
TempDir(const TempDir &)=delete
delete all means to copy or move a TempDir
TempDir(TempDir &&)=delete
std::string temp_dir_
Definition TempFiles.h:55
TempDir & operator=(const TempDir &)=delete
bool keep_dir_
Definition TempFiles.h:56
TempDir & operator=(TempDir &&)=delete
Holds the allocated filenames and deletes the files at program exit.
Definition TempFiles.h:91
std::vector< std::string > filenames_
Definition TempFiles.h:101
std::string newFile()
create a new filename and queue internally for deletion
Registry_(const Registry_ &)=delete
std::mutex mtx_
Definition TempFiles.h:102
Registry_ & operator=(const Registry_ &)=delete
Temporary files that live until the process exits.
Definition TempFiles.h:68
static std::string getTemporaryFile(const std::string &alternative_file="")
Obtain a temporary filename, ensuring automatic deletion upon exit.
static Registry_ registry_
filenames handed out so far, deleted upon program exit
Definition TempFiles.h:106
Main OpenMS namespace.
Definition openswathalgo/include/OpenMS/OPENSWATHALGO/DATAACCESS/ISpectrumAccess.h:19