Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

remove Config::client() and ::peer() methods #210

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
53 changes: 0 additions & 53 deletions include/zenoh/api/config.hxx
Original file line number Diff line number Diff line change
Expand Up @@ -36,17 +36,6 @@ class Config : public Owned<::z_owned_config_t> {
}

#ifdef ZENOHCXX_ZENOHC
/// @brief Create the default configuration for "peer" mode.
/// @param err if not null, the result code will be written to this location, otherwise ZException exception will be
/// thrown in case of error.
/// @return the ``Config`` object.
/// @note zenoh-c only.
static Config peer(ZResult* err = nullptr) {
Config c(zenoh::detail::null_object);
__ZENOH_RESULT_CHECK(::z_config_peer(&c._0), err, std::string("Failed to create peer configuration"));
return c;
}

/// @brief Create the configuration from the JSON file.
/// @param path path to the config file.
/// @param err if not null, the result code will be written to this location, otherwise ZException exception will be
Expand All @@ -72,22 +61,6 @@ class Config : public Owned<::z_owned_config_t> {
std::string("Failed to create config from: ").append(s));
return c;
}
/// @brief Create the configuration for "client" mode.
/// @param peers the array of peer endpoints.
/// @param err if not null, the result code will be written to this location, otherwise ZException exception will be
/// thrown in case of error.
/// @return the ``Config`` object.
/// @note zenoh-c only.
static Config client(const std::vector<std::string>& peers, ZResult* err = nullptr) {
Config c(zenoh::detail::null_object);
std::vector<const char*> p;
p.reserve(peers.size());
for (const auto& peer : peers) {
p.push_back(peer.c_str());
}
__ZENOH_RESULT_CHECK(::z_config_client(&c._0, p.data(), p.size()), err, "Failed to create client config");
return c;
}

/// @brief Create a configuration by parsing a file with path stored in ZENOH_CONFIG environment variable.
/// @param err if not null, the result code will be written to this location, otherwise ZException exception will be
Expand All @@ -101,32 +74,6 @@ class Config : public Owned<::z_owned_config_t> {
}
#endif

#ifdef ZENOHCXX_ZENOHPICO
/// @brief Create the default configuration for "peer" mode.
/// @param locator Multicast address for peer-to-peer communication.
/// @param err if not null, the result code will be written to this location, otherwise ZException exception will be
/// thrown in case of error.
/// @return the ``Config`` object.
/// @note zenoh-pico only.
static Config peer(const char* locator, ZResult* err = nullptr) {
Config c(zenoh::detail::null_object);
__ZENOH_RESULT_CHECK(::z_config_peer(&c._0, locator), err, "Failed to create client config");
return c;
}

/// @brief Create the configuration for "client" mode.
/// @param peer the peer locator to connect to, if null, multicast scouting will be performed.
/// @param err if not null, the result code will be written to this location, otherwise ZException exception will be
/// thrown in case of error.
/// @return the ``Config`` object.
/// @note zenoh-pico only.
static Config client(const char* peer, ZResult* err = nullptr) {
Config c(zenoh::detail::null_object);
__ZENOH_RESULT_CHECK(::z_config_client(&c._0, peer), err, "Failed to create client config");
return c;
}
#endif

/// @name Methods

#ifdef ZENOHCXX_ZENOHC
Expand Down
14 changes: 5 additions & 9 deletions tests/zenohc/config.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -19,18 +19,15 @@ using namespace zenoh;
#undef NDEBUG
#include <assert.h>

void test_config_client() {
void test_config_insert() {
std::vector<std::string> peers = {"tcp/192.168.0.1", "tcp/10.0.0.1"};
auto config = Config::client(peers);
auto config = Config::create_default();
config.insert_json("mode", "\"client\"");
config.insert_json("connect/endpoints", "[\"tcp/192.168.0.1\", \"tcp/10.0.0.1\"]");
assert(config.get("mode") == "\"client\"");
assert(config.get("connect/endpoints") == "[\"tcp/192.168.0.1\",\"tcp/10.0.0.1\"]");
}

void test_config_peer() {
auto config = Config::peer();
assert(config.get("mode") == "\"peer\"");
}

void test_config_to_string() {
Config config = Config::create_default();
auto s = config.to_string();
Expand All @@ -40,8 +37,7 @@ void test_config_to_string() {

int main(int argc, char** argv) {
init_logging();
test_config_client();
test_config_peer();
test_config_insert();
test_config_to_string();
// TODO: add more tests
};
Loading