ifc-schedule 0.3.0

IFC scheduling: IfcTask/IfcWorkSchedule, sequencing, 4D linkage.
Documentation
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
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
//! Constructors and setters for the schedule drafts.
//!
//! The drafts are `#[non_exhaustive]` so they can grow a field when a
//! release needs one (#214) without breaking callers: build one with `new`
//! and the setters, each named after the field it sets, as
//! `ifc-resource`'s drafts are built.

use ifc_model::EntityId;

use super::procedure::ProcedureDraft;
use super::timing::TaskTimeDraft;
use super::{
    DateTimeValue, EventDraft, EventTimeDraft, RecurrenceDraft, TaskDraft, WorkControlDraft,
};

impl<'a> TaskDraft<'a> {
    /// Starts a draft for an `IfcTask` with its `GlobalId` and every optional
    /// attribute unset, `IsMilestone` false.
    #[must_use]
    pub fn new(global_id: &'a str) -> Self {
        Self {
            global_id,
            ..Self::default()
        }
    }

    /// Sets `IfcRoot.Name`.
    #[must_use]
    pub fn name(mut self, value: &'a str) -> Self {
        self.name = Some(value);
        self
    }

    /// Sets `IfcRoot.Description`.
    #[must_use]
    pub fn description(mut self, value: &'a str) -> Self {
        self.description = Some(value);
        self
    }

    /// Sets `IfcProcess.Identification` (IFC2X3 `TaskId`).
    #[must_use]
    pub fn identification(mut self, value: &'a str) -> Self {
        self.identification = Some(value);
        self
    }

    /// Sets `IfcProcess.LongDescription`.
    #[must_use]
    pub fn long_description(mut self, value: &'a str) -> Self {
        self.long_description = Some(value);
        self
    }

    /// Sets `IfcTask.Status`.
    #[must_use]
    pub fn status(mut self, value: &'a str) -> Self {
        self.status = Some(value);
        self
    }

    /// Sets `IfcTask.WorkMethod`.
    #[must_use]
    pub fn work_method(mut self, value: &'a str) -> Self {
        self.work_method = Some(value);
        self
    }

    /// Sets `IfcTask.IsMilestone`.
    #[must_use]
    pub fn is_milestone(mut self, value: bool) -> Self {
        self.is_milestone = value;
        self
    }

    /// Sets `IfcTask.Priority`, an integer in `0..=100`.
    #[must_use]
    pub fn priority(mut self, value: i64) -> Self {
        self.priority = Some(value);
        self
    }

    /// Sets `IfcTask.TaskTime`, an `IfcTaskTime` reference.
    #[must_use]
    pub fn task_time(mut self, value: EntityId) -> Self {
        self.task_time = Some(value);
        self
    }

    /// Sets `IfcTask.PredefinedType`.
    #[must_use]
    pub fn predefined_type(mut self, value: &'a str) -> Self {
        self.predefined_type = Some(value);
        self
    }
}

impl<'a> WorkControlDraft<'a> {
    /// Starts a draft for an `IfcWorkPlan` or `IfcWorkSchedule` with its
    /// required `GlobalId`, `CreationDate` and `StartTime`; each date is
    /// ISO 8601 text (`&str`, IFC4 and IFC4X3) or an IFC2X3 record form.
    #[must_use]
    pub fn new(
        global_id: &'a str,
        creation_date: impl Into<DateTimeValue<'a>>,
        start_time: impl Into<DateTimeValue<'a>>,
    ) -> Self {
        Self {
            global_id,
            creation_date: creation_date.into(),
            start_time: start_time.into(),
            ..Self::default()
        }
    }

    /// Sets `IfcRoot.Name`.
    #[must_use]
    pub fn name(mut self, value: &'a str) -> Self {
        self.name = Some(value);
        self
    }

    /// Sets `IfcRoot.Description`.
    #[must_use]
    pub fn description(mut self, value: &'a str) -> Self {
        self.description = Some(value);
        self
    }

    /// Sets `IfcWorkControl.Identification` (IFC2X3 `Identifier`).
    #[must_use]
    pub fn identification(mut self, value: &'a str) -> Self {
        self.identification = Some(value);
        self
    }

    /// Sets `IfcWorkControl.Purpose`.
    #[must_use]
    pub fn purpose(mut self, value: &'a str) -> Self {
        self.purpose = Some(value);
        self
    }

    /// Sets `IfcWorkControl.Duration`, an ISO 8601 duration.
    #[must_use]
    pub fn duration(mut self, value: &'a str) -> Self {
        self.duration = Some(value);
        self
    }

    /// Sets `IfcWorkControl.TotalFloat`, an ISO 8601 duration.
    #[must_use]
    pub fn total_float(mut self, value: &'a str) -> Self {
        self.total_float = Some(value);
        self
    }

    /// Sets `IfcWorkControl.FinishTime`.
    #[must_use]
    pub fn finish_time(mut self, value: impl Into<DateTimeValue<'a>>) -> Self {
        self.finish_time = Some(value.into());
        self
    }

    /// Sets `PredefinedType`.
    #[must_use]
    pub fn predefined_type(mut self, value: &'a str) -> Self {
        self.predefined_type = Some(value);
        self
    }
}

impl<'a> EventDraft<'a> {
    /// Starts a draft for an `IfcEvent` with its `GlobalId` and every optional
    /// attribute unset.
    #[must_use]
    pub fn new(global_id: &'a str) -> Self {
        Self {
            global_id,
            ..Self::default()
        }
    }

    /// Sets `IfcRoot.Name`.
    #[must_use]
    pub fn name(mut self, value: &'a str) -> Self {
        self.name = Some(value);
        self
    }

    /// Sets `IfcObject.ObjectType`.
    #[must_use]
    pub fn object_type(mut self, value: &'a str) -> Self {
        self.object_type = Some(value);
        self
    }

    /// Sets `IfcProcess.Identification`.
    #[must_use]
    pub fn identification(mut self, value: &'a str) -> Self {
        self.identification = Some(value);
        self
    }

    /// Sets `IfcProcess.LongDescription`.
    #[must_use]
    pub fn long_description(mut self, value: &'a str) -> Self {
        self.long_description = Some(value);
        self
    }

    /// Sets `IfcEvent.PredefinedType`.
    #[must_use]
    pub fn predefined_type(mut self, value: &'a str) -> Self {
        self.predefined_type = Some(value);
        self
    }

    /// Sets `IfcEvent.EventTriggerType`.
    #[must_use]
    pub fn trigger_type(mut self, value: &'a str) -> Self {
        self.trigger_type = Some(value);
        self
    }

    /// Sets `IfcEvent.UserDefinedEventTriggerType`.
    #[must_use]
    pub fn user_defined_trigger_type(mut self, value: &'a str) -> Self {
        self.user_defined_trigger_type = Some(value);
        self
    }

    /// Sets `IfcEvent.EventOccurenceTime`, an `IfcEventTime` reference.
    #[must_use]
    pub fn occurence_time(mut self, value: EntityId) -> Self {
        self.occurence_time = Some(value);
        self
    }
}

impl<'a> EventTimeDraft<'a> {
    /// Starts a draft for an `IfcEventTime` with every attribute unset.
    #[must_use]
    pub fn new() -> Self {
        Self::default()
    }

    /// Sets `IfcSchedulingTime.Name`.
    #[must_use]
    pub fn name(mut self, value: &'a str) -> Self {
        self.name = Some(value);
        self
    }

    /// Sets `IfcEventTime.ActualDate`.
    #[must_use]
    pub fn actual(mut self, value: &'a str) -> Self {
        self.actual = Some(value);
        self
    }

    /// Sets `IfcEventTime.EarlyDate`.
    #[must_use]
    pub fn early(mut self, value: &'a str) -> Self {
        self.early = Some(value);
        self
    }

    /// Sets `IfcEventTime.LateDate`.
    #[must_use]
    pub fn late(mut self, value: &'a str) -> Self {
        self.late = Some(value);
        self
    }

    /// Sets `IfcEventTime.ScheduleDate`.
    #[must_use]
    pub fn schedule(mut self, value: &'a str) -> Self {
        self.schedule = Some(value);
        self
    }
}

impl<'a> RecurrenceDraft<'a> {
    /// Starts a draft for an `IfcRecurrencePattern` with its required
    /// `RecurrenceType` and every component unset.
    #[must_use]
    pub fn new(recurrence_type: &'a str) -> Self {
        Self {
            recurrence_type,
            ..Self::default()
        }
    }

    /// Sets `DayComponent`, days of the month in `1..=31`.
    #[must_use]
    pub fn days(mut self, value: Vec<i64>) -> Self {
        self.days = value;
        self
    }

    /// Sets `WeekdayComponent`, 1 = Monday through 7 = Sunday.
    #[must_use]
    pub fn weekdays(mut self, value: Vec<i64>) -> Self {
        self.weekdays = value;
        self
    }

    /// Sets `MonthComponent`, 1 = January through 12 = December.
    #[must_use]
    pub fn months(mut self, value: Vec<i64>) -> Self {
        self.months = value;
        self
    }

    /// Sets `Position`.
    #[must_use]
    pub fn position(mut self, value: i64) -> Self {
        self.position = Some(value);
        self
    }

    /// Sets `Interval`, a positive count.
    #[must_use]
    pub fn interval(mut self, value: i64) -> Self {
        self.interval = Some(value);
        self
    }

    /// Sets `Occurrences`, a positive count.
    #[must_use]
    pub fn occurrences(mut self, value: i64) -> Self {
        self.occurrences = Some(value);
        self
    }
}

impl<'a> ProcedureDraft<'a> {
    /// Starts a draft for an `IfcProcedure` with its `GlobalId` and every optional
    /// attribute unset.
    #[must_use]
    pub fn new(global_id: &'a str) -> Self {
        Self {
            global_id,
            ..Self::default()
        }
    }

    /// Sets `Name`, required by `HasName`.
    #[must_use]
    pub fn name(mut self, value: &'a str) -> Self {
        self.name = Some(value);
        self
    }

    /// Sets `Description`.
    #[must_use]
    pub fn description(mut self, value: &'a str) -> Self {
        self.description = Some(value);
        self
    }

    /// Sets `ObjectType`.
    #[must_use]
    pub fn object_type(mut self, value: &'a str) -> Self {
        self.object_type = Some(value);
        self
    }

    /// Sets `Identification` (IFC2X3 `ProcedureID`).
    #[must_use]
    pub fn identification(mut self, value: &'a str) -> Self {
        self.identification = Some(value);
        self
    }

    /// Sets `LongDescription`.
    #[must_use]
    pub fn long_description(mut self, value: &'a str) -> Self {
        self.long_description = Some(value);
        self
    }

    /// Sets `PredefinedType` (IFC2X3 `ProcedureType`).
    #[must_use]
    pub fn predefined_type(mut self, value: &'a str) -> Self {
        self.predefined_type = Some(value);
        self
    }

    /// Sets IFC2X3 `UserDefinedProcedureType`.
    #[must_use]
    pub fn user_defined_procedure_type(mut self, value: &'a str) -> Self {
        self.user_defined_procedure_type = Some(value);
        self
    }
}

impl<'a> TaskTimeDraft<'a> {
    /// Starts a draft for an `IfcTaskTime` with every attribute unset.
    #[must_use]
    pub fn new() -> Self {
        Self::default()
    }

    /// Sets `Name`.
    #[must_use]
    pub fn name(mut self, value: &'a str) -> Self {
        self.name = Some(value);
        self
    }

    /// Sets `DurationType`.
    #[must_use]
    pub fn duration_type(mut self, value: &'a str) -> Self {
        self.duration_type = Some(value);
        self
    }

    /// Sets `ScheduleDuration`, an ISO 8601 duration.
    #[must_use]
    pub fn schedule_duration(mut self, value: &'a str) -> Self {
        self.schedule_duration = Some(value);
        self
    }

    /// Sets `ScheduleStart`.
    #[must_use]
    pub fn schedule_start(mut self, value: &'a str) -> Self {
        self.schedule_start = Some(value);
        self
    }

    /// Sets `ScheduleFinish`.
    #[must_use]
    pub fn schedule_finish(mut self, value: &'a str) -> Self {
        self.schedule_finish = Some(value);
        self
    }

    /// Sets `ActualStart`.
    #[must_use]
    pub fn actual_start(mut self, value: &'a str) -> Self {
        self.actual_start = Some(value);
        self
    }

    /// Sets `ActualFinish`.
    #[must_use]
    pub fn actual_finish(mut self, value: &'a str) -> Self {
        self.actual_finish = Some(value);
        self
    }

    /// Sets `IsCritical`.
    #[must_use]
    pub fn is_critical(mut self, value: bool) -> Self {
        self.is_critical = Some(value);
        self
    }

    /// Sets `Completion`, a percentage in `0..=100`.
    #[must_use]
    pub fn completion(mut self, value: f64) -> Self {
        self.completion = Some(value);
        self
    }
}