From ecd6422e59e6c0d3798ea20a29438b1c14c153ba Mon Sep 17 00:00:00 2001 From: Christian Eltzschig Date: Mon, 8 Jul 2024 14:48:16 +0200 Subject: [PATCH] [#264] Add first nodebuilder implementation --- .../cxx/publish_subscribe/src/publisher.cpp | 14 +++++----- iceoryx2-ffi/cxx/CMakeLists.txt | 1 + iceoryx2-ffi/cxx/include/iox2/node.hpp | 9 +++++-- iceoryx2-ffi/cxx/src/dummy.cpp | 13 ++++----- iceoryx2-ffi/cxx/src/node.cpp | 27 +++++++++++++++++++ 5 files changed, 49 insertions(+), 15 deletions(-) create mode 100644 iceoryx2-ffi/cxx/src/node.cpp diff --git a/examples/cxx/publish_subscribe/src/publisher.cpp b/examples/cxx/publish_subscribe/src/publisher.cpp index 864df8bb4..75cab72e8 100644 --- a/examples/cxx/publish_subscribe/src/publisher.cpp +++ b/examples/cxx/publish_subscribe/src/publisher.cpp @@ -14,14 +14,14 @@ int main() { using namespace iox2; - auto node = - NodeBuilder() - .name(NodeName::create("hello world").expect("valid node name")) - .template create() - .expect("successful node creation"); + auto node = NodeBuilder(); + // .name(NodeName::create("hello world").expect("valid node name")) + // .template create() + // .expect("successful node creation"); - Node::list( - Config{}, [](auto) { return iox::ok(CallbackProgression::Continue); }); + // Node::list( + // Config{}, [](auto) { return iox::ok(CallbackProgression::Continue); + // }); return 0; } diff --git a/iceoryx2-ffi/cxx/CMakeLists.txt b/iceoryx2-ffi/cxx/CMakeLists.txt index 9ef1cd871..3695d586d 100644 --- a/iceoryx2-ffi/cxx/CMakeLists.txt +++ b/iceoryx2-ffi/cxx/CMakeLists.txt @@ -37,6 +37,7 @@ target_include_directories(includes-only-cxx add_library(iceoryx2-cxx-object-lib OBJECT src/dummy.cpp + src/node.cpp ) set_target_properties(iceoryx2-cxx-object-lib diff --git a/iceoryx2-ffi/cxx/include/iox2/node.hpp b/iceoryx2-ffi/cxx/include/iox2/node.hpp index def34498d..9d99de262 100644 --- a/iceoryx2-ffi/cxx/include/iox2/node.hpp +++ b/iceoryx2-ffi/cxx/include/iox2/node.hpp @@ -45,7 +45,7 @@ class NodeName { const std::string& as_string() const; private: - std::string value; + iox2_node_name_storage_t value; }; class ServiceName { @@ -106,8 +106,13 @@ class NodeBuilder { IOX_BUILDER_PARAMETER(Config, config, Config{}) public: + NodeBuilder(); + template - iox::expected, NodeCreationFailure> create() const; + iox::expected, NodeCreationFailure> create() const&&; + + private: + iox2_node_builder_h m_handle; }; } // namespace iox2 diff --git a/iceoryx2-ffi/cxx/src/dummy.cpp b/iceoryx2-ffi/cxx/src/dummy.cpp index f435d3809..ed263cb2f 100644 --- a/iceoryx2-ffi/cxx/src/dummy.cpp +++ b/iceoryx2-ffi/cxx/src/dummy.cpp @@ -10,16 +10,17 @@ // // SPDX-License-Identifier: Apache-2.0 OR MIT -// NOTE: dummy source file to create static and shared libraries; can be removed once we have real cpp files -// or the libraries need to become an INTERFACE library in cmake +// NOTE: dummy source file to create static and shared libraries; can be removed +// once we have real cpp files or the libraries need to become an INTERFACE +// library in cmake -#include "iox2/node.hpp" +#include +#include #include "iox2/iceoryx2.h" - -#include -#include +#include "iox2/node.hpp" void hypnotoad() { IOX_LOG(INFO, "All glory to the hypnotoad!"); + iox2_node_builder_new(nullptr); } diff --git a/iceoryx2-ffi/cxx/src/node.cpp b/iceoryx2-ffi/cxx/src/node.cpp new file mode 100644 index 000000000..95010bca5 --- /dev/null +++ b/iceoryx2-ffi/cxx/src/node.cpp @@ -0,0 +1,27 @@ +// Copyright (c) 2024 Contributors to the Eclipse Foundation +// +// See the NOTICE file(s) distributed with this work for additional +// information regarding copyright ownership. +// +// This program and the accompanying materials are made available under the +// terms of the Apache Software License 2.0 which is available at +// https://www.apache.org/licenses/LICENSE-2.0, or the MIT license +// which is available at https://opensource.org/licenses/MIT. +// +// SPDX-License-Identifier: Apache-2.0 OR MIT + +#include "iox2/node.hpp" + +#include + +namespace iox2 { +iox::expected NodeName::create( + const char* value) {} + +const std::string& NodeName::as_string() const {} + +NodeBuilder::NodeBuilder() : m_handle{iox2_node_builder_new(nullptr)} {} + +template +iox::expected, NodeCreationFailure> NodeBuilder::create() const&& {} +} // namespace iox2