Hyperspace::REST::FixedCachedCollection Class Reference

Convenience RESTful-compliant Collection based on a cached set of resources. More...

Inheritance diagram for Hyperspace::REST::FixedCachedCollection:

Public Member Functions

 FixedCachedCollection (const QByteArray &path, ResourceFactory *factory, const QList< QByteArray > &idList=QList< QByteArray >(), QObject *parent=Q_NULLPTR)
 
void setIdList (const QList< QByteArray > &idList)
 
void setCanDelete (bool canDelete)
 
void setCanPost (bool canPost)
 
void setCanPut (bool canPut)
 
QStringList resources () const
 
- Public Member Functions inherited from Hyperspace::REST::KeyValueCollection
 KeyValueCollection (const QByteArray &path, ResourceFactory *factory)
 
- Public Member Functions inherited from Hyperspace::REST::Collection
 Collection (const QByteArray &path, ResourceFactory *factory)
 
QByteArray path () const
 
void deleteResource (const QByteArray &waveId, const QByteArray &resourceId, const ByteArrayHash &attributes, const QByteArray &payload)
 
void getResource (const QByteArray &waveId, const QByteArray &resourceId, const ByteArrayHash &attributes, const QByteArray &payload)
 
void postResource (const QByteArray &waveId, const QByteArray &resourceId, const ByteArrayHash &attributes, const QByteArray &payload)
 
void putResource (const QByteArray &waveId, const QByteArray &resourceId, const ByteArrayHash &attributes, const QByteArray &payload)
 
void head (const QByteArray &waveId, const ByteArrayHash &attributes, const QByteArray &payload) Q_DECL_OVERRIDE
 Sends back a BadRequest Rebound by default. More...
 

Protected Member Functions

virtual void keyValuePut (const QByteArray &waveId, const ByteArrayHash &attributes, const QVariantMap &data) Q_DECL_OVERRIDE
 Implement Wave PUT method with a Key/Value pair. More...
 
virtual void keyValuePost (const QByteArray &waveId, const ByteArrayHash &attributes, const QVariantMap &data) Q_DECL_OVERRIDE
 Implement Wave POST method with a Key/Value pair. More...
 
virtual void keyValueDelete (const QByteArray &waveId, const ByteArrayHash &attributes, const QVariantMap &data) Q_DECL_OVERRIDE
 Implement Wave DELETE method with a Key/Value pair. More...
 
virtual ResourceloadResource (const QByteArray &id) Q_DECL_OVERRIDE Q_DECL_FINAL
 
- Protected Member Functions inherited from Hyperspace::REST::PropertyCollection
virtual void keyValueGet (const QByteArray &waveId, const ByteArrayHash &attributes, const QVariantMap &data) Q_DECL_OVERRIDE
 Implement Wave GET method with a Key/Value pair. More...
 
- Protected Member Functions inherited from Hyperspace::REST::KeyValueCollection
void sendKeyValueRebound (const KeyValueRebound &rebound)
 Sends a rebound with a Key/Value payload. More...
 
virtual void get (const QByteArray &waveId, const ByteArrayHash &attributes, const QByteArray &payload) Q_DECL_OVERRIDE Q_DECL_FINAL
 Implement Wave GET method. More...
 
virtual void httpDelete (const QByteArray &waveId, const ByteArrayHash &attributes, const QByteArray &payload) Q_DECL_OVERRIDE Q_DECL_FINAL
 Implement Wave DELETE method. More...
 
virtual void post (const QByteArray &waveId, const ByteArrayHash &attributes, const QByteArray &payload) Q_DECL_OVERRIDE Q_DECL_FINAL
 Implement Wave POST method. More...
 
virtual void put (const QByteArray &waveId, const ByteArrayHash &attributes, const QByteArray &payload) Q_DECL_OVERRIDE Q_DECL_FINAL
 Implement Wave PUT method. More...
 
- Protected Member Functions inherited from Hyperspace::REST::Collection
ResourceFactoryfactory () const
 

Additional Inherited Members

- Protected Slots inherited from Hyperspace::AbstractWaveTarget
void sendRebound (const Hyperspace::Rebound &rebound)
 Send a rebound for a received wave. More...
 

Detailed Description

Convenience RESTful-compliant Collection based on a cached set of resources.

FixedCachedCollection is arguably the most commonly used Collection in Hyperspace. It automatically loads and caches resources from its Factory, and is completely self-sufficient. In addition, it is also a PropertyCollection, so it can provide additional information beyond its resources list. To learn more about the relationship between Hyperspace and QObject, please read Hyperspace and QObject.

FixedCachedCollection works on the assumption that a static ID list exists. It can be supplied and modified at any time during its lifecycle, and it lists all available resources on it.

FixedCachedCollection implements full RESTful semantics, so it supports DELETE, POST and PUT for collections. This behavior can be changed/limited.

See also
Hyperspace::REST::PropertyCollection

Constructor & Destructor Documentation

Hyperspace::REST::FixedCachedCollection::FixedCachedCollection ( const QByteArray &  path,
ResourceFactory factory,
const QList< QByteArray > &  idList = QList<QByteArray>(),
QObject *  parent = Q_NULLPTR 
)
explicit

Constructs a FixedCachedCollection.

path The path to this collection, relative to the Gate's base target path. factory The ResourceFactory for this collection. idList The initial list of IDs for this collection. parent QObject's parent.

Member Function Documentation

void Hyperspace::REST::FixedCachedCollection::setIdList ( const QList< QByteArray > &  idList)

Sets the ID list for this collection

idList The list of resource IDs available on this collection.

void Hyperspace::REST::FixedCachedCollection::setCanDelete ( bool  canDelete)

Sets whether it is possible to call DELETE on this collection.

canDelete Whether is is possible to call DELETE on this collection.

void Hyperspace::REST::FixedCachedCollection::setCanPost ( bool  canPost)

Sets whether it is possible to call POST on this collection.

canDelete Whether is is possible to call POST on this collection.

void Hyperspace::REST::FixedCachedCollection::setCanPut ( bool  canPut)

Sets whether it is possible to call PUT on this collection.

canDelete Whether is is possible to call PUT on this collection.

QStringList Hyperspace::REST::FixedCachedCollection::resources ( ) const
Returns
ID list of available resources.
void Hyperspace::REST::FixedCachedCollection::keyValuePut ( const QByteArray &  waveId,
const ByteArrayHash &  attributes,
const QVariantMap &  data 
)
protectedvirtual

Implement Wave PUT method with a Key/Value pair.

Reimplement this method to act when a PUT Wave is sent.

waveId The internal waveId. Must be used to construct the Rebound. attributes The wave's attributes. data The payload as a Key/Value map.

Reimplemented from Hyperspace::REST::PropertyCollection.

void Hyperspace::REST::FixedCachedCollection::keyValuePost ( const QByteArray &  waveId,
const ByteArrayHash &  attributes,
const QVariantMap &  data 
)
protectedvirtual

Implement Wave POST method with a Key/Value pair.

Reimplement this method to act when a POST Wave is sent.

waveId The internal waveId. Must be used to construct the Rebound. attributes The wave's attributes. data The payload as a Key/Value map.

Reimplemented from Hyperspace::REST::PropertyCollection.

void Hyperspace::REST::FixedCachedCollection::keyValueDelete ( const QByteArray &  waveId,
const ByteArrayHash &  attributes,
const QVariantMap &  data 
)
protectedvirtual

Implement Wave DELETE method with a Key/Value pair.

Reimplement this method to act when a DELETE Wave is sent.

waveId The internal waveId. Must be used to construct the Rebound. attributes The wave's attributes. data The payload as a Key/Value map.

Implements Hyperspace::REST::KeyValueCollection.

Resource * Hyperspace::REST::FixedCachedCollection::loadResource ( const QByteArray &  id)
protectedvirtual

Loads a resource from the Factory and returns it.

Must be reimplemented by Collection implementations, mainly due to different caching policies.

id The ID of the Resource to be loaded.

Returns
The loaded resource, or a null pointer if the resource could not be loaded.

Implements Hyperspace::REST::Collection.