Hyperspace::REST::ResourceFactory Class Referenceabstract

The base class for Resource factories. More...

Public Member Functions

virtual Resourcecreate (const QByteArray &id)=0
 Creates a resource with a specific ID. More...

Detailed Description

The base class for Resource factories.

ResourceFactory serves the sole purpose of creating Resources dynamically based on their ID. It has to be subclassed for every different Resource type: this is made easier through the macro HYPERSPACE_REST_FACTORY_FOR_RESOURCE, which automatically implements a subclass for a Resource class.

See also

Member Function Documentation

virtual Resource* Hyperspace::REST::ResourceFactory::create ( const QByteArray &  id)
pure virtual

Creates a resource with a specific ID.

Reimplement this function to return a new Resource object depending on its ID. Unless you need to perform specific actions on the Resource after construction or supply your Resource's constructor with additional parameters, you should instead auto-generate your Resource factory via HYPERSPACE_REST_FACTORY_FOR_RESOURCE.

id The ID of the Resource to be created.

No caching or other smart behavior should be done in this class - caching will be handled in the Collection object if needed.
The new Resource object.