BOOST_OPENMETHOD_CLASSES

Register classes.

Synopsis

Declared in <boost/openmethod/macros.hpp>

#define BOOST_OPENMETHOD_CLASSES(…​)

Description

Registers classes in a registry.

This macro is a wrapper around boost::openmethod::use_classes; see its documentation for more details.

The default registry is the value of BOOST_OPENMETHOD_DEFAULT_REGISTRY when <boost/openmethod/core.hpp> is included. Subsequently changing it has no retroactive effect.

Examples

A class and its direct bases must appear together in one call. Take Cat and Dog, both derived from Animal, and Bulldog, derived from Dog. A single call listing all of them describes the hierarchy:

BOOST_OPENMETHOD_CLASSES(Animal, Cat, Dog, Bulldog);

Several calls do just as well, as long as every class appears alongside its direct bases. Dog is listed twice here, and that is what attaches Bulldog to it:

BOOST_OPENMETHOD_CLASSES(Animal, Cat, Dog);
BOOST_OPENMETHOD_CLASSES(Dog, Bulldog);

Registering the classes one per call describes no inheritance at all, and boost::openmethod::initialize reports a boost::openmethod::missing_base error:

BOOST_OPENMETHOD_CLASSES(Animal);
BOOST_OPENMETHOD_CLASSES(Cat);
BOOST_OPENMETHOD_CLASSES(Dog); // initialize reports missing_base

Listing a class with an ancestor in place of its direct base is the more dangerous mistake, because nothing reports it. Below, Bulldog is recorded as derived from Animal; an overrider for Dog no longer applies to it, so a call passing a Bulldog quietly selects the overrider for Animal:

BOOST_OPENMETHOD_CLASSES(Animal, Cat, Dog);
BOOST_OPENMETHOD_CLASSES(Animal, Bulldog);
// OpenMethod believes that Bulldog derives from Animal, not Dog

Parameters

Name

Description

...

The classes to register, optionally followed by the registry.

See Also