haorenhui
2023-10-30 6d6cc10d9e8e242661da7fd655dec155a09d676c
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
Quintiq file version 2.0
#parent: #root
StaticMethod Create (
  LibCal_Calendar owner_i,
  DateTime startTime_i,
  DateTime endTime_i,
  Real capacity_i
) as LibCal_ExplicitTimeInterval
{
  TextBody:
  [*
    interval := construct( LibCal_ExplicitTimeInterval,
                           InitialStart := startTime_i,  // InitialEnd is not stored to save memory
                           Start        := startTime_i,
                           End          := endTime_i,
                           Capacity     := capacity_i );
    
    // Let the Calendar know that its available capacity has changed.
    // Cannot be done from the OnCreate(), because that is apparently triggered before the relation with the Calendar is set.
    // Do registration here and not in the On Create of Notification NotifyCalendar in order to prevent a separate
    // reactive call (i.e. transaction) for each created TimeInterval.
    owner_i.RegisterChangedCapacity();
    
    return owner_i.AddTimeInterval( &interval ).astype( LibCal_ExplicitTimeInterval );
  *]
  InterfaceProperties { Accessibility: 'Module' }
}