Skip to content

Commit

Permalink
[eclipse-iceoryx#264] Implement API stubs for service factory
Browse files Browse the repository at this point in the history
  • Loading branch information
elfenpiff committed Jul 10, 2024
1 parent a7a8de0 commit 445a7ed
Show file tree
Hide file tree
Showing 15 changed files with 533 additions and 25 deletions.
9 changes: 8 additions & 1 deletion examples/cxx/publish_subscribe/src/publisher.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,16 @@

int main() {
using namespace iox2;
auto node = NodeBuilder().template create<NodeType::ZERO_COPY>().expect(
auto node = NodeBuilder().template create<ServiceType::Ipc>().expect(
"successful node creation");

auto service =
node.service_builder(ServiceName::create("My/Funk/ServiceName")
.expect("valid service name"))
.publish_subscribe<TransmissionData>()
.open_or_create()
.expect("successful service creation/opening");

// Node<NodeType::ZERO_COPY>::list(
// Config{}, [](auto) { return iox::ok(CallbackProgression::Continue);
// });
Expand Down
25 changes: 25 additions & 0 deletions iceoryx2-ffi/cxx/include/iox2/attribute.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
// 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
#ifndef IOX2_ATTRIBUTE_HPP_
#define IOX2_ATTRIBUTE_HPP_

#include <string>

namespace iox2 {
class Attribute {
public:
const std::string& key() const {}
const std::string& value() const {}
};
} // namespace iox2

#endif
25 changes: 25 additions & 0 deletions iceoryx2-ffi/cxx/include/iox2/attribute_set.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
// 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
#ifndef IOX2_ATTRIBUTE_SET_HPP_
#define IOX2_ATTRIBUTE_SET_HPP_

#include <string>
#include <vector>

namespace iox2 {
class AttributeSet {
public:
std::vector<std::string> get(const std::string& key) const {}
};
} // namespace iox2

#endif
29 changes: 29 additions & 0 deletions iceoryx2-ffi/cxx/include/iox2/attribute_specifier.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
// 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
#ifndef IOX2_ATTRIBUTE_SPECIFIER_HPP_
#define IOX2_ATTRIBUTE_SPECIFIER_HPP_

#include <string>

#include "attribute_set.hpp"

namespace iox2 {
class AttributeSpecifier {
public:
AttributeSpecifier() = default;
AttributeSpecifier& define(const std::string& key,
const std::string& value) {}
AttributeSet& attributes() const {}
};
} // namespace iox2

#endif
36 changes: 36 additions & 0 deletions iceoryx2-ffi/cxx/include/iox2/attribute_verifier.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
// 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
#ifndef IOX2_ATTRIBUTE_VERIFIER_HPP_
#define IOX2_ATTRIBUTE_VERIFIER_HPP_

#include <iox/expected.hpp>
#include <string>
#include <vector>

#include "attribute_set.hpp"

namespace iox2 {
class AttributeVerifier {
public:
AttributeVerifier() = default;
AttributeVerifier& require(const std::string& key,
const std::string& value) {}
AttributeVerifier& require_key(const std::string& key) {}
const AttributeSet& attributes() const {}
std::vector<std::string> keys() const {}

iox::expected<void, std::string> verify_requirements(
const AttributeSet& rhs) const {}
};
} // namespace iox2

#endif
Empty file.
31 changes: 11 additions & 20 deletions iceoryx2-ffi/cxx/include/iox2/node.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,9 @@
#include "config.hpp"
#include "internal/iceoryx2.hpp"
#include "node_name.hpp"
#include "service_builder.hpp"
#include "service_name.hpp"
#include "service_type.hpp"

namespace iox2 {
enum class NodeListFailure {};
Expand All @@ -29,41 +32,29 @@ enum class NodeCreationFailure { InsufficientPermissions, InternalError };

enum class NodeCleanupFailure {};

enum class NodeType { PROCESS_LOCAL, ZERO_COPY };

class NodeId {};
class ServiceName {
public:
static iox::expected<ServiceName, SemanticStringError> create(
const char* value);
const std::string& as_string() const;
};

template <NodeType>
class Builder {};

class NodeDetails {
public:
const NodeName& name() const;
const Config& config() const;
};

template <NodeType>
template <ServiceType>
class AliveNodeView {
public:
const NodeId& id() const;
const iox::optional<NodeDetails> details() const;
};

template <NodeType>
template <ServiceType>
class DeadNodeView {
public:
const NodeId& id() const;
const iox::optional<NodeDetails> details() const;
iox::expected<bool, NodeCleanupFailure> remove_stale_resources();
};

template <NodeType T>
template <ServiceType T>
class NodeState {
public:
NodeState& if_alive(const iox::function<void(AliveNodeView<T>&)>& callback);
Expand All @@ -72,12 +63,12 @@ class NodeState {
NodeState& is_undefined(const iox::function<void(NodeId&)>& callback);
};

template <NodeType T>
template <ServiceType T>
class Node {
public:
NodeName& name() const;
NodeId& id() const;
Builder<T> service_builder(const ServiceName& name) const;
NodeName& name() const {}
NodeId& id() const {}
ServiceBuilder<T> service_builder(const ServiceName& name) const {}

static iox::expected<void, NodeListFailure> list(
const Config& config,
Expand All @@ -98,7 +89,7 @@ class NodeBuilder {
public:
NodeBuilder();

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

private:
Expand Down
22 changes: 22 additions & 0 deletions iceoryx2-ffi/cxx/include/iox2/port_factory_event.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
// 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
#ifndef IOX2_PORTFACTORY_EVENT_HPP_
#define IOX2_PORTFACTORY_EVENT_HPP_

#include "service_type.hpp"

namespace iox2 {
template <ServiceType>
class PortFactoryEvent {};
} // namespace iox2

#endif
22 changes: 22 additions & 0 deletions iceoryx2-ffi/cxx/include/iox2/port_factory_publish_subscribe.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
// 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
#ifndef IOX2_PORTFACTORY_PUBLISH_SUBSCRIBE_HPP_
#define IOX2_PORTFACTORY_PUBLISH_SUBSCRIBE_HPP_

#include "service_type.hpp"

namespace iox2 {
template <ServiceType, typename Payload, typename UserHeader>
class PortFactoryPublishSubscribe {};
} // namespace iox2

#endif
31 changes: 31 additions & 0 deletions iceoryx2-ffi/cxx/include/iox2/service_builder.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
// 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
#ifndef IOX2_SERVICE_BUILDER_HPP_
#define IOX2_SERVICE_BUILDER_HPP_

#include "service_builder_event.hpp"
#include "service_builder_publish_subscribe.hpp"
#include "service_type.hpp"

namespace iox2 {

template <ServiceType S>
class ServiceBuilder {
public:
template <typename Payload>
ServiceBuilderPublishSubscribe<Payload, void, S> publish_subscribe() {}

ServiceBuilderEvent<S> event() {}
};

} // namespace iox2
#endif
Loading

0 comments on commit 445a7ed

Please sign in to comment.