/
activity.cpp
411 lines (338 loc) · 12.9 KB
/
activity.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
#include <simmer.h>
using namespace Rcpp;
using namespace simmer;
//[[Rcpp::export]]
SEXP Seize__new(const std::string& resource, int amount, std::vector<bool> cont,
const std::vector<Environment>& trj, unsigned short mask)
{
return XPtr<Seize<int> >(new Seize<int>(resource, amount, cont, trj, mask));
}
//[[Rcpp::export]]
SEXP Seize__new_func(const std::string& resource, const Function& amount, std::vector<bool> cont,
const std::vector<Environment>& trj, unsigned short mask)
{
return XPtr<Seize<Function> >(new Seize<Function>(resource, amount, cont, trj, mask));
}
//[[Rcpp::export]]
SEXP SeizeSelected__new(int id, int amount, std::vector<bool> cont,
const std::vector<Environment>& trj, unsigned short mask)
{
return XPtr<Seize<int> >(new Seize<int>(id, amount, cont, trj, mask));
}
//[[Rcpp::export]]
SEXP SeizeSelected__new_func(int id, const Function& amount, std::vector<bool> cont,
const std::vector<Environment>& trj, unsigned short mask)
{
return XPtr<Seize<Function> >(new Seize<Function>(id, amount, cont, trj, mask));
}
//[[Rcpp::export]]
SEXP Release__new(const std::string& resource, int amount) {
return XPtr<Release<int> >(new Release<int>(resource, amount));
}
//[[Rcpp::export]]
SEXP Release__new_func(const std::string& resource, const Function& amount) {
return XPtr<Release<Function> >(new Release<Function>(resource, amount));
}
//[[Rcpp::export]]
SEXP ReleaseSelected__new(int id, int amount) {
return XPtr<Release<int> >(new Release<int>(id, amount));
}
//[[Rcpp::export]]
SEXP ReleaseSelected__new_func(int id, const Function& amount) {
return XPtr<Release<Function> >(new Release<Function>(id, amount));
}
//[[Rcpp::export]]
SEXP SetCapacity__new(const std::string& resource, double value, char mod) {
return XPtr<SetCapacity<double> >(new SetCapacity<double>(resource, value, mod));
}
//[[Rcpp::export]]
SEXP SetCapacity__new_func(const std::string& resource, const Function& value, char mod) {
return XPtr<SetCapacity<Function> >(new SetCapacity<Function>(resource, value, mod));
}
//[[Rcpp::export]]
SEXP SetCapacitySelected__new(int id, double value, char mod) {
return XPtr<SetCapacity<double> >(new SetCapacity<double>(id, value, mod));
}
//[[Rcpp::export]]
SEXP SetCapacitySelected__new_func(int id, const Function& value, char mod) {
return XPtr<SetCapacity<Function> >(new SetCapacity<Function>(id, value, mod));
}
//[[Rcpp::export]]
SEXP SetQueue__new(const std::string& resource, double value, char mod) {
return XPtr<SetQueue<double> >(new SetQueue<double>(resource, value, mod));
}
//[[Rcpp::export]]
SEXP SetQueue__new_func(const std::string& resource, const Function& value, char mod) {
return XPtr<SetQueue<Function> >(new SetQueue<Function>(resource, value, mod));
}
//[[Rcpp::export]]
SEXP SetQueueSelected__new(int id, double value, char mod) {
return XPtr<SetQueue<double> >(new SetQueue<double>(id, value, mod));
}
//[[Rcpp::export]]
SEXP SetQueueSelected__new_func(int id, const Function& value, char mod) {
return XPtr<SetQueue<Function> >(new SetQueue<Function>(id, value, mod));
}
//[[Rcpp::export]]
SEXP Select__new(const std::vector<std::string>& resources, const std::string& policy, int id) {
return XPtr<Select<VEC<std::string> > >(new Select<VEC<std::string> >(resources, policy, id));
}
//[[Rcpp::export]]
SEXP Select__new_func(const Function& resources, const std::string& policy, int id) {
return XPtr<Select<Function> >(new Select<Function>(resources, policy, id));
}
//[[Rcpp::export]]
SEXP SetAttribute__new(const std::vector<std::string>& keys,
const std::vector<double>& values, bool global, char mod)
{
return XPtr<SetAttribute<VEC<std::string>, VEC<double> > >(
new SetAttribute<VEC<std::string>, VEC<double> >(keys, values, global, mod));
}
//[[Rcpp::export]]
SEXP SetAttribute__new_func1(const Function& keys,
const std::vector<double>& values, bool global, char mod)
{
return XPtr<SetAttribute<Function, VEC<double> > >(
new SetAttribute<Function, VEC<double> >(keys, values, global, mod));
}
//[[Rcpp::export]]
SEXP SetAttribute__new_func2(const std::vector<std::string>& keys,
const Function& values, bool global, char mod)
{
return XPtr<SetAttribute<VEC<std::string>, Function> >(
new SetAttribute<VEC<std::string>, Function>(keys, values, global, mod));
}
//[[Rcpp::export]]
SEXP SetAttribute__new_func3(const Function& keys,
const Function& values, bool global, char mod)
{
return XPtr<SetAttribute<Function, Function> >(
new SetAttribute<Function, Function>(keys, values, global, mod));
}
//[[Rcpp::export]]
SEXP Activate__new(const std::string& source) {
return XPtr<Activate<std::string> >(new Activate<std::string>(source));
}
//[[Rcpp::export]]
SEXP Activate__new_func(const Function& source) {
return XPtr<Activate<Function> >(new Activate<Function>(source));
}
//[[Rcpp::export]]
SEXP Deactivate__new(const std::string& source) {
return XPtr<Deactivate<std::string> >(new Deactivate<std::string>(source));
}
//[[Rcpp::export]]
SEXP Deactivate__new_func(const Function& source) {
return XPtr<Deactivate<Function> >(new Deactivate<Function>(source));
}
//[[Rcpp::export]]
SEXP SetTraj__new(const std::string& source, const Environment& trj) {
return XPtr<SetTraj<std::string> >(new SetTraj<std::string>(source, trj));
}
//[[Rcpp::export]]
SEXP SetTraj__new_func(const Function& source, const Environment& trj) {
return XPtr<SetTraj<Function> >(new SetTraj<Function>(source, trj));
}
//[[Rcpp::export]]
SEXP SetSourceFn__new(const std::string& source, const Function& dist) {
return XPtr<SetSource<std::string, Function> >(
new SetSource<std::string, Function>(source, dist));
}
//[[Rcpp::export]]
SEXP SetSourceFn__new_func(const Function& source, const Function& dist) {
return XPtr<SetSource<Function, Function> >(
new SetSource<Function, Function>(source, dist));
}
//[[Rcpp::export]]
SEXP SetSourceDF__new(const std::string& source, const DataFrame& data) {
return XPtr<SetSource<std::string, DataFrame> >(
new SetSource<std::string, DataFrame>(source, data));
}
//[[Rcpp::export]]
SEXP SetSourceDF__new_func(const Function& source, const DataFrame& data) {
return XPtr<SetSource<Function, DataFrame> >(
new SetSource<Function, DataFrame>(source, data));
}
//[[Rcpp::export]]
SEXP SetPrior__new(const std::vector<int>& values, char mod) {
return XPtr<SetPrior<VEC<int> > >(new SetPrior<VEC<int> >(values, mod));
}
//[[Rcpp::export]]
SEXP SetPrior__new_func(const Function& values, char mod) {
return XPtr<SetPrior<Function> >(new SetPrior<Function>(values, mod));
}
//[[Rcpp::export]]
SEXP Timeout__new(double delay) {
return XPtr<Timeout<double> >(new Timeout<double>(delay));
}
//[[Rcpp::export]]
SEXP Timeout__new_func(const Function& task) {
return XPtr<Timeout<Function> >(new Timeout<Function>(task));
}
//[[Rcpp::export]]
SEXP Timeout__new_attr(const std::string& key, bool global) {
typedef FnWrap<double, Arrival*, std::string> Callback;
Callback call = Callback(BIND(&Arrival::get_attribute, _1, key, global), key);
return XPtr<Timeout<Callback> >(new Timeout<Callback>(call));
}
//[[Rcpp::export]]
SEXP Branch__new(const Function& option, std::vector<bool> cont,
const std::vector<Environment>& trj)
{
return XPtr<Branch>(new Branch(option, cont, trj));
}
//[[Rcpp::export]]
SEXP Rollback__new(int amount, int times) {
return XPtr<Rollback>(new Rollback(amount, times));
}
//[[Rcpp::export]]
SEXP Rollback__new_func(int amount, const Function& check) {
return XPtr<Rollback>(new Rollback(amount, 0, check));
}
//[[Rcpp::export]]
SEXP Leave__new(double prob) {
return XPtr<Leave<double> >(new Leave<double>(prob));
}
//[[Rcpp::export]]
SEXP Leave__new_func(const Function& prob) {
return XPtr<Leave<Function> >(new Leave<Function>(prob));
}
//[[Rcpp::export]]
SEXP Clone__new(int n, const std::vector<Environment>& trj) {
return XPtr<Clone<int> >(new Clone<int>(n, trj));
}
//[[Rcpp::export]]
SEXP Clone__new_func(const Function& n, const std::vector<Environment>& trj) {
return XPtr<Clone<Function> >(new Clone<Function>(n, trj));
}
//[[Rcpp::export]]
SEXP Synchronize__new(bool wait, bool terminate) {
return XPtr<Synchronize>(new Synchronize(wait, terminate));
}
//[[Rcpp::export]]
SEXP Batch__new(int n, double timeout, bool permanent, const std::string& name) {
return XPtr<Batch<double> >(new Batch<double>(n, timeout, permanent, name));
}
//[[Rcpp::export]]
SEXP Batch__new_func1(int n, const Function& timeout, bool permanent, const std::string& name) {
return XPtr<Batch<Function> >(new Batch<Function>(n, timeout, permanent, name));
}
//[[Rcpp::export]]
SEXP Batch__new_func2(int n, double timeout, bool permanent,
const std::string& name, const Function& rule)
{
return XPtr<Batch<double> >(new Batch<double>(n, timeout, permanent, name, rule));
}
//[[Rcpp::export]]
SEXP Batch__new_func3(int n, const Function& timeout, bool permanent,
const std::string& name,const Function& rule)
{
return XPtr<Batch<Function> >(new Batch<Function>(n, timeout, permanent, name, rule));
}
//[[Rcpp::export]]
SEXP Separate__new() { return XPtr<Separate>(new Separate()); }
//[[Rcpp::export]]
SEXP RenegeIn__new(double t, const std::vector<Environment>& trj) {
return XPtr<RenegeIn<double> >(new RenegeIn<double>(t, trj));
}
//[[Rcpp::export]]
SEXP RenegeIn__new_func(const Function& t, const std::vector<Environment>& trj) {
return XPtr<RenegeIn<Function> >(new RenegeIn<Function>(t, trj));
}
//[[Rcpp::export]]
SEXP RenegeIf__new(const std::string& signal, const std::vector<Environment>& trj) {
return XPtr<RenegeIf<std::string> >(new RenegeIf<std::string>(signal, trj));
}
//[[Rcpp::export]]
SEXP RenegeIf__new_func(const Function& signal, const std::vector<Environment>& trj) {
return XPtr<RenegeIf<Function> >(new RenegeIf<Function>(signal, trj));
}
//[[Rcpp::export]]
SEXP RenegeAbort__new() { return XPtr<RenegeAbort>(new RenegeAbort()); }
//[[Rcpp::export]]
SEXP Send__new(const std::vector<std::string>& signals, double delay) {
return XPtr<Send<VEC<std::string>, double> >(
new Send<VEC<std::string>, double>(signals, delay));
}
//[[Rcpp::export]]
SEXP Send__new_func1(const Function& signals, double delay) {
return XPtr<Send<Function, double> >(new Send<Function, double>(signals, delay));
}
//[[Rcpp::export]]
SEXP Send__new_func2(const std::vector<std::string>& signals, const Function& delay) {
return XPtr<Send<VEC<std::string>, Function> >(
new Send<VEC<std::string>, Function>(signals, delay));
}
//[[Rcpp::export]]
SEXP Send__new_func3(const Function& signals, const Function& delay) {
return XPtr<Send<Function, Function> >(new Send<Function, Function>(signals, delay));
}
//[[Rcpp::export]]
SEXP Trap__new(const std::vector<std::string>& signals,
const std::vector<Environment>& trj, bool interruptible)
{
return XPtr<Trap<VEC<std::string> > >(
new Trap<VEC<std::string> >(signals, trj, interruptible));
}
//[[Rcpp::export]]
SEXP Trap__new_func(const Function& signals,
const std::vector<Environment>& trj, bool interruptible)
{
return XPtr<Trap<Function> >(new Trap<Function>(signals, trj, interruptible));
}
//[[Rcpp::export]]
SEXP UnTrap__new(const std::vector<std::string>& signals) {
return XPtr<UnTrap<VEC<std::string> > >(new UnTrap<VEC<std::string> >(signals));
}
//[[Rcpp::export]]
SEXP UnTrap__new_func(const Function& signals) {
return XPtr<UnTrap<Function> >(new UnTrap<Function>(signals));
}
//[[Rcpp::export]]
SEXP Wait__new() { return XPtr<Wait>(new Wait()); }
//[[Rcpp::export]]
SEXP Log__new(const std::string& message, int level) {
return XPtr<Log<std::string> >(new Log<std::string>(message, level));
}
//[[Rcpp::export]]
SEXP Log__new_func(const Function& message, int level) {
return XPtr<Log<Function> >(new Log<Function>(message, level));
}
//[[Rcpp::export]]
int activity_get_count_(SEXP activity_) {
XPtr<Activity> activity(activity_);
return activity->count;
}
//[[Rcpp::export]]
void activity_print_(SEXP activity_, int indent, bool verbose) {
XPtr<Activity> activity(activity_);
return activity->print(indent, verbose);
}
//[[Rcpp::export]]
SEXP activity_get_next_(SEXP activity_) {
XPtr<Activity> activity(activity_);
Activity* the_next = activity->get_next();
if (the_next)
return XPtr<Activity>(the_next, false);
return R_NilValue;
}
//[[Rcpp::export]]
SEXP activity_get_prev_(SEXP activity_) {
XPtr<Activity> activity(activity_);
Activity* the_prev = activity->get_prev();
if (the_prev)
return XPtr<Activity>(the_prev, false);
return R_NilValue;
}
//[[Rcpp::export]]
void activity_chain_(SEXP first_, SEXP second_) {
XPtr<Activity> first(first_);
XPtr<Activity> second(second_);
first->set_next(second);
second->set_prev(first);
}
//[[Rcpp::export]]
SEXP activity_clone_(SEXP activity_) {
XPtr<Activity> activity(activity_);
return XPtr<Activity>(activity->clone());
}