To implement entity collections, we need to leverage some more advanced C++ techniques, and we will take a brief break from our conventions so far, implementing multiple classes in a single header file.
Create entity-collection.h in cm-lib/source/data, and in it, add our namespaces as normal and forward declare Entity:
#ifndef ENTITYCOLLECTION_H #define ENTITYCOLLECTION_H
namespace cm { namespace data { class Entity;
}}
#endif
Next, we’ll walk through the necessary classes in turn, each of which must be added in order inside the namespaces.
We first define the root class, which does nothing more than inheriting from QObject and giving us access to all the goodness that it brings, such as object ownership and signals. This is required because classes deriving directly from QObject cannot be templated:
class CMLIBSHARED_EXPORT EntityCollectionObject :...