From f2006f60762baeb23f3f911c0d483a8550ab11a2 Mon Sep 17 00:00:00 2001 From: "benjamin.lesage" Date: Fri, 12 Apr 2024 09:22:53 +0200 Subject: [PATCH] Add default services flag support on constructors --- .../model/hardware/BaseHardwareNodeBuilder.scala | 15 +++++++++++++++ .../pml/model/hardware/HardwareTest.scala | 3 +++ 2 files changed, 18 insertions(+) diff --git a/src/main/scala/onera/pmlanalyzer/pml/model/hardware/BaseHardwareNodeBuilder.scala b/src/main/scala/onera/pmlanalyzer/pml/model/hardware/BaseHardwareNodeBuilder.scala index 8362ed1..b62d7f4 100644 --- a/src/main/scala/onera/pmlanalyzer/pml/model/hardware/BaseHardwareNodeBuilder.scala +++ b/src/main/scala/onera/pmlanalyzer/pml/model/hardware/BaseHardwareNodeBuilder.scala @@ -150,4 +150,19 @@ trait BaseHardwareNodeBuilder[T <: Hardware] extends PMLNodeBuilder[T] { def apply(name: Symbol)(implicit p: ProvideRelation[Hardware, Service], owner: Owner): T = apply(name, Set.empty, true) + + + /** + * A physical component can be defined only its name, the services will be defined by default + * + * @group publicConstructor + * @param name the physical component name + * @param withDefaultServices add default Load/Store services on creation + * @param p implicitly retrieved relation linking components to their provided services + * @param owner implicitly retrieved name of the platform + * @return the physical component + */ + def apply(name: Symbol, withDefaultServices: Boolean)(implicit p: ProvideRelation[Hardware, Service], + owner: Owner): T = + apply(name, Set.empty, withDefaultServices) } diff --git a/src/test/scala/onera/pmlanalyzer/pml/model/hardware/HardwareTest.scala b/src/test/scala/onera/pmlanalyzer/pml/model/hardware/HardwareTest.scala index f46ff06..4161317 100644 --- a/src/test/scala/onera/pmlanalyzer/pml/model/hardware/HardwareTest.scala +++ b/src/test/scala/onera/pmlanalyzer/pml/model/hardware/HardwareTest.scala @@ -49,6 +49,9 @@ class HardwareTest extends AnyFlatSpec with should.Matchers { val i = Target(Set.empty, false) i.services.size shouldEqual 0 + + val j = Target(Symbol("j"), false) + j.services.size shouldEqual 0 } }