preCICE
Loading...
Searching...
No Matches
ConnectionInfoPublisher.hpp
Go to the documentation of this file.
1#pragma once
2#include <string>
3#include <string_view>
4#include <utility>
5
6#include "logging/Logger.hpp"
8
9namespace precice::com {
10
11namespace impl {
13
17std::string hashedFilePath(std::string_view acceptorName, std::string_view requesterName, std::string_view meshName, Rank rank);
18
22std::string localDirectory(std::string_view acceptorName, std::string_view requesterName, std::string_view addressDirectory);
23} // namespace impl
24
26public:
28 std::string_view requesterName,
29 std::string_view tag,
30 int rank,
31 std::string_view addressDirectory) noexcept
34 tag(tag),
35 rank(rank),
37 {
38 }
39
41 std::string_view requesterName,
42 std::string_view tag,
43 std::string_view addressDirectory) noexcept
46 tag(tag),
48 {
49 }
50
51protected:
52 std::string const acceptorName;
53 std::string const requesterName;
54 std::string const tag;
55 int const rank = -1;
56 std::string const addressDirectory;
57
59 std::string getLocalDirectory() const;
60
62 std::string getFilename() const;
63
64 mutable logging::Logger _log{"com::ConnectionInfoPublisher"};
65};
66
69public:
71 std::string_view requesterName,
72 std::string_view tag,
73 int rank,
74 std::string_view addressDirectory) noexcept
76 {
77 }
78
80 std::string_view requesterName,
81 std::string_view tag,
82 std::string_view addressDirectory) noexcept
84 {
85 }
86
88 std::string read() const;
89};
90
92
96public:
98 std::string_view requesterName,
99 std::string_view tag,
100 int rank,
101 std::string_view addressDirectory) noexcept
103 {
104 }
105
107 std::string_view requesterName,
108 std::string_view tag,
109 std::string_view addressDirectory) noexcept
111 {
112 }
113
116
118
122 void write(std::string_view info) const;
123};
124
125} // namespace precice::com
std::string getLocalDirectory() const
Returns the local directory which is used to store the hashed part.
ConnectionInfoPublisher(std::string_view acceptorName, std::string_view requesterName, std::string_view tag, std::string_view addressDirectory) noexcept
ConnectionInfoPublisher(std::string_view acceptorName, std::string_view requesterName, std::string_view tag, int rank, std::string_view addressDirectory) noexcept
std::string getFilename() const
Returns the full path to the hashed filename.
ConnectionInfoReader(std::string_view acceptorName, std::string_view requesterName, std::string_view tag, int rank, std::string_view addressDirectory) noexcept
std::string read() const
Reads the info from the connection info file. Will block, if the the file is not present.
ConnectionInfoReader(std::string_view acceptorName, std::string_view requesterName, std::string_view tag, std::string_view addressDirectory) noexcept
ConnectionInfoWriter(std::string_view acceptorName, std::string_view requesterName, std::string_view tag, std::string_view addressDirectory) noexcept
void write(std::string_view info) const
Write the string info, e.g. IP:port to the connection info file.
ConnectionInfoWriter(std::string_view acceptorName, std::string_view requesterName, std::string_view tag, int rank, std::string_view addressDirectory) noexcept
~ConnectionInfoWriter()
Removes the connection info file and the directories ./precice-run/[hash], is empty.
This class provides a lightweight logger.
Definition Logger.hpp:17
std::string hashedFilePath(std::string_view acceptorName, std::string_view requesterName, std::string_view meshName, Rank rank)
Returns the file name for the connection information.
std::string localDirectory(std::string_view acceptorName, std::string_view requesterName, std::string_view addressDirectory)
contains the data communication abstraction layer.
int Rank
Definition Types.hpp:37