scalendar-1.2.0: A library for handling calendars and resource availability over time.

Safe HaskellSafe
LanguageHaskell2010

Time.SCalendar.Operations

Synopsis

Documentation

augmentCalendar Source #

Arguments

:: SCalendar

SCalendar to be augmented.

-> Int

Number of times by which the SCalendar will be augmented.

-> Maybe SCalendar 

Given an SCalendar of size 2^n, this function increases its size k times, that is, 2^(n+k). The new SCalendar is properly updated up to its root so that it will render the same results as the previous one. For example, given an SCalendar c of size 2^5=32, 'augmentCalendar c 3' would produce a new SCalendar of size 2^(5+3)=256.

isQuantityAvailable Source #

Arguments

:: Int

Quantity of resources.

-> TimePeriod

TimePeriod over which we want to determine the availability of the quantity.

-> SCalendar

SCalendar over which we want to determine the availability of the quantity in a Given TimePeriod.

-> Bool 

Given a quantity, this function determines if it is available in a TimePeriod for a specific SCalendar. Thus, it does not take into account the particular resources whose availability wants to be determined: it is only concerned with the availabilty of a quantity in a specific SCalendar.

isReservAvailable :: Reservation -> SCalendar -> Bool Source #

Given a Reservation, this function determines if it is available in a SCalendar. A Reservation is the product of a set of identifiers which point to reservable resources and a TimePeriod over which those resources are to be reserved. Thus, this function checks if that particular set of resources is available for a TimePeriod in the given SCalendar.

reservePeriod' :: Reservation -> Calendar -> Maybe Calendar Source #

This function introduces a new Reservation in a Calendar. Note that since no availability check is performed before introducing the Reservation, here we use a plain Calendar. Thus this function is useful to introduce Reservations without any constraint, but that's why it must be used carefully since information can be lost due to the usage of the union set-operation to update the Q and QN sets in the Calendar.

reservePeriod :: Reservation -> SCalendar -> Maybe SCalendar Source #

This function introduces a new Reservation in a SCalendar applying an availability check. This means that if the reservation conflicts with others already made in the SCalendar, it will no be introduced. Thus this function takes into account the set of reservable identifiers for the SCalendar to calculate the subset of available ones and introduce the Reservation if possible.

reserveManyPeriods :: [Reservation] -> SCalendar -> Maybe SCalendar Source #

This function is like reservePeriod but introduces several Reservations at once. It is important to note that if a Reservation in the list conflicts with others already made in the SCalendar, it will be excluded. Thus the order of the Reservations in the list matters, since if one Reservation passes the availability check but the next one does not, then latter will be excluded.

reserveManyPeriods' :: [Reservation] -> Calendar -> Maybe Calendar Source #

This function is like reservePeriod' but adds a list of Reservations without any availabilty check.

cancelPeriod :: Cancellation -> Calendar -> Maybe Calendar Source #

This function removes reserved identifiers in a Calendar according to the Set of identifiers and TimePeriod specified in the Cancellation. Thus a Cancellation only affects the nodes whose upper or lower bounds are included in the TimePeriod of the Cancellation.

cancelManyPeriods :: [Cancellation] -> Calendar -> Maybe Calendar Source #

This is like cancelPeriod but performs several Cancellations at once.

periodReport :: TimePeriod -> SCalendar -> Maybe Report Source #

Given a TimePeriod and a SCalendar, this function returns a Report which summarizes important data about the reserved and available identifiers in that SCalendar.