S Morita / mbed-mros2

Dependents:   mbed-os-example-mros2 example-mbed-mros2-sub-pose example-mbed-mros2-pub-twist example-mbed-mros2-mturtle-teleop

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers SEDPAgent.h Source File

SEDPAgent.h

00001 /*
00002 The MIT License
00003 Copyright (c) 2019 Lehrstuhl Informatik 11 - RWTH Aachen University
00004 Permission is hereby granted, free of charge, to any person obtaining a copy
00005 of this software and associated documentation files (the "Software"), to deal
00006 in the Software without restriction, including without limitation the rights
00007 to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
00008 copies of the Software, and to permit persons to whom the Software is
00009 furnished to do so, subject to the following conditions:
00010 The above copyright notice and this permission notice shall be included in
00011 all copies or substantial portions of the Software.
00012 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
00013 IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
00014 FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
00015 AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
00016 LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
00017 OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
00018 THE SOFTWARE
00019 
00020 This file is part of embeddedRTPS.
00021 
00022 Author: i11 - Embedded Software, RWTH Aachen University
00023 */
00024 
00025 #ifndef RTPS_SEDPAGENT_H
00026 #define RTPS_SEDPAGENT_H
00027 
00028 #include "rtps/discovery/BuiltInEndpoints.h"
00029 #include "rtps/discovery/TopicData.h"
00030 
00031 namespace rtps {
00032 
00033 class Participant;
00034 class ReaderCacheChange;
00035 class Writer;
00036 class Reader;
00037 
00038 class SEDPAgent {
00039 public:
00040   void init(Participant &part, const BuiltInEndpoints &endpoints);
00041   void addWriter(Writer &writer);
00042   void addReader(Reader &reader);
00043   void registerOnNewPublisherMatchedCallback(void (*callback)(void *arg),
00044                                              void *args);
00045   void registerOnNewSubscriberMatchedCallback(void (*callback)(void *arg),
00046                                               void *args);
00047 
00048 protected: // For testing purposes
00049   void onNewPublisher(const TopicData &writerData);
00050   void onNewSubscriber(const TopicData &writerData);
00051 
00052 private:
00053   Participant *m_part;
00054   sys_mutex_t m_mutex;
00055   uint8_t m_buffer[600]; // TODO check size, currently changed from 300 to 600
00056                          // (FastDDS gives too much options)
00057   BuiltInEndpoints m_endpoints;
00058   void (*mfp_onNewPublisherCallback)(void *arg) = nullptr;
00059   void *m_onNewPublisherArgs = nullptr;
00060   void (*mfp_onNewSubscriberCallback)(void *arg) = nullptr;
00061   void *m_onNewSubscriberArgs = nullptr;
00062 
00063   static void receiveCallbackPublisher(void *callee,
00064                                        const ReaderCacheChange &cacheChange);
00065   static void receiveCallbackSubscriber(void *callee,
00066                                         const ReaderCacheChange &cacheChange);
00067   void onNewPublisher(const ReaderCacheChange &change);
00068   void onNewSubscriber(const ReaderCacheChange &change);
00069 };
00070 } // namespace rtps
00071 
00072 #endif // RTPS_SEDPAGENT_H