IODA Bundle
TemporaryFiles.h
Go to the documentation of this file.
1
/*
2
* (C) Copyright 1996-2012 ECMWF.
3
*
4
* This software is licensed under the terms of the Apache Licence Version 2.0
5
* which can be obtained at http://www.apache.org/licenses/LICENSE-2.0.
6
* In applying this licence, ECMWF does not waive the privileges and immunities
7
* granted to it by virtue of its status as an intergovernmental organisation nor
8
* does it submit to any jurisdiction.
9
*/
10
11
#ifndef odc_tests_TemporaryODB_H
12
#define odc_tests_TemporaryODB_H
13
14
#include "eckit/filesystem/PathName.h"
15
16
#include "
odc/Writer.h
"
17
18
//----------------------------------------------------------------------------------------------------------------------
19
20
/// A class to be used as a fixture, which writes a temporary ODB file using the supplied
21
/// initialisation function, and then ensures that it is correctly cleaned up at the
22
/// end of the test.
23
24
25
class
TemporaryFile
{
26
27
public
:
// methods
28
29
TemporaryFile
() :
30
path_
(
eckit
::PathName::unique(
"_temporary_testing_file"
)) {}
31
32
virtual
~TemporaryFile
() {
33
if
(
path_
.exists()) {
34
path_
.unlink();
35
}
36
}
37
38
const
eckit::PathName&
path
()
const
{
return
path_
; }
39
40
private
:
// members
41
42
eckit::PathName
path_
;
43
};
44
45
46
//----------------------------------------------------------------------------------------------------------------------
47
48
#endif
// odc_tests_TemporaryODB_H
Writer.h
TemporaryFile
Definition:
TemporaryFiles.h:25
TemporaryFile::TemporaryFile
TemporaryFile()
Definition:
TemporaryFiles.h:29
TemporaryFile::path_
eckit::PathName path_
Definition:
TemporaryFiles.h:42
TemporaryFile::~TemporaryFile
virtual ~TemporaryFile()
Definition:
TemporaryFiles.h:32
TemporaryFile::path
const eckit::PathName & path() const
Definition:
TemporaryFiles.h:38
eckit
Definition:
DistributionUtils.h:15
odc
tests
TemporaryFiles.h
Generated on Fri Aug 20 2021 11:49:11 for IODA Bundle by
1.9.1