@@ -63,11 +63,12 @@ namespace simmer {
63
63
*/
64
64
Source (Simulator* sim, const std::string& name_prefix, int mon,
65
65
const REnv& trj, const Order& order)
66
- : Process(sim, name_prefix, mon, PRIORITY_MIN), count(0 ), order(order),
67
- first_activity (internal::head(trj)), trj(trj) {}
66
+ : Process(sim, name_prefix, mon, PRIORITY_MIN), order(order), trj_(trj) {}
68
67
69
68
virtual void reset () {
70
69
count = 0 ;
70
+ trj = trj_;
71
+ head = internal::head (trj);
71
72
ahead.clear ();
72
73
}
73
74
@@ -81,7 +82,7 @@ namespace simmer {
81
82
return Process::deactivate ();
82
83
}
83
84
84
- int get_n_generated () const { return count; }
85
+ int get_count () const { return count; }
85
86
86
87
REnv get_trajectory () const { return trj; }
87
88
@@ -93,27 +94,23 @@ namespace simmer {
93
94
94
95
void set_trajectory (const REnv& new_trj) {
95
96
trj = new_trj;
96
- first_activity = internal::head (trj);
97
+ head = internal::head (trj);
97
98
}
98
99
99
100
protected:
100
- int count; /* *< number of arrivals generated */
101
- Order order;
102
- Activity* first_activity;
103
-
104
101
Arrival* new_arrival (double delay) {
105
102
// format the name and create the next arrival
106
103
std::string arr_name = MakeString () << name << count++;
107
104
Arrival* arrival = new Arrival (
108
- sim, arr_name, is_monitored (), order, first_activity , count, this );
105
+ sim, arr_name, is_monitored (), order, head , count, this );
109
106
ahead.emplace (arrival);
110
107
111
108
if (sim->verbose ) sim->print (" source" , name, " new" , arr_name,
112
109
MakeString () << (sim->now () + delay));
113
110
114
111
// schedule the arrival
115
- sim->schedule (delay, arrival, first_activity && first_activity ->priority ?
116
- first_activity ->priority : count);
112
+ sim->schedule (delay, arrival, head && head ->priority ?
113
+ head ->priority : count);
117
114
118
115
return arrival;
119
116
}
@@ -129,7 +126,10 @@ namespace simmer {
129
126
}
130
127
131
128
private:
132
- REnv trj;
129
+ int count; /* *< number of arrivals generated */
130
+ Order order;
131
+ Activity* head;
132
+ REnv trj_, trj;
133
133
ArrSet ahead;
134
134
135
135
virtual void set_source_impl (const std::any& new_source) = 0;
0 commit comments