forked from eProsima/Fast-DDS
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added readme on new features on doc/
- Loading branch information
1 parent
21992ec
commit bddea1c
Showing
1 changed file
with
67 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
/********/ | ||
Internal ePRosima doc - New features in this branch | ||
/********/ | ||
|
||
--- Query the number of Publishers and Subscribers listening to a topic | ||
|
||
Participant has 2 new API functions, get_no_publishers and get_no_subscribers | ||
These functions a target_topic as argument and return the number of pubs/subs | ||
that exist on a participant that are assigned to the specified topic | ||
|
||
--- Possibility to attach a secondary ReaderListener to SimpleEDP RTPSReaders | ||
|
||
A new Participant API function, getEDPReaders, allows the user to get pointer | ||
to the two stateful readers the EDP spawns. From here it is possible to access | ||
the ReaderListener, which has been modified. | ||
|
||
The ReaderListeners used in the EDP Readers inherit from a class that allows a | ||
slave ReaderListener to be attached. This way a user can attach his own | ||
ReaderListener so that its callback is executed whenever the default EDP | ||
callback is invoked. | ||
|
||
The result of this is that there is a path from user land to the EDP | ||
RTPSReaders, then to the modified ReaderListener and from there we can | ||
attach a user defined ReaderListener with its own callbacks. | ||
|
||
--- Examples: | ||
|
||
---Attach a slave ReaderListener: | ||
- The target slave ReaderListener inherits from ReaderListener | ||
|
||
class gettopicnamesandtypesReaderListener:public ReaderListener | ||
{ | ||
public: | ||
std::mutex mapmutex; | ||
std::map<std::string,std::set<std::string>> topicNtypes; | ||
void onNewCacheChangeAdded(RTPSReader* reader, const CacheChange_t* const change_in){ | ||
CacheChange_t* change = (CacheChange_t*) change_in; | ||
if(change->kind == ALIVE){ | ||
WriterProxyData proxyData; | ||
CDRMessage_t tempMsg; | ||
tempMsg.msg_endian = change->serializedPayload.encapsulation == PL_CDR_BE ? BIGEND:LITTLEEND; | ||
tempMsg.length = change->serializedPayload.length; | ||
memcpy(tempMsg.buffer,change->serializedPayload.data,tempMsg.length); | ||
if(proxyData.readFromCDRMessage(&tempMsg)){ | ||
mapmutex.lock(); | ||
topicNtypes[proxyData.m_topicName].insert(proxyData.m_typeName); | ||
mapmutex.unlock(); | ||
} | ||
} | ||
} | ||
}; | ||
|
||
- Insertion from within application code: | ||
|
||
std::pair<StatefulReader*,StatefulReader*> EDP_Readers = my_participant->getEDPReaders(); | ||
InfectableReaderListener* target = dynamic_cast<InfectableReaderListener*>(EDP_Readers.second->getListener()); | ||
target->attachListener(slave_listener); | ||
result = target->hasReaderAttached(); | ||
ASSERT_EQ(result,true); | ||
slave_target = dynamic_cast<gettopicnamesandtypesReaderListener*>(target->getAttachedListener()); | ||
|
||
|
||
--- Poll the no of Pubs and Subs on topic "TEST_NAME" | ||
|
||
std::string my_topicName("TEST_NAME"); | ||
int no_pubs = my_participant->get_no_publishers(my_topicName.cstr()); | ||
|