Skip to content

T12270: create an inheritance hierarchy of private types

Glen Ditchfield requested to merge gditchfield/kcalendarcore:t12270 into master

I think this is ready for proper review and testing. I've tried to minimized the differences from master; there should be some refactoring later.

Default Constructors

Before, the Event, Incidence, and IncidenceBase constructors called the corresponding *Private constructors. Now, inheritance causes all the private constructors to run when Event() calls EventPrivate(). The private constructors initialize the same members as before, and the incidence constructors execute the same statements; the change in interleaving of the constructor bodies shouldn't matter.

Similar reasoning applies to Todo(), Journal(), and FreeBusy().

Assignment

Before, Event.assign() called EventPrivate.operator=() to copy its members. Now, EventPrivate.operator=() would also copy IncidencePrivate and IncidenceBasePrivate members, so Event.assign() explicitly copies the private members. Other classes have an init() function that only copy the necessary members.

Copy Constructors

As was the case with the default constructors, the private constructors are all called by the Event constructor instead of individually by the incidence class constructors, so the interleaving of the constructor bodies changes, but that shouldn't matter.

Instance Constructors

Event(const Incidence &other) is very much like a copy constructor, except that the EventPrivate members must be initialized to default values. Therefore the EventPrivate constructor should call IncidencePrivate(const IncidencePrivate &p). However it can't do so directly because the type system blocks access to other's private member. I worked around this by adding IncidencePrivate(const Incidence &other), which can access the member.

@winterz @vkrause

Edited by Glen Ditchfield

Merge request reports