Skip to content

Commit

Permalink
[eclipse-iceoryx#231] Properties can be read via port factory
Browse files Browse the repository at this point in the history
  • Loading branch information
elfenpiff committed Jun 9, 2024
1 parent 9a300b6 commit fd04244
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 6 deletions.
2 changes: 1 addition & 1 deletion iceoryx2/src/service/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -367,7 +367,7 @@ pub trait Service: Debug + Sized {
continue;
}

if service_config.service_name() == service_name {
if service_config.name() == service_name {
return Ok(true);
}
}
Expand Down
7 changes: 6 additions & 1 deletion iceoryx2/src/service/port_factory/event.rs
Original file line number Diff line number Diff line change
Expand Up @@ -60,14 +60,19 @@ impl<Service: service::Service> PortFactory<Service> {

/// Returns the [`ServiceName`] of the [`crate::service::Service`]
pub fn name(&self) -> &ServiceName {
self.service.state().static_config.service_name()
self.service.state().static_config.name()
}

/// Returns the uuid of the [`crate::service::Service`]
pub fn uuid(&self) -> &str {
self.service.state().static_config.uuid()
}

/// Returns the value of a property
pub fn property(&self, key: &str) -> Option<&str> {
self.service.state().static_config.property(key)
}

/// Returns the [`static_config::event::StaticConfig`] of the [`crate::service::Service`].
/// Contains all settings that never change during the lifetime of the service.
pub fn static_config(&self) -> &static_config::event::StaticConfig {
Expand Down
7 changes: 6 additions & 1 deletion iceoryx2/src/service/port_factory/publish_subscribe.rs
Original file line number Diff line number Diff line change
Expand Up @@ -79,14 +79,19 @@ impl<Service: service::Service, PayloadType: Debug + ?Sized> PortFactory<Service

/// Returns the [`ServiceName`] of the service
pub fn name(&self) -> &ServiceName {
self.service.state().static_config.service_name()
self.service.state().static_config.name()
}

/// Returns the uuid of the [`crate::service::Service`]
pub fn uuid(&self) -> &str {
self.service.state().static_config.uuid()
}

/// Returns the value of a property
pub fn property(&self, key: &str) -> Option<&str> {
self.service.state().static_config.property(key)
}

/// Returns the [`static_config::event::StaticConfig`] of the [`crate::service::Service`].
/// Contains all settings that never change during the lifetime of the service.
pub fn static_config(&self) -> &static_config::publish_subscribe::StaticConfig {
Expand Down
6 changes: 3 additions & 3 deletions iceoryx2/src/service/static_config/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -85,20 +85,20 @@ impl StaticConfig {
}

/// Returns the value of a property
pub fn property(&self, key: &str) -> Option<&str> {
pub(crate) fn property(&self, key: &str) -> Option<&str> {
self.properties
.iter()
.find(|&v| v.0 == key)
.and_then(|v| Some(v.1.as_str()))
}

/// Returns the uuid of the [`crate::service::Service`]
pub fn uuid(&self) -> &str {
pub(crate) fn uuid(&self) -> &str {
&self.uuid
}

/// Returns the [`ServiceName`] of the [`crate::service::Service`]
pub fn service_name(&self) -> &ServiceName {
pub(crate) fn name(&self) -> &ServiceName {
&self.service_name
}

Expand Down

0 comments on commit fd04244

Please sign in to comment.