PStore Class Reference

Detailed Description

The PStore class is an interface to store an heterogeneous collection of PObject into a container (typically a database).

Definition at line 32 of file PStore.h.

#include <PStore.h>

Constructor & Destructor Documentation

◆ PStore() [1/2]

PStore::PStore ( )

Constructs an empty/invalid PStore Object.

To open a PStore, use the Open() factory, for example:

PStore store;
if (PDatabaseStore::Open("papillon.db", store).Ok()) ...

◆ PStore() [2/2]

PStore::PStore ( const PStore other)

Constructs a shared copy of other.

◆ ~PStore()

virtual PStore::~PStore ( )
virtual

Destroys this object.

Member Function Documentation

◆ Add() [1/2]

PResult PStore::Add ( const PObject object,
PGuid entityId 
)

Adds the specified object to the store and retrieve the automatically assigned entity-id (composed of store-id and object-id).

Returns PResult::C_OK if success, another result otherwise.

◆ Add() [2/2]

PResult PStore::Add ( const PObject object)

Adds the specified object to the store.

Returns PResult::C_OK if success, another result otherwise.

◆ AddListener()

void PStore::AddListener ( const PStoreEventListener eventListener)

Adds the specified listener.

It will be notified each time a change occurs in this store.

◆ Close()

void PStore::Close ( )

Closes this store, freeing any resources acquired.

◆ Exists()

bool PStore::Exists ( const PGuid entityId) const

Returns true if this store contains the specified entity, false otherwise.

◆ Get()

PResult PStore::Get ( const PGuid entityId,
PObject object 
) const

Gets an object specified by its guid (entity id).

Returns PResult::C_OK if success (the object exist and cast succeeded), another result otherwise.

◆ GetAll()

PResult PStore::GetAll ( EType  type,
PList listObjects 
) const

Gets all objects of the specified type from this store and fill the specified list; the list is first cleared.

Returns PResult::C_OK if success (the object exist and cast succeeded), another result otherwise.

◆ GetEntity()

PResult PStore::GetEntity ( const PGuid entityId,
PEntity entity 
) const

Gets an entity specified by its guid (entity id).

Returns PResult::C_OK if success, another result otherwise.

◆ GetStoreId()

papillon::uint64 PStore::GetStoreId ( ) const

Returns the store id (unique for each store) associated with this PStore.

◆ GetTimestampLatestUpdate()

PDateTime PStore::GetTimestampLatestUpdate ( ) const

Returns the timestamp of the latest update of this store.

For example, if you are using a memory cache for a PStore which relies on a database, this method returns the last time where database has been reloaded in memory.

◆ IsEmpty()

bool PStore::IsEmpty ( ) const

Returns true if this store is empty, false otherwise.

◆ IsValid()

bool PStore::IsValid ( ) const

Returns true if this store is valid and is ready for storage, false otherwise.

◆ Iterator()

PStoreIterator PStore::Iterator ( ) const

Returns an iterator on this store.

◆ NotifyListeners()

void PStore::NotifyListeners ( )
protected

◆ operator=()

PStore& PStore::operator= ( const PStore other)

Performs a shared copy of other to this object.

◆ Remove()

PResult PStore::Remove ( PGuid entityId)

Remove the object specified by its guid (entity id).

Returns PResult::C_OK if success, another result otherwise.

◆ RemoveAllObjects()

PResult PStore::RemoveAllObjects ( )

Removes all Papillon objects in this PStore.

◆ RemoveListener()

PResult PStore::RemoveListener ( const PStoreEventListener eventListener)

Removes the specified listener.

Returns PResult::C_OK if success, another result otherwise.

◆ SetDeleteFlag()

PResult PStore::SetDeleteFlag ( PGuid entityId,
bool  enabled 
)

Updates the "deleteFlag" status of an entity.

Use true to set the delete flag or false to unset it. Returns PResult::C_OK if success, another result otherwise.

◆ SetTimestampLatestUpdate()

void PStore::SetTimestampLatestUpdate ( const PDateTime timestamp)

Sets the timestamp of the latest update of this store.

For example, if you are using a memory cache for a PStore which relies on a database, then this method should be called each time the database is reloaded in memory.

◆ Size() [1/2]

papillon::int32 PStore::Size ( ) const

Returns the number of papillon objects stored in this container.

Returns -1 if failure.

◆ Size() [2/2]

papillon::int32 PStore::Size ( EType  type) const

Returns the number of papillon objects of the specified type stored in this container.

Returns -1 if failure.

◆ Update()

PResult PStore::Update ( const PGuid entityId,
const PObject object 
)

Updates the specified object.

Returns PResult::C_OK if success, another result otherwise.