Skip to content

Commit 915863f

Browse files
committed
Update the Context class
1 parent 138b7f1 commit 915863f

2 files changed

Lines changed: 12 additions & 0 deletions

File tree

include/MGIS/Context.hxx

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -124,6 +124,9 @@ namespace mgis {
124124
* free function.
125125
*/
126126
void setLogStream(std::shared_ptr<std::ostream>) noexcept;
127+
//! \return a pointer to a log stream. This pointer may be null.
128+
[[nodiscard]] std::shared_ptr<std::ostream> getLogStreamPointer()
129+
const noexcept;
127130
//! \brief reset the default log stream
128131
void resetLogStream() noexcept;
129132
/*!

src/Context.cxx

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
12
/*!
23
* \file src/Context.cxx
34
* \brief This file implements the `Context` class
@@ -37,6 +38,14 @@ namespace mgis {
3738
this->log_stream = s;
3839
} // end of setLogStream
3940

41+
std::shared_ptr<std::ostream> Context::getLogStreamPointer() const noexcept {
42+
if (std::holds_alternative<std::shared_ptr<std::ostream>>(
43+
this->log_stream)) {
44+
return std::get<std::shared_ptr<std::ostream>>(this->log_stream);
45+
}
46+
return {};
47+
} // end of getLogStreamPointer
48+
4049
void Context::resetLogStream() noexcept {
4150
this->log_stream = std::monostate{};
4251
}

0 commit comments

Comments
 (0)