forked from eclipse-iceoryx/iceoryx
-
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.
iox-eclipse-iceoryx#252 added publisher c binding
Signed-off-by: Christian Eltzschig <christian.eltzschig2@de.bosch.com>
- Loading branch information
Showing
6 changed files
with
136 additions
and
10 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
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,33 @@ | ||
// Copyright (c) 2020 by Robert Bosch GmbH. All rights reserved. | ||
// | ||
// Licensed under the Apache License, Version 2.0 (the "License"); | ||
// you may not use this file except in compliance with the License. | ||
// You may obtain a copy of the License at | ||
// | ||
// http://www.apache.org/licenses/LICENSE-2.0 | ||
// | ||
// Unless required by applicable law or agreed to in writing, software | ||
// distributed under the License is distributed on an "AS IS" BASIS, | ||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
// See the License for the specific language governing permissions and | ||
// limitations under the License. | ||
|
||
#ifndef IOX_BINDING_C_PUBLISHER_H_ | ||
#define IOX_BINDING_C_PUBLISHER_H_ | ||
|
||
#include "iceoryx_binding_c/internal/c2cpp_bridge.h" | ||
#include "iceoryx_binding_c/types.h" | ||
|
||
CLASS PublisherPortData* Publisher_new(); | ||
void Publisher_delete(CLASS PublisherPortData* const self); | ||
iox_popo_AllocationError | ||
Publisher_allocateChunk(CLASS PublisherPortData* const self, void** const chunk, const uint32_t payloadSize); | ||
void Publisher_freeChunk(CLASS PublisherPortData* const self, void* const chunk); | ||
void Publisher_sendChunk(CLASS PublisherPortData* const self, void* const chunk); | ||
const void* Publisher_getLastChunk(CLASS PublisherPortData* const self); | ||
void Publisher_offer(CLASS PublisherPortData* const self); | ||
void Publisher_stopOffer(CLASS PublisherPortData* const self); | ||
bool Publisher_isOffered(CLASS PublisherPortData* const self); | ||
bool Publisher_hasSubscribers(CLASS PublisherPortData* const self); | ||
|
||
#endif |
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
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
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,86 @@ | ||
// Copyright (c) 2020 by Robert Bosch GmbH. All rights reserved. | ||
// | ||
// Licensed under the Apache License, Version 2.0 (the "License"); | ||
// you may not use this file except in compliance with the License. | ||
// You may obtain a copy of the License at | ||
// | ||
// http://www.apache.org/licenses/LICENSE-2.0 | ||
// | ||
// Unless required by applicable law or agreed to in writing, software | ||
// distributed under the License is distributed on an "AS IS" BASIS, | ||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
// See the License for the specific language governing permissions and | ||
// limitations under the License. | ||
|
||
#include "iceoryx_posh/internal/popo/ports/publisher_port_user.hpp" | ||
|
||
using namespace iox; | ||
using namespace iox::cxx; | ||
using namespace iox::popo; | ||
using namespace iox::capro; | ||
using namespace iox::mepoo; | ||
|
||
extern "C" { | ||
#include "iceoryx_binding_c/publisher.h" | ||
} | ||
|
||
PublisherPortData* Publisher_new() | ||
{ | ||
return new PublisherPortData(ServiceDescription{1, 2, 3}, "JoinTheChurchOfHypnotoad!", nullptr, 0u); | ||
} | ||
|
||
void Publisher_delete(PublisherPortData* const self) | ||
{ | ||
delete self; | ||
} | ||
|
||
iox_popo_AllocationError | ||
Publisher_allocateChunk(PublisherPortData* const self, void** const chunk, const uint32_t payloadSize) | ||
{ | ||
auto result = | ||
PublisherPortUser(self).allocateChunk(payloadSize).and_then([&](ChunkHeader* h) { *chunk = h->payload(); }); | ||
if (result.has_error()) | ||
{ | ||
return static_cast<iox_popo_AllocationError>(static_cast<int>(result.get_error())); | ||
} | ||
|
||
return AllocationError_SUCCESS; | ||
} | ||
|
||
void Publisher_freeChunk(PublisherPortData* const self, void* const chunk) | ||
{ | ||
PublisherPortUser(self).freeChunk(convertPayloadPointerToChunkHeader(chunk)); | ||
} | ||
|
||
void Publisher_sendChunk(PublisherPortData* const self, void* const chunk) | ||
{ | ||
PublisherPortUser(self).sendChunk(convertPayloadPointerToChunkHeader(chunk)); | ||
} | ||
|
||
const void* Publisher_getLastChunk(PublisherPortData* const self) | ||
{ | ||
const void* returnValue = nullptr; | ||
PublisherPortUser(self).getLastChunk().and_then([&](const ChunkHeader* h) { returnValue = h->payload(); }); | ||
return returnValue; | ||
} | ||
|
||
void Publisher_offer(PublisherPortData* const self) | ||
{ | ||
PublisherPortUser(self).offer(); | ||
} | ||
|
||
void Publisher_stopOffer(PublisherPortData* const self) | ||
{ | ||
PublisherPortUser(self).stopOffer(); | ||
} | ||
|
||
bool Publisher_isOffered(PublisherPortData* const self) | ||
{ | ||
return PublisherPortUser(self).isOffered(); | ||
} | ||
|
||
bool Publisher_hasSubscribers(PublisherPortData* const self) | ||
{ | ||
return PublisherPortUser(self).hasSubscribers(); | ||
} | ||
|
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