Skip to content

Commit

Permalink
[eclipse-iceoryx#264] Add first nodebuilder implementation
Browse files Browse the repository at this point in the history
  • Loading branch information
elfenpiff committed Jul 10, 2024
1 parent b25237c commit ecd6422
Show file tree
Hide file tree
Showing 5 changed files with 49 additions and 15 deletions.
14 changes: 7 additions & 7 deletions examples/cxx/publish_subscribe/src/publisher.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,14 @@

int main() {
using namespace iox2;
auto node =
NodeBuilder()
.name(NodeName::create("hello world").expect("valid node name"))
.template create<NodeType::ZERO_COPY>()
.expect("successful node creation");
auto node = NodeBuilder();
// .name(NodeName::create("hello world").expect("valid node name"))
// .template create<NodeType::ZERO_COPY>()
// .expect("successful node creation");

Node<NodeType::ZERO_COPY>::list(
Config{}, [](auto) { return iox::ok(CallbackProgression::Continue); });
// Node<NodeType::ZERO_COPY>::list(
// Config{}, [](auto) { return iox::ok(CallbackProgression::Continue);
// });

return 0;
}
1 change: 1 addition & 0 deletions iceoryx2-ffi/cxx/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
9 changes: 7 additions & 2 deletions iceoryx2-ffi/cxx/include/iox2/node.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ class NodeName {
const std::string& as_string() const;

private:
std::string value;
iox2_node_name_storage_t value;
};

class ServiceName {
Expand Down Expand Up @@ -106,8 +106,13 @@ class NodeBuilder {
IOX_BUILDER_PARAMETER(Config, config, Config{})

public:
NodeBuilder();

template <NodeType T>
iox::expected<Node<T>, NodeCreationFailure> create() const;
iox::expected<Node<T>, NodeCreationFailure> create() const&&;

private:
iox2_node_builder_h m_handle;
};
} // namespace iox2

Expand Down
13 changes: 7 additions & 6 deletions iceoryx2-ffi/cxx/src/dummy.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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 <iostream>
#include <iox/logging.hpp>

#include "iox2/iceoryx2.h"

#include <iox/logging.hpp>
#include <iostream>
#include "iox2/node.hpp"

void hypnotoad() {
IOX_LOG(INFO, "All glory to the hypnotoad!");
iox2_node_builder_new(nullptr);
}
27 changes: 27 additions & 0 deletions iceoryx2-ffi/cxx/src/node.cpp
Original file line number Diff line number Diff line change
@@ -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 <iox2/iceoryx2.h>

namespace iox2 {
iox::expected<NodeName, SemanticStringError> NodeName::create(
const char* value) {}

const std::string& NodeName::as_string() const {}

NodeBuilder::NodeBuilder() : m_handle{iox2_node_builder_new(nullptr)} {}

template <NodeType T>
iox::expected<Node<T>, NodeCreationFailure> NodeBuilder::create() const&& {}
} // namespace iox2

0 comments on commit ecd6422

Please sign in to comment.