S Morita / mbed-mros2

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

Committer:
smoritaemb
Date:
Thu Dec 30 21:06:29 2021 +0900
Revision:
0:580aba13d1a1
Updated to catch up to mros2 v2.3

Who changed what in which revision?

UserRevisionLine numberNew contents of line
smoritaemb 0:580aba13d1a1 1 /*
smoritaemb 0:580aba13d1a1 2 The MIT License
smoritaemb 0:580aba13d1a1 3 Copyright (c) 2019 Lehrstuhl Informatik 11 - RWTH Aachen University
smoritaemb 0:580aba13d1a1 4 Permission is hereby granted, free of charge, to any person obtaining a copy
smoritaemb 0:580aba13d1a1 5 of this software and associated documentation files (the "Software"), to deal
smoritaemb 0:580aba13d1a1 6 in the Software without restriction, including without limitation the rights
smoritaemb 0:580aba13d1a1 7 to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
smoritaemb 0:580aba13d1a1 8 copies of the Software, and to permit persons to whom the Software is
smoritaemb 0:580aba13d1a1 9 furnished to do so, subject to the following conditions:
smoritaemb 0:580aba13d1a1 10 The above copyright notice and this permission notice shall be included in
smoritaemb 0:580aba13d1a1 11 all copies or substantial portions of the Software.
smoritaemb 0:580aba13d1a1 12 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
smoritaemb 0:580aba13d1a1 13 IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
smoritaemb 0:580aba13d1a1 14 FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
smoritaemb 0:580aba13d1a1 15 AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
smoritaemb 0:580aba13d1a1 16 LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
smoritaemb 0:580aba13d1a1 17 OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
smoritaemb 0:580aba13d1a1 18 THE SOFTWARE
smoritaemb 0:580aba13d1a1 19
smoritaemb 0:580aba13d1a1 20 This file is part of embeddedRTPS.
smoritaemb 0:580aba13d1a1 21
smoritaemb 0:580aba13d1a1 22 Author: i11 - Embedded Software, RWTH Aachen University
smoritaemb 0:580aba13d1a1 23 */
smoritaemb 0:580aba13d1a1 24
smoritaemb 0:580aba13d1a1 25 #include "rtps/entities/StatelessReader.h"
smoritaemb 0:580aba13d1a1 26
smoritaemb 0:580aba13d1a1 27 using rtps::StatelessReader;
smoritaemb 0:580aba13d1a1 28
smoritaemb 0:580aba13d1a1 29 #define SLR_VERBOSE 0
smoritaemb 0:580aba13d1a1 30
smoritaemb 0:580aba13d1a1 31 void StatelessReader::init(const TopicData &attributes) {
smoritaemb 0:580aba13d1a1 32 m_attributes = attributes;
smoritaemb 0:580aba13d1a1 33 m_is_initialized_ = true;
smoritaemb 0:580aba13d1a1 34 }
smoritaemb 0:580aba13d1a1 35
smoritaemb 0:580aba13d1a1 36 void StatelessReader::newChange(const ReaderCacheChange &cacheChange) {
smoritaemb 0:580aba13d1a1 37 if (m_callback != nullptr) {
smoritaemb 0:580aba13d1a1 38 m_callback(m_callee, cacheChange);
smoritaemb 0:580aba13d1a1 39 }
smoritaemb 0:580aba13d1a1 40 }
smoritaemb 0:580aba13d1a1 41
smoritaemb 0:580aba13d1a1 42 void StatelessReader::registerCallback(ddsReaderCallback_fp cb, void *callee) {
smoritaemb 0:580aba13d1a1 43 if (cb != nullptr) {
smoritaemb 0:580aba13d1a1 44 m_callback = cb;
smoritaemb 0:580aba13d1a1 45 m_callee = callee; // It's okay if this is null
smoritaemb 0:580aba13d1a1 46 } else {
smoritaemb 0:580aba13d1a1 47 #if SLR_VERBOSE
smoritaemb 0:580aba13d1a1 48 printf("StatelessReader[%s]: Passed callback is nullptr\n",
smoritaemb 0:580aba13d1a1 49 &m_attributes.topicName[0]);
smoritaemb 0:580aba13d1a1 50 #endif
smoritaemb 0:580aba13d1a1 51 }
smoritaemb 0:580aba13d1a1 52 }
smoritaemb 0:580aba13d1a1 53
smoritaemb 0:580aba13d1a1 54 bool StatelessReader::addNewMatchedWriter(const WriterProxy & /*newProxy*/) {
smoritaemb 0:580aba13d1a1 55 // Nothing to do
smoritaemb 0:580aba13d1a1 56 return true;
smoritaemb 0:580aba13d1a1 57 }
smoritaemb 0:580aba13d1a1 58
smoritaemb 0:580aba13d1a1 59 void StatelessReader::removeWriter(const Guid & /*guid*/) {
smoritaemb 0:580aba13d1a1 60 // Nothing to do
smoritaemb 0:580aba13d1a1 61 }
smoritaemb 0:580aba13d1a1 62
smoritaemb 0:580aba13d1a1 63 bool StatelessReader::onNewHeartbeat(const SubmessageHeartbeat &,
smoritaemb 0:580aba13d1a1 64 const GuidPrefix_t &) {
smoritaemb 0:580aba13d1a1 65 // nothing to do
smoritaemb 0:580aba13d1a1 66 return true;
smoritaemb 0:580aba13d1a1 67 }
smoritaemb 0:580aba13d1a1 68
smoritaemb 0:580aba13d1a1 69 #undef SLR_VERBOSE