dataNode

dataNode — Extends capabilities of node properties.

Synopsis

                    VisuDataNode;
void                (*VisuDataNodeCallbackMethod)       (VisuData *dataObj,
                                                         VisuNode *node,
                                                         gpointer data);
                    VisuDataNodeClass;
gboolean            (*VisuDataNodeFromStringFunc)       (VisuDataNode *data,
                                                         VisuData *dataObj,
                                                         VisuNode *node,
                                                         gchar *labelIn,
                                                         gchar **labelOut,
                                                         gboolean *modify);
gchar *             (*VisuDataNodeToStringFunc)         (VisuDataNode *data,
                                                         VisuData *dataObj,
                                                         VisuNode *node);
GList *             visu_data_node_class_getAll         (void);
void                visu_data_node_emitValueChanged     (VisuDataNode *data,
                                                         VisuData *dataObj);
gboolean            visu_data_node_getEditable          (VisuDataNode *data);
const gchar *       visu_data_node_getLabel             (VisuDataNode *data);
gboolean            visu_data_node_getUsed              (VisuDataNode *data,
                                                         VisuData *dataObj);
gchar *             visu_data_node_getValueAsString     (VisuDataNode *data,
                                                         VisuData *dataObj,
                                                         VisuNode *node);
GObject *           visu_data_node_new                  (const gchar *name,
                                                         GType type);
GObject *           visu_data_node_newWithCallbacks     (const gchar *name,
                                                         VisuDataNodeFromStringFunc setAsString,
                                                         VisuDataNodeToStringFunc getAsString);
void                visu_data_node_setCallback          (VisuDataNode *data,
                                                         VisuDataNodeCallbackMethod callback,
                                                         gpointer user_data);
void                visu_data_node_setEditable          (VisuDataNode *data,
                                                         gboolean status);
void                visu_data_node_setLabel             (VisuDataNode *data,
                                                         const gchar *label);
void                visu_data_node_setUsed              (VisuDataNode *data,
                                                         VisuData *dataObj,
                                                         gint nb);
gboolean            visu_data_node_setValueAsString     (VisuDataNode *data,
                                                         VisuData *dataObj,
                                                         VisuNode *node,
                                                         gchar *labelIn,
                                                         gchar **labelOut);

Object Hierarchy

  GObject
   +----VisuDataNode

Signals

  "propertyUnused"                                 : No Hooks
  "propertyUsed"                                   : No Hooks
  "valueChanged"                                   : No Hooks

Description

This module is a wrapper around node properties from VisuData. It adds some capabilities, such as a translatable name, a way to go from data to strings and reverse, callbacks when the properties is changed...

When creating a node property calling visu_node_array_property_newPointer() for instance, a VisuDataNode can be created using visu_data_node_new(). A VisuDataNode may not be attached to a specific VisuData and is a global property found on each VisuData (or potentialy found). The advantage of doing this is to keep track of available properties for VisuData objects. To get all public properties, call visu_data_node_class_getAll().

Details

VisuDataNode

typedef struct _VisuDataNode VisuDataNode;

An opaque structure.


VisuDataNodeCallbackMethod ()

void                (*VisuDataNodeCallbackMethod)       (VisuData *dataObj,
                                                         VisuNode *node,
                                                         gpointer data);

Interface for callbacks methods that are called whenever a data is changed on a node.

WARNING: it may be removed later.

dataObj :

the VisuData object on which the callback is done ;

node :

the VisuNode on which the callback is done ;

data :

a user defined pointer.

VisuDataNodeClass

typedef struct _VisuDataNodeClass VisuDataNodeClass;

An opaque structure.


VisuDataNodeFromStringFunc ()

gboolean            (*VisuDataNodeFromStringFunc)       (VisuDataNode *data,
                                                         VisuData *dataObj,
                                                         VisuNode *node,
                                                         gchar *labelIn,
                                                         gchar **labelOut,
                                                         gboolean *modify);

If the string is correctly formatted (that means it has the same format as the string returned by GetValueAsStringFunc()) the stored values are modified. The resulting string is created and put into labelOut. If the input string labelIn is unparsable, labelOut will contain current values.

data :

a VisuDataNode ;

dataObj :

a VisuData object ;

node :

a VisuNode ;

labelIn :

a formatted string ;

labelOut :

a pointer to store a string ;

modify :

TRUE if the values have been modified.

Returns :

TRUE if the string was correctly parsed (modified or not).

VisuDataNodeToStringFunc ()

gchar *             (*VisuDataNodeToStringFunc)         (VisuDataNode *data,
                                                         VisuData *dataObj,
                                                         VisuNode *node);

For the given node, the values stored are printed into a string.

data :

a VisuDataNode ;

dataObj :

a VisuData object ;

node :

a VisuNode.

Returns :

a newly created string (use g_free()).

visu_data_node_class_getAll ()

GList *             visu_data_node_class_getAll         (void);

All registered VisuDataNode are stored in an intern list. This method is used to retrieve it.

Returns :

a GList of all registereed VisuDataNode (this list is owned by V_Sim). [transfer none][element-type VisuDataNode*]

visu_data_node_emitValueChanged ()

void                visu_data_node_emitValueChanged     (VisuDataNode *data,
                                                         VisuData *dataObj);

Emit the 'valueChanged' signal. This method should be called after all changes have been done to a node property set of nodes. Then routines using this property can update itself.

data :

a VisuDataNode ;

dataObj :

a VisuData object.

visu_data_node_getEditable ()

gboolean            visu_data_node_getEditable          (VisuDataNode *data);

If some callback method has been given with visu_data_node_setCallback(), then the values are considered editable.

data :

a VisuDataNode.

Returns :

TRUE if values are editable.

visu_data_node_getLabel ()

const gchar *       visu_data_node_getLabel             (VisuDataNode *data);

A VisuDataNode can have a label, if not its name is used.

data :

a VisuDataNode ;

Returns :

the label of the node (in UTF8), this string is owned by V_Sim.

visu_data_node_getUsed ()

gboolean            visu_data_node_getUsed              (VisuDataNode *data,
                                                         VisuData *dataObj);

Access method to know if the given dataObj has a public node property of the type data.

data :

a VisuDataNode ;

dataObj :

a VisuData object.

Returns :

TRUE if dataObj has a node property of the given type.

visu_data_node_getValueAsString ()

gchar *             visu_data_node_getValueAsString     (VisuDataNode *data,
                                                         VisuData *dataObj,
                                                         VisuNode *node);

For the given node, the values stored are printed into a string.

data :

a VisuDataNode ;

dataObj :

a VisuData object ;

node :

a VisuNode.

Returns :

a newly created string.

visu_data_node_new ()

GObject *           visu_data_node_new                  (const gchar *name,
                                                         GType type);

This method creates a new VisuDataNode and registers it. A VisuDataNode is characterised by a string used as a key to store it as a node property (see visu_node_array_property_newPointer()). The stored data can be arrays or not. Notice that name is copied.

name :

a string used to store the data as a node property ;

type :

the type of data stored (array or not).

Returns :

a newly created VisuDataNode. [transfer full]

visu_data_node_newWithCallbacks ()

GObject *           visu_data_node_newWithCallbacks     (const gchar *name,
                                                         VisuDataNodeFromStringFunc setAsString,
                                                         VisuDataNodeToStringFunc getAsString);

As visu_data_node_new(), but with custom setAsString and getAsString routines. This is used to allow to treat every node related values, not just node properties.

name :

a string used to store the data as a node property ;

setAsString :

a custom routine to change node values from a string ;. [scope call]

getAsString :

a custom routine to create a string from node values. [scope call]

Returns :

a newly created VisuDataNode. [transfer full]

visu_data_node_setCallback ()

void                visu_data_node_setCallback          (VisuDataNode *data,
                                                         VisuDataNodeCallbackMethod callback,
                                                         gpointer user_data);

When visu_data_node_setValueAsString(), values may be modified. If true, the given callback method is called with user_data as argument.

data :

a VisuDataNode ;

callback :

a VisuDataNodeCallbackMethod method ;. [scope call]

user_data :

a pointer to a location used to store some user data.

visu_data_node_setEditable ()

void                visu_data_node_setEditable          (VisuDataNode *data,
                                                         gboolean status);

Set if the values are modifiable.

data :

a VisuDataNode ;

status :

a boolean value.

visu_data_node_setLabel ()

void                visu_data_node_setLabel             (VisuDataNode *data,
                                                         const gchar *label);

A VisuDataNode can have a label, if not its name is used. Notice that label is not copied.

data :

a VisuDataNode ;

label :

an UTF8 string (may be translated).

visu_data_node_setUsed ()

void                visu_data_node_setUsed              (VisuDataNode *data,
                                                         VisuData *dataObj,
                                                         gint nb);

A VisuDataNode stores data for each node of a given VisuData. The number of data stored for each node is set with this method. When some part wants to set a new node property and wants to make it public, this method can be called. It also can be called when the node property is removed (using a null nb argument). If nb is changed for a positive value, the "propertyUsed" signal is emitted with dataObj as argument, instead if the value is changed for null, the "propertyUnused" signal is triggered also with dataObj as argument.

data :

a VisuDataNode ;

dataObj :

a VisuData object ;

nb :

a positive or null integer.

visu_data_node_setValueAsString ()

gboolean            visu_data_node_setValueAsString     (VisuDataNode *data,
                                                         VisuData *dataObj,
                                                         VisuNode *node,
                                                         gchar *labelIn,
                                                         gchar **labelOut);

If the string is correctly formatted (that means it has the same format as the string returned by visu_data_node_getValueAsString()) the stored values are modified. The resulting string is created and put into labelOut. If the input string labelIn is unparsable, labelOut will contain current values. Notice that this method is callable only if the data is editable (see visu_data_node_getEditable()).

data :

a VisuDataNode ;

dataObj :

a VisuData object ;

node :

a VisuNode ;

labelIn :

a formatted string ;

labelOut :

a pointer to store a string.

Returns :

TRUE if the string was correctly parsed.

Signal Details

The "propertyUnused" signal

void                user_function                      (VisuDataNode *data,
                                                        GObject      *dataObj,
                                                        gpointer      user_data)      : No Hooks

The given property data gets unused by dataObj.

data :

the VisuDataNode emitting the signal.

dataObj :

the VisuData its working on.

user_data :

user data set when the signal handler was connected.

Since 3.3


The "propertyUsed" signal

void                user_function                      (VisuDataNode *data,
                                                        GObject      *dataObj,
                                                        gpointer      user_data)      : No Hooks

The given property data gets used by dataObj.

data :

the VisuDataNode emitting the signal.

dataObj :

the VisuData its working on.

user_data :

user data set when the signal handler was connected.

Since 3.3


The "valueChanged" signal

void                user_function                      (VisuDataNode *data,
                                                        GObject      *dataObj,
                                                        gpointer      user_data)      : No Hooks

The given property data used by dataObj has its value changed.

data :

the VisuDataNode emitting the signal.

dataObj :

the VisuData its working on.

user_data :

user data set when the signal handler was connected.

Since 3.3