ToolPool

ToolPool — a storage container that can uniquely stores GBoxed objects.

Functions

Properties

GType * type Read / Write / Construct Only

Signals

Types and Values

struct ToolPoolClass

Object Hierarchy

    GObject
    ╰── ToolPool

Description

This storage is intended to be a signaling container for a given type of GBoxed objects. In addition, these objects are guaranteed to be unique in the container.

Functions

tool_pool_new ()

ToolPool *
tool_pool_new (GType type,
               GCompareFunc compare);

Create a new ToolPool object to store GBoxed objects defined by type . These objects must be comparable with compare function.

Parameters

type

a type inheriting G_TYPE_BOXED.

 

compare

a comparison function.

[scope call]

Returns

a newly created ToolPool object.

[transfer full]

Since: 3.8


tool_pool_add ()

gpointer
tool_pool_add (ToolPool *pool,
               gconstpointer boxed);

Copy boxed into pool if not already present.

Parameters

pool

a ToolPool object.

 

boxed

a GBoxed pointer.

 

Returns

a pointer on the copy of boxed . This copy is owned by V_Sim.

[transfer none]

Since: 3.8


tool_pool_take ()

gpointer
tool_pool_take (ToolPool *pool,
                gpointer boxed);

Insert boxed in pool and takes ownership.

Parameters

pool

a ToolPool object.

 

boxed

a GBoxed pointer.

 

Returns

a pointer on boxed . This pointer is owned by V_Sim.

[transfer none]

Since: 3.8


tool_pool_asList ()

GList *
tool_pool_asList (ToolPool *pool);

Get the list of elements stored in pool .

Parameters

pool

a ToolPool object.

 

Returns

the list should be freed with g_list_free() when no longer needed.

[transfer container][element-type GLib.Value]

Since: 3.8


tool_pool_getById ()

gpointer
tool_pool_getById (ToolPool *pool,
                   guint num);

This function retrieves the nth stored object. Number 0, is the last added object.

Parameters

pool

a ToolPool object.

 

num

an integer (>0).

 

Returns

the corresponding object, or NULL if none has been found.

[transfer none]


tool_pool_getByData ()

gpointer
tool_pool_getByData (ToolPool *pool,
                     gconstpointer boxed);

This function retrieves the stored object that is equivalent to boxed .

Parameters

pool

a ToolPool object.

 

boxed

a GBoxed object.

 

Returns

the corresponding object, or NULL if none has been found.

[transfer none]

Since: 3.8


tool_pool_index ()

gint
tool_pool_index (ToolPool *pool,
                 gconstpointer boxed);

Retrieve the storage index of boxed if it exists, or -1 if not.

Parameters

pool

a ToolPool object.

 

boxed

an object.

 

Returns

an index.

Since: 3.8

Types and Values

struct ToolPoolClass

struct ToolPoolClass {
  GObjectClass parent;
};

A short way to identify _ToolPoolClass structure.

Members

GObjectClass parent;

the parent class.

 

Property Details

The “type” property

  “type”                     GType *

stored type.

Flags: Read / Write / Construct Only

Allowed values: gpointer

Signal Details

The “new-element” signal

void
user_function (ToolPool *pool,
               gpointer  boxed,
               gpointer  user_data)

A new object is available in the pool.

Parameters

pool

the object emitting the signal.

 

boxed

the newly added object.

 

user_data

user data set when the signal handler was connected.

 

Flags: No Hooks

Since: 3.8