Skip to content

Commit

Permalink
add more accessors to the declared streams
Browse files Browse the repository at this point in the history
  • Loading branch information
frs69wq committed Jan 13, 2025
1 parent e923a7d commit eebf700
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 0 deletions.
9 changes: 9 additions & 0 deletions include/dtlmod/DTL.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,15 @@ class DTL {
/// @param name The name of the Stream to add to the DTL.
/// @return A handler on the newly created Stream object.
std::shared_ptr<Stream> add_stream(const std::string& name);

/// @brief Retrieve all streams declared in the Data Transport by its name.
/// @return a map of handlers on Stream objects with their names as keys.
std::unordered_map<std::string, std::shared_ptr<Stream>> get_all_streams() const { return streams_; }

/// @brief Retrieve a data stream from the Data Transport Layer by its name.
/// @param name The name of the Stream to retrieve.
/// @return A handler on the Stream object or nullptr if it doesn't exist.
std::shared_ptr<Stream> get_stream_by_name_or_null(const std::string& name) const;
};

} // namespace dtlmod
Expand Down
8 changes: 8 additions & 0 deletions src/DTL.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -138,4 +138,12 @@ std::shared_ptr<Stream> DTL::add_stream(const std::string& name)
return streams_[name];
}

std::shared_ptr<Stream> DTL::get_stream_by_name_or_null(const std::string& name) const
{
auto it = streams_.find(name);
if (it == streams_.end())
return nullptr;
return it->second;

}
} // namespace dtlmod

0 comments on commit eebf700

Please sign in to comment.