Skip to content

Commit fb7d930

Browse files
committed
add inline documentation to Gather class
1 parent 6eb6c06 commit fb7d930

File tree

2 files changed

+24
-2
lines changed

2 files changed

+24
-2
lines changed

src/core/bindings.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,6 @@ PYBIND11_MODULE(_gather, m) {
4747
.def_readwrite("nx", &Gather::nx)
4848
.def_readwrite("dt", &Gather::dt)
4949
.def_readonly("data", &Gather::data)
50-
.def("__str__", &Gather::display)
50+
.def("__str__", &Gather::str)
5151
.def("from_bin_file", &Gather::from_bin_file);
5252
}

src/core/gather/gather.hpp

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,10 +25,32 @@ class Gather {
2525
data.resize(nt * nx);
2626
}
2727

28-
[[nodiscard]] std::string display() const {
28+
/**
29+
* @brief a helper function used for Python __str__ method.
30+
*/
31+
[[nodiscard]] std::string str() const {
2932
return "Gather id: " + std::to_string(id);
3033
}
3134

35+
/**
36+
* @brief overload the output stream operator for Gather.
37+
*/
38+
friend std::ostream &operator<<(std::ostream &os, const Gather &gather) {
39+
os << "Gather id: " << gather.id << std::endl;
40+
return os;
41+
}
42+
43+
/**
44+
* @brief Read a binary file and create a Gather object.
45+
*
46+
* This function takes a file path (string), the number of time samples (nt),
47+
* and the number of traces (nx) to read from the binary file.
48+
*
49+
* @param path the path to the binary file.
50+
* @param nt the number of time samples per trace.
51+
* @param nx the number of traces per gather.
52+
* @return Gather object populated with data from the file.
53+
*/
3254
static Gather from_bin_file(const std::string &path, int nt, int nx,
3355
double dt = 0.0) {
3456
std::ifstream file(path, std::ios::binary);

0 commit comments

Comments
 (0)