The API is managed by a singleton object of type TimetableManager
.
The single instance of this object is created by a call to the static function
TimetableManager::Create()
which creates the global state managed
by the API. The instance returned by TimetableManager::Create()
can be used to call API functions that
depend on global state only, as well as to create new user sessions.
User sessions are represented by objects of type UserSession
.
A new user session can be created using the TimetableManager
::StartSession()
API function, which returns a UserSession
object. A UserSession
object can be used to create course loads associated with that session.
Course loads are represented by objects of type CourseLoad
.
New course loads associated with a user session can be created by calling
NewCourseLoad()
or OpenCourseLoad()
on the UserSession
object. The CourseLoad
object has methods for interacting with the course load, such as selecting
courses and generating timetales. A course load is freed when its CourseLoad
object's destructor is called.
A session ends when its UserSession
object's destructor gets called. The API client should ensure that any CourseLoad
objects associated with the session are destroyed before the UserSession
object is destroyed.
As mentioned above, API functions can be classified based on what type of state they depend on. This is expressed in the following coding conventions:
TimetableManager
.
UserSession
and CourseLoad
(member functions of CourseLoad
can be thought of as depending on "per-course load state").