Skip to content

Commit

Permalink
Allow implicit conversion factory->resource
Browse files Browse the repository at this point in the history
reduces boilerplate
  • Loading branch information
mkrzewic authored and MohammadAlTurany committed Dec 18, 2018
1 parent 5e24fdb commit 4dc37ef
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 1 deletion.
1 change: 1 addition & 0 deletions fairmq/FairMQTransportFactory.h
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ class FairMQTransportFactory

/// Get a pointer to the associated polymorphic memory resource
fair::mq::ChannelResource* GetMemoryResource() { return &fMemoryResource; }
operator fair::mq::ChannelResource*() { return &fMemoryResource; }

/// @brief Create empty FairMQMessage
/// @return pointer to FairMQMessage
Expand Down
3 changes: 2 additions & 1 deletion test/memory_resources/_memory_resources.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -127,10 +127,11 @@ TEST(MemoryResources, getMessage_test)
v.emplace_back(5);
v.emplace_back(6);
void* vectorBeginPtr = &v[0];
message = getMessage(std::move(v), allocSHM);
message = getMessage(std::move(v), *factorySHM);
EXPECT_TRUE(message != nullptr);
EXPECT_TRUE(message->GetData() != vectorBeginPtr);
}

EXPECT_TRUE(message->GetSize() == 3 * sizeof(testData));
messageArray = static_cast<int*>(message->GetData());
EXPECT_TRUE(messageArray[0] == 4 && messageArray[1] == 5 && messageArray[2] == 6);
Expand Down

0 comments on commit 4dc37ef

Please sign in to comment.