• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

Scala-Robotics-Simulator / PPS-22-srs / #109

27 Jul 2025 10:48AM UTC coverage: 74.412% (-2.0%) from 76.435%
#109

push

github

srs-mate
refactor: use named parameter for state copy in Launcher

253 of 340 relevant lines covered (74.41%)

10.75 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

0.0
/src/main/scala/io/github/srs/model/ModelModule.scala
1
package io.github.srs.model
2

3
/**
4
 * Module that defines the model logic for the Scala Robotics Simulator.
5
 */
6
object ModelModule:
7

×
8
  /**
9
   * State trait that defines the base state for the simulation.
10
   */
11
  trait State
12

×
13
  /**
14
   * Trait representing the core model logic for updating the simulation state.
15
   *
16
   * @tparam S
17
   *   the type of the simulation state, which must extend [[State]].
18
   */
19
  trait Model[S <: State]:
20
    /**
21
     * Updates the state of the simulation.
22
     *
23
     * @param s
24
     *   the current state of the simulation.
25
     * @return
26
     *   an optional new state, or None if the simulation should end.
27
     */
28
    def update(s: S): Option[S]
29

30
  /**
31
   * Provider trait that defines the interface for providing a model.
32
   * @tparam S
33
   *   the type of the state, which must extend [[State]].
34
   */
35
  trait Provider[S <: State]:
36
    val model: Model[S]
37

38
  /**
39
   * Component trait that defines the interface for creating a model.
40
   *
41
   * @tparam S
42
   *   the type of the simulation state, which must extend [[State]].
43
   */
44
  trait Component[S <: State]:
45

×
46
    object Model:
47
      /**
×
48
       * Creates a model from the provided update function.
49
       *
50
       * @param updateFunc
51
       *   a function that defines how the state is updated.
52
       * @return
53
       *   a [[Model]] instance using the given update logic.
54
       */
55
      def apply(updateFunc: S => Option[S]): Model[S] = new ModelImpl(updateFunc)
56

×
57
      /**
58
       * Private model implementation that delegates state updates to the provided function.
59
       */
60
      private class ModelImpl(updateFunc: S => Option[S]) extends Model[S]:
61
        /**
×
62
         * @inheritdoc
63
         */
64
        override def update(s: S): Option[S] = updateFunc(s)
65
  end Component
×
66

67
  /**
68
   * Interface trait that combines the provider and component traits.
69
   * @tparam S
70
   *   the type of the state, which must extend [[State]].
71
   */
72
  trait Interface[S <: State] extends Provider[S] with Component[S]
73
end ModelModule
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc