OpenStructure
Public Member Functions
WidgetPool Class Reference

#include <widget_pool.hh>

Inherits QObject.

Public Member Functions

 WidgetPool (QObject *parent=NULL)
 
void Add (const QString &name, int limit=-1)
 
bool IsAvailable (const QString &name)
 
WidgetCreate (const QString &name)
 
bool Take (const QString &name)
 
bool Give (const QString &name)
 
QList< QString > GetAvailableWidgets ()
 

Detailed Description

This Widget pool manages instances of widgets Widgets can be added to this pool by simply passing the classname and the amount of available instances. This class is coupled to the WidgetRegistry .

Definition at line 45 of file widget_pool.hh.

Constructor & Destructor Documentation

◆ WidgetPool()

WidgetPool ( QObject *  parent = NULL)

Member Function Documentation

◆ Add()

void Add ( const QString &  name,
int  limit = -1 
)

add a Widget to the WidgetPool This method adds a class to this widget pool. It does NOT add the given class to the WidgetRegistry. You should first add the class to the WidgetRegistry use the WidgetRegistry::RegisterWidgetFactory(WidgetFactory* factory) for this.

Parameters
namefull qualified class name. Is used to identify the class.
limitamount of available instances of the class in the WidgetRegistry. If unlimited then this can be set to -1.

◆ Create()

Widget* Create ( const QString &  name)

returns a instance of the given class name It does not WidgetPool::Take(const QString& name) a instance out of the pool. The user of this class is responsible to call the take method before calling this method.

Parameters
nameFull qualified class of the class of which you would like to have an instance.
Returns
Returns a instance of the desired class. Returns NULL if all instances are used or class is not in widget registry.

◆ GetAvailableWidgets()

QList<QString> GetAvailableWidgets ( )

Get a List with all available Widgets.

Returns
The returned list contains all widgets which have available instances in the pool. Instances which have no available instances won't be in this list.

◆ Give()

bool Give ( const QString &  name)

Returns a instance of a class into the pool This method returns one instance back into the pool. If there is an unlimited amount of instances of this class, nothing will be changed inside the pool.

Parameters
namefull qualified class of the class of which you give back an instance.
Returns
returns false if class is not known. Otherwise true will be returned.

◆ IsAvailable()

bool IsAvailable ( const QString &  name)

returns whether this class has available instances or not

Parameters
nameFull qualified class of the class you would like to check
Returns
returns true if there are available instances. False if all instances are used or class is not in widget registry.

◆ Take()

bool Take ( const QString &  name)

Takes a instance of a class out of the pool This method takes one available instances out of the pool. If there are no available instances or unlimited amount of instances, nothing will be changed. Call this method always before creating an instance. If false is returned do not call WidgetPool::Create(const QString& name) !

Parameters
namefull qualified class of the class of which you would like to take an instance.
Returns
returns false if no instance is available or class is not known. Otherwise true will be returned.

The documentation for this class was generated from the following file: