Ocean
Loading...
Searching...
No Matches
FileResolver.h
Go to the documentation of this file.
1/*
2 * Copyright (c) Meta Platforms, Inc. and affiliates.
3 *
4 * This source code is licensed under the MIT license found in the
5 * LICENSE file in the root directory of this source tree.
6 */
7
8#ifndef META_OCEAN_IO_FILE_RESOLVER_H
9#define META_OCEAN_IO_FILE_RESOLVER_H
10
11#include "ocean/io/IO.h"
12#include "ocean/io/Directory.h"
13#include "ocean/io/File.h"
14#include "ocean/io/Path.h"
15
17
18#include <vector>
19
20namespace Ocean
21{
22
23namespace IO
24{
25
26/**
27 * This class implements a file and url resolver.<br>
28 * This resolver is implemented as singleton.<br>
29 * However, it can be used as local object anyway.<br>
30 * @ingroup io
31 */
32class OCEAN_IO_EXPORT FileResolver : public Singleton<FileResolver>
33{
34 public:
35
36 /**
37 * Creates a new resolver object.
38 * Beware: Do not use this constructor if the global resolver object is requestet.
39 */
41
42 /**
43 * Registers the reference path.
44 * @param reference Reference path to register
45 * @return True, if the reference path is a valid absolute path
46 */
47 bool addReferencePath(const Directory& reference);
48
49 /**
50 * Resolves the absolute paths of a file.
51 * @param file File to resolve
52 * @param checkExistence False, to return file paths even if they do not exist
53 * @return Resolved absolute file paths
54 */
55 Files resolve(const File& file, const bool checkExistence = false) const;
56
57 /**
58 * Resolves absolute paths of several files.
59 * @param files Files to resolve
60 * @param checkExistence False, to return file paths even if they do not exist
61 * @return Resolved absolute file paths
62 */
63 Files resolve(const Files& files, const bool checkExistence = false) const;
64
65 /**
66 * Resolves the absolute paths of a file by an additional reference path.
67 * @param file File to resolve
68 * @param reference Additional reference path
69 * @param checkExistence False, to return file paths even if they do not existh
70 * @return Resolved absolute file paths
71 */
72 Files resolve(const File& file, const Path& reference, const bool checkExistence = false) const;
73
74 /**
75 * Resolves the absolute paths of several file by an additional reference path.
76 * @param files Files to resolve
77 * @param reference Additional reference path
78 * @param checkExistence False, to return file paths even if they do not exist
79 * @return Resolved absolute file paths
80 */
81 Files resolve(const Files& files, const Path& reference, const bool checkExistence = false) const;
82
83 private:
84
85 /// Registered reference paths.
87};
88
89}
90
91}
92
93#endif // META_OCEAN_IO_FILE_RESOLVER_H
This class holds a directory.
Definition Directory.h:36
This class holds a file.
Definition File.h:36
This class implements a file and url resolver.
Definition FileResolver.h:33
Files resolve(const File &file, const Path &reference, const bool checkExistence=false) const
Resolves the absolute paths of a file by an additional reference path.
Files resolve(const Files &files, const Path &reference, const bool checkExistence=false) const
Resolves the absolute paths of several file by an additional reference path.
Directories referencePaths
Registered reference paths.
Definition FileResolver.h:86
FileResolver()
Creates a new resolver object.
bool addReferencePath(const Directory &reference)
Registers the reference path.
Files resolve(const File &file, const bool checkExistence=false) const
Resolves the absolute paths of a file.
Files resolve(const Files &files, const bool checkExistence=false) const
Resolves absolute paths of several files.
This class holds a path.
Definition Path.h:27
This template class is the base class for all singleton objects.
Definition Singleton.h:71
std::vector< File > Files
Definition of a vector holding files.
Definition File.h:29
std::vector< Directory > Directories
Definition of a vector holding directories.
Definition Directory.h:28
The namespace covering the entire Ocean framework.
Definition Accessor.h:15