ACF $AcfVersion:0$
CObjectQueueComp.h
Go to the documentation of this file.
1// SPDX-License-Identifier: LGPL-2.1-or-later OR GPL-2.0-or-later OR GPL-3.0-or-later OR LicenseRef-ACF-Commercial
2#pragma once
3
4
5// Qt includes
6#include <QtCore/QList>
7
8// ACF includes
11#include <ibase/IObjectQueue.h>
12
13
14namespace ibase
15{
16
17
23 virtual public IObjectQueue,
24 virtual public iser::ISerializable
25{
26public:
28
29 I_BEGIN_COMPONENT(CObjectQueueComp);
30 I_REGISTER_INTERFACE(IObjectQueue);
31 I_REGISTER_INTERFACE(iser::ISerializable);
32 I_ASSIGN(m_objectFactoryFactPtr, "ObjectFactory", "Object factory used to create queue instancies", true, "ObjectFactory");
33 I_ASSIGN(m_maxReserveObjectsAttrPtr, "MaxReserveObjects", "Maximal number of reserve objects used to avoid cretion and removing of objects from heap", true, 10);
34 I_END_COMPONENT;
35
36 // reimplemented (ibase::IObjectQueue)
37 virtual int GetObjectsCount(const QByteArray* typeIdPtr = NULL) const override;
38 virtual void ClearQueue() override;
39 virtual istd::IChangeable* CreateFrontObject(int offsetPos = 0, const QByteArray* typeIdPtr = NULL) override;
40 virtual istd::IChangeable* CreateBackObject(int offsetPos = 0, const QByteArray* typeIdPtr = NULL) override;
41 virtual void RemoveFrontObject(int offsetPos = 0, const QByteArray* typeIdPtr = NULL) override;
42 virtual void RemoveBackObject(int offsetPos = 0, const QByteArray* typeIdPtr = NULL) override;
43 virtual istd::IChangeable* GetFrontObject(int offsetPos = 0, const QByteArray* typeIdPtr = NULL) const override;
44 virtual istd::IChangeable* GetBackObject(int offsetPos = 0, const QByteArray* typeIdPtr = NULL) const override;
45 virtual void SelectObjects(
46 ObjectList& result,
47 bool doAppend = false,
48 int offsetPos = 0,
49 const QByteArray* typeIdPtr = NULL) const override;
50 virtual istd::IChangeable* PopFrontObject(int offsetPos = 0, const QByteArray* typeIdPtr = NULL) override;
51 virtual istd::IChangeable* PopBackObject(int offsetPos = 0, const QByteArray* typeIdPtr = NULL) override;
52
53 // reimplemented (iser::ISerializable)
54 virtual bool Serialize(iser::IArchive& archive) override;
55
56protected:
59
60 // reimplemented (icomp::CComponentBase)
61 virtual void OnComponentDestroyed() override;
62
63private:
64 I_FACT(istd::IChangeable, m_objectFactoryFactPtr);
65 I_ATTR(int, m_maxReserveObjectsAttrPtr);
66
67 typedef QList<istd::IChangeable*> ObjectQueue;
68
69 ObjectQueue m_objectsQueue;
70 ObjectQueue m_objectsReserve;
71};
72
73
74} // namespace ibase
75
76
77
78
Implementation of ibase::IObjectQueue including some smart optimizations.
virtual istd::IChangeable * CreateBackObject(int offsetPos=0, const QByteArray *typeIdPtr=NULL) override
Create object at the end of this queue.
istd::IChangeable * CreateObject()
virtual istd::IChangeable * PopBackObject(int offsetPos=0, const QByteArray *typeIdPtr=NULL) override
Get object at the end of queue and remove it from queue.
icomp::CComponentBase BaseClass
virtual void ClearQueue() override
Remove all objects from queue.
virtual int GetObjectsCount(const QByteArray *typeIdPtr=NULL) const override
Get number of objects in this queue.
virtual bool Serialize(iser::IArchive &archive) override
Load or store state of this object as a archive stream.
virtual istd::IChangeable * GetBackObject(int offsetPos=0, const QByteArray *typeIdPtr=NULL) const override
Get object at the end of queue.
virtual void OnComponentDestroyed() override
virtual istd::IChangeable * CreateFrontObject(int offsetPos=0, const QByteArray *typeIdPtr=NULL) override
Create object at the front of this queue.
virtual istd::IChangeable * PopFrontObject(int offsetPos=0, const QByteArray *typeIdPtr=NULL) override
Get object at the front of queue and remove it from queue.
virtual istd::IChangeable * GetFrontObject(int offsetPos=0, const QByteArray *typeIdPtr=NULL) const override
Get object at the front of queue.
virtual void RemoveBackObject(int offsetPos=0, const QByteArray *typeIdPtr=NULL) override
Remove object at the end of this queue.
virtual void SelectObjects(ObjectList &result, bool doAppend=false, int offsetPos=0, const QByteArray *typeIdPtr=NULL) const override
Find set of objects.
virtual void RemoveFrontObject(int offsetPos=0, const QByteArray *typeIdPtr=NULL) override
Remove object at the front of this queue.
Interface allowing to manage queue of some objects.
QVector< istd::IChangeable * > ObjectList
Base class for component implementation.
Represents an input/output persistence archive for object serialization.
Definition IArchive.h:164
Common class for all classes which objects can be archived or restored from archive.
Common interface for data model objects, which can be changed.
Definition IChangeable.h:28
#define NULL
Definition istd.h:74
This namespace contains basic implementations of standard primitives on the component level.