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

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

28 Aug 2025 07:57AM UTC coverage: 46.066% (+0.5%) from 45.534%
#415

push

github

srs-mate
refactor: fix rebase conflict

1 of 10 new or added lines in 2 files covered. (10.0%)

66 existing lines in 6 files now uncovered.

1206 of 2618 relevant lines covered (46.07%)

6.6 hits per line

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

0.0
/src/main/scala/io/github/srs/view/ViewModule.scala
1
package io.github.srs.view
2

3
import cats.effect.IO
4
import cats.effect.std.Queue
5
import io.github.srs.controller.protocol.Event
6
import io.github.srs.model.ModelModule
7

8
/**
9
 * Module that defines the view logic for the Scala Robotics Simulator.
10
 */
11
object ViewModule:
12

×
13
  /**
14
   * View trait that defines the interface for the view.
15
   *
16
   * @tparam S
17
   *   the type of the state, which must extend [[ModelModule.State]].
18
   */
19
  trait View[S <: ModelModule.State]:
20

×
21
    /**
22
     * Initializes the view with a queue for handling events.
23
     * @param queue
24
     *   the queue that will be used to handle events in the view.
25
     * @return
26
     *   an [[IO]] task that completes when the initialization is done.
27
     */
28
    def init(queue: Queue[IO, Event]): IO[Unit]
29

30
    /**
31
     * Renders the view based on the current state.
32
     * @param state
33
     *   the current state of the simulation, which must extend [[ModelModule.State]].
34
     * @return
35
     *   the rendering task, which is an [[IO]] that completes when the rendering is done.
36
     */
37
    def render(state: S): IO[Unit]
38

39
    /**
40
     * Closes the view and releases any resources.
41
     * @return
42
     *   an [[IO]] task that completes when the view is closed.
43
     */
44
    def close(): IO[Unit]
45

46
  end View
47

48
  /**
49
   * Provider trait that defines the interface for providing a view.
50
   * @tparam S
51
   *   the type of the state, which must extend [[ModelModule.State]].
52
   */
53
  trait Provider[S <: ModelModule.State]:
54
    val view: View[S]
55

56
  /**
57
   * Defines the dependencies required by the view module. In particular, it requires a
58
   * [[io.github.srs.controller.ControllerModule.Provider]].
59
   */
60
  type Requirements[S <: ModelModule.State] = io.github.srs.controller.ControllerModule.Provider[S]
61

62
  /**
63
   * Component trait that defines the interface for creating a view.
64
   *
65
   * @tparam S
66
   *   the type of the simulation state, which must extend [[ModelModule.State]].
67
   */
68
  trait Component[S <: ModelModule.State]:
UNCOV
69
    context: Requirements[S] =>
×
70

71
    /**
72
     * Factory method to create a new instance of the view.
73
     */
74
    object View:
75
      /**
×
76
       * Creates a new instance of the view.
77
       * @return
78
       *   the newly created view instance.
79
       */
80
      def apply(): View[S] = makeView()
81

×
82
    /**
83
     * Creates a new instance of the view.
84
     * @return
85
     *   the newly created view instance.
86
     */
87
    protected def makeView(): View[S]
88

89
  end Component
90

91
  /**
92
   * Interface trait that combines the provider and component traits for the view module.
93
   * @tparam S
94
   *   the type of the state, which must extend [[ModelModule.State]].
95
   */
96
  trait Interface[S <: ModelModule.State] extends Provider[S] with Component[S]:
97
    self: Requirements[S] =>
98
end ViewModule
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