Skip to content

Commit 9b5d73c

Browse files
committed
return references, not raw pointers for chaining
1 parent 3e0ca36 commit 9b5d73c

3 files changed

Lines changed: 15 additions & 15 deletions

File tree

include/dtlmod/Stream.hpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -103,17 +103,17 @@ class Stream : public std::enable_shared_from_this<Stream> {
103103
/// @brief Stream configuration function: set the Engine type to create.
104104
/// @param engine_type The type of Engine to create when opening the Stream.
105105
/// @return The calling Stream (enable method chaining).
106-
Stream* set_engine_type(const Engine::Type& engine_type);
106+
Stream& set_engine_type(const Engine::Type& engine_type);
107107
/// @brief Stream configuration function: set the Transport Method to use.
108108
/// @param transport_method the Transport methode to use when opening the Stream.
109109
/// @return The calling Stream (enable method chaining).
110-
Stream* set_transport_method(const Transport::Method& transport_method);
110+
Stream& set_transport_method(const Transport::Method& transport_method);
111111
/// @brief Stream configuration function: specify that metadata must be exported
112112
/// @return The calling Stream (enable method chaining).
113-
Stream* set_metadata_export();
113+
Stream& set_metadata_export();
114114
/// @brief Stream configuration function: specify that metadata must not be exported
115115
/// @return The calling Stream (enable method chaining).
116-
Stream* unset_metadata_export();
116+
Stream& unset_metadata_export();
117117

118118
/******* Engine Factory *******/
119119

src/DTL.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ DTL::DTL(const std::string& filename)
5656
if (streams_.find(name) == streams_.end())
5757
streams_.try_emplace(name, std::make_shared<Stream>(name, this));
5858
// And set its engine type and transport method
59-
streams_[name]->set_engine_type(type)->set_transport_method(transport_method);
59+
streams_[name]->set_engine_type(type).set_transport_method(transport_method);
6060

6161
// Check if metadata must be exported for this stream
6262
if (stream.contains("export_metadata")) {

src/Stream.cpp

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -25,10 +25,10 @@ const char* Stream::get_engine_type_str() const
2525
return it == EnumStrings.end() ? "Out of range" : it->second;
2626
}
2727

28-
Stream* Stream::set_engine_type(const Engine::Type& engine_type)
28+
Stream& Stream::set_engine_type(const Engine::Type& engine_type)
2929
{
3030
if (engine_type_ == engine_type) // No modification, just return
31-
return this;
31+
return *this;
3232

3333
// Check if this engine type is known
3434
if (engine_type != Engine::Type::File && engine_type != Engine::Type::Staging)
@@ -53,7 +53,7 @@ Stream* Stream::set_engine_type(const Engine::Type& engine_type)
5353
// set the engine type
5454
engine_type_ = engine_type;
5555

56-
return this;
56+
return *this;
5757
}
5858

5959
const char* Stream::get_transport_method_str() const
@@ -68,10 +68,10 @@ const char* Stream::get_transport_method_str() const
6868
return it == EnumStrings.end() ? "Out of range" : it->second;
6969
}
7070

71-
Stream* Stream::set_transport_method(const Transport::Method& transport_method)
71+
Stream& Stream::set_transport_method(const Transport::Method& transport_method)
7272
{
7373
if (transport_method_ == transport_method) // No modification, just return
74-
return this;
74+
return *this;
7575

7676
// Check if this transport method is known
7777
if (transport_method != Transport::Method::File && transport_method != Transport::Method::Mailbox &&
@@ -97,18 +97,18 @@ Stream* Stream::set_transport_method(const Transport::Method& transport_method)
9797
// Set the transport method
9898
transport_method_ = transport_method;
9999

100-
return this;
100+
return *this;
101101
}
102102

103-
Stream* Stream::set_metadata_export()
103+
Stream& Stream::set_metadata_export()
104104
{
105105
metadata_export_ = true;
106-
return this;
106+
return *this;
107107
}
108-
Stream* Stream::unset_metadata_export()
108+
Stream& Stream::unset_metadata_export()
109109
{
110110
metadata_export_ = false;
111-
return this;
111+
return *this;
112112
}
113113

114114
/****** Engine Factory ******/

0 commit comments

Comments
 (0)