NGen
Loading...
Searching...
No Matches
path_tokens.hpp
1/*
2Author: Nels Frazier
3Copyright (C) 2025 Lynker
4------------------------------------------------------------------------
5Licensed under the Apache License, Version 2.0 (the "License");
6you may not use this file except in compliance with the License.
7You may obtain a copy of the License at
8
9 http://www.apache.org/licenses/LICENSE-2.0
10
11Unless required by applicable law or agreed to in writing, software
12distributed under the License is distributed on an "AS IS" BASIS,
13WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14See the License for the specific language governing permissions and
15limitations under the License.
16------------------------------------------------------------------------
17Path-template token resolver.
18
19The BMI serialization protocol is intentionally MPI-agnostic: the
20protocol itself knows nothing about ranks, hosts, or processes, and
21will happily write multiple instances to the same file without
22coordination. When a caller *does* want per-rank (or per-pid, or
23per-host, or per-date) file naming to sidestep coordination, they
24bake the discriminator into the configured path via these tokens and
25let the engine/realization layer resolve them before handing the
26path to the protocol.
27
28Recognized tokens (double-braced, exactly — no whitespace inside):
29 {{rank}} MPI rank (0 for non-MPI or uninitialized), decimal.
30 {{pid}} POSIX process id, decimal.
31 {{host}} Host name (first label, truncated at 63 chars; empty if
32 lookup fails).
33 {{date}} Calendar date at call time formatted YYYYMMDD (local
34 time; not suitable as a cryptographic nonce).
35
36Unknown tokens — anything else matching `{{...}}` — are left intact so
37that a future addition doesn't silently swallow a typo. The caller is
38expected to validate the final string however they see fit.
39
40Keep this header free of MPI includes (guarded behind NGEN_WITH_MPI in
41the .cpp). Callers include the header; link pulls in whichever MPI
42state is available at build time.
43*/
44#pragma once
45
46#include <string>
47
48namespace utilities {
49
57std::string resolve_path_tokens(const std::string& path);
58
59} // namespace utilities
Definition path_tokens.hpp:48
std::string resolve_path_tokens(const std::string &path)
Expand {{rank}}, {{pid}}, {{host}}, {{date}} tokens in path and return the resolved string.
Definition path_tokens.cpp:102