Optional support for multiple inheritance

The NIH Class Library can be compiled to support Multiple Inheritance (MI) by defining the preprocessor symbol MI. All classes linked together in a program must all have been compiled with the same MI option setting. The major effect of this switch is that all classes derived from Object specify it as a virtual base class. Since C++ does not permit a pointer to a virtual base class to be cast down to a pointer to a derived class, the new DECLARE_MEMBERS macro defines an overloaded family of static member functions named castDown() that can perform this conversion. (If MI is not enabled, castDown() becomes an ordinary pointer cast.)

The castDown() functions all call the function _castDown() to perform the pointer conversion. If a class has only a single base class, it uses the DEFINE_CLASS and DEFINE_ABSTRACT_CLASS preprocessor macros as before, and these generate an implementation of _castDown() suitable for the single inheritance case. If a class has multiple base classes, it uses the new DEFINE_CLASS_MI and DEFINE_ABSTRACT_CLASS_MI macros, which do not generate _castDown()—the class provider must supply a definition as described in Template_c.

All readFrom() constructors must specify the readFrom() constructor for the virtual base class Object in their initialization lists when MI is enabled. See Template_h for details.

If you use virtual base classes in conjunction with the NIH Class Library, you must take care when implementing the deepCopy() and storeOn() operations that a virtual base class's member variables are only deepened or stored once. The library provides the functions deepenVBase() and storeVBaseOn() to help with this. Call deepenVBase() instead of deepenShallowCopy() to deepen the member variables of a virtual base class, and call storeVBaseOn() instead of storer() to store the member variables of a virtual base class.