CObjectQueueComp.h
Go to the documentation of this file.
1 #ifndef ibase_CObjectQueueComp_included
2 #define ibase_CObjectQueueComp_included
3 
4 
5 // Qt includes
6 #include <QtCore/QList>
7 
8 // ACF includes
9 #include <iser/ISerializable.h>
10 #include <icomp/CComponentBase.h>
11 #include <ibase/IObjectQueue.h>
12 
13 
14 namespace ibase
15 {
16 
17 
22  public icomp::CComponentBase,
23  virtual public IObjectQueue,
24  virtual public iser::ISerializable
25 {
26 public:
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;
38  virtual void ClearQueue();
39  virtual istd::IChangeable* CreateFrontObject(int offsetPos = 0, const QByteArray* typeIdPtr = NULL);
40  virtual istd::IChangeable* CreateBackObject(int offsetPos = 0, const QByteArray* typeIdPtr = NULL);
41  virtual void RemoveFrontObject(int offsetPos = 0, const QByteArray* typeIdPtr = NULL);
42  virtual void RemoveBackObject(int offsetPos = 0, const QByteArray* typeIdPtr = NULL);
43  virtual istd::IChangeable* GetFrontObject(int offsetPos = 0, const QByteArray* typeIdPtr = NULL) const;
44  virtual istd::IChangeable* GetBackObject(int offsetPos = 0, const QByteArray* typeIdPtr = NULL) const;
45  virtual void SelectObjects(
46  ObjectList& result,
47  bool doAppend = false,
48  int offsetPos = 0,
49  const QByteArray* typeIdPtr = NULL) const;
50  virtual istd::IChangeable* PopFrontObject(int offsetPos = 0, const QByteArray* typeIdPtr = NULL);
51  virtual istd::IChangeable* PopBackObject(int offsetPos = 0, const QByteArray* typeIdPtr = NULL);
52 
53  // reimplemented (iser::ISerializable)
54  virtual bool Serialize(iser::IArchive& archive);
55 
56 protected:
58  void TryReductReserve();
59 
60  // reimplemented (icomp::CComponentBase)
61  virtual void OnComponentDestroyed();
62 
63 private:
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 #endif // !ibase_CObjectQueueComp_included
78 
79 
icomp::CComponentBase BaseClass
virtual istd::IChangeable * CreateFrontObject(int offsetPos=0, const QByteArray *typeIdPtr=NULL)
Create object at the front of this queue.
virtual int GetObjectsCount(const QByteArray *typeIdPtr=NULL) const
Get number of objects in this queue.
Base class for component implementation.
virtual void RemoveFrontObject(int offsetPos=0, const QByteArray *typeIdPtr=NULL)
Remove object at the front of this queue.
Common class for all classes which objects can be archived or restored from archive.
Definition: ISerializable.h:23
Represent input/output persistence archive.
Definition: IArchive.h:30
Common interface for data model objects, which can be changed.
Definition: IChangeable.h:24
virtual istd::IChangeable * CreateBackObject(int offsetPos=0, const QByteArray *typeIdPtr=NULL)
Create object at the end of this queue.
virtual void OnComponentDestroyed()
istd::IChangeable * CreateObject()
#define NULL
Definition: istd.h:64
Interface allowing to manage queue of some objects.
Definition: IObjectQueue.h:20
virtual bool Serialize(iser::IArchive &archive)
Load or store state of this object as a archive stream.
virtual void RemoveBackObject(int offsetPos=0, const QByteArray *typeIdPtr=NULL)
Remove object at the end of this queue.
virtual istd::IChangeable * GetFrontObject(int offsetPos=0, const QByteArray *typeIdPtr=NULL) const
Get object at the front of queue.
virtual istd::IChangeable * PopFrontObject(int offsetPos=0, const QByteArray *typeIdPtr=NULL)
Get object at the front of queue and remove it from queue.
virtual istd::IChangeable * GetBackObject(int offsetPos=0, const QByteArray *typeIdPtr=NULL) const
Get object at the end of queue.
Implementation of ibase::IObjectQueue including some smart optimizations.
QVector< istd::IChangeable * > ObjectList
Definition: IObjectQueue.h:23
virtual void ClearQueue()
Remove all objects from queue.
virtual istd::IChangeable * PopBackObject(int offsetPos=0, const QByteArray *typeIdPtr=NULL)
Get object at the end of queue and remove it from queue.
virtual void SelectObjects(ObjectList &result, bool doAppend=false, int offsetPos=0, const QByteArray *typeIdPtr=NULL) const
Find set of objects.

© 2007-2017 Witold Gantzke and Kirill Lepskiy