@@ -3,20 +3,20 @@ use crate::simulator::Services;
33use crate :: utils:: errors:: SimulationError ;
44
55pub trait ModelClone {
6- fn clone_box ( & self ) -> Box < dyn AsModel > ;
6+ fn clone_box ( & self ) -> Box < dyn ReportableModel > ;
77}
88
99impl < T > ModelClone for T
1010where
11- T : ' static + AsModel + Clone ,
11+ T : ' static + ReportableModel + Clone ,
1212{
13- fn clone_box ( & self ) -> Box < dyn AsModel > {
13+ fn clone_box ( & self ) -> Box < dyn ReportableModel > {
1414 Box :: new ( self . clone ( ) )
1515 }
1616}
1717
18- impl Clone for Box < dyn AsModel > {
19- fn clone ( & self ) -> Box < dyn AsModel > {
18+ impl Clone for Box < dyn ReportableModel > {
19+ fn clone ( & self ) -> Box < dyn ReportableModel > {
2020 self . clone_box ( )
2121 }
2222}
@@ -30,14 +30,11 @@ pub trait SerializableModel {
3030 }
3131}
3232
33- /// The `AsModel ` trait defines everything required for a model to operate
33+ /// The `DevsModel ` trait defines everything required for a model to operate
3434/// within the discrete event simulation. The simulator formalism (Discrete
3535/// Event System Specification) requires `events_ext`, `events_int`,
36- /// `time_advance`, and `until_next_event`. The additional `status` is for
37- /// facilitation of simulation reasoning, reporting, and debugging.
38- // #[enum_dispatch]
39- pub trait AsModel : ModelClone + SerializableModel {
40- fn status ( & self ) -> String ;
36+ /// `time_advance`, and `until_next_event`.
37+ pub trait DevsModel : ModelClone + SerializableModel {
4138 fn events_ext (
4239 & mut self ,
4340 incoming_message : & ModelMessage ,
@@ -48,3 +45,15 @@ pub trait AsModel: ModelClone + SerializableModel {
4845 fn time_advance ( & mut self , time_delta : f64 ) ;
4946 fn until_next_event ( & self ) -> f64 ;
5047}
48+
49+ /// The additional status and record-keeping methods of `Reportable` provide
50+ /// improved simulation reasoning, reporting, and debugging, but do not
51+ /// impact simulation execution or results.
52+ pub trait Reportable {
53+ fn status ( & self ) -> String ;
54+ }
55+
56+ /// A `ReportableModel` has the required Discrete Event System Specification
57+ /// methods of trait `DevsModel` and the status reporting and record keeping
58+ /// mechanisms of trait `Reportable`.
59+ pub trait ReportableModel : DevsModel + Reportable { }
0 commit comments