CpgLink

CpgLink — Information transfer link

Synopsis

#define             CPG_LINK_CONST                      (obj)
struct              CpgLink;
struct              CpgLinkClass;
CpgLink *           cpg_link_new                        (const gchar *id,
                                                         CpgObject *from,
                                                         CpgObject *to);
CpgObject *         cpg_link_get_from                   (CpgLink *link);
CpgObject *         cpg_link_get_to                     (CpgLink *link);
gboolean            cpg_link_add_action                 (CpgLink *link,
                                                         CpgLinkAction *action);
gboolean            cpg_link_remove_action              (CpgLink *link,
                                                         CpgLinkAction *action);
const GSList *      cpg_link_get_actions                (CpgLink *link);
CpgLinkAction *     cpg_link_get_action                 (CpgLink *link,
                                                         const gchar *target);
void                cpg_link_attach                     (CpgLink *link,
                                                         CpgObject *from,
                                                         CpgObject *to);
CpgLink *           cpg_link_get_action_template        (CpgLink *link,
                                                         CpgLinkAction *action,
                                                         gboolean match_full);
                    CpgLinkPrivate;

Object Hierarchy

  GObject
   +----CpgObject
         +----CpgLink

Implemented Interfaces

CpgLink implements CpgUsable, CpgAnnotatable, CpgLayoutable and CpgTaggable.

Properties

  "from"                     CpgObject*            : Read / Write / Construct
  "to"                       CpgObject*            : Read / Write / Construct

Signals

  "action-added"                                   : Run Last
  "action-removed"                                 : Run Last

Description

A CpgLink is a connection between two CpgObject. The link defines actions which consist of a target property in the object to which the link is connected, and an expression by which this target property needs to be updated.

CpgLink Copy Semantics

When a link is copied with cpg_object_copy, the link actions are also copied. However, the link "from" and "to" properties are NOT copied, so that you are free to attach it to two new objects.

Details

CPG_LINK_CONST()

#define CPG_LINK_CONST(obj)      (G_TYPE_CHECK_INSTANCE_CAST ((obj), CPG_TYPE_LINK, CpgLink const))


struct CpgLink

struct CpgLink;


struct CpgLinkClass

struct CpgLinkClass {
};


cpg_link_new ()

CpgLink *           cpg_link_new                        (const gchar *id,
                                                         CpgObject *from,
                                                         CpgObject *to);

Create a new CpgLink

id :

the object id

from :

a CpgObject. [allow-none]

to :

a CpgObject. [allow-none]

Returns :

a new CpgLink

cpg_link_get_from ()

CpgObject *         cpg_link_get_from                   (CpgLink *link);

Returns the from CpgObject of the link

link :

the CpgLink

Returns :

the from CpgObject. [transfer none]

cpg_link_get_to ()

CpgObject *         cpg_link_get_to                     (CpgLink *link);

Returns the to CpgObject of the link

link :

the CpgLink

Returns :

the to CpgObject. [transfer none]

cpg_link_add_action ()

gboolean            cpg_link_add_action                 (CpgLink *link,
                                                         CpgLinkAction *action);

Add a new action to be performed when the link is evaluated during simulation. Note that if an action with the same target already exists, the action information is transfered to the existing action instance. This means that the specified action might not actually be added to the object. Also, since a CpgLinkAction is a GInitiallyUnowned, action will be destroyed after the call to cpg_link_add_action in the above described case, unless you explicitly sink the floating reference.

In the case that you can not know whether an action is overriding an existing action in link, never use action after a call to cpg_link_add_action. Instead, retrieve the corresponding action using cpg_link_get_action after the call to cpg_link_add_action.

link :

the CpgLink

action :

the CpgLinkAction

Returns :

TRUE if action could be successfully added, FALSE otherwise

cpg_link_remove_action ()

gboolean            cpg_link_remove_action              (CpgLink *link,
                                                         CpgLinkAction *action);

Removes an action from the link.

link :

the CpgLink

action :

the CpgLinkAction

Returns :

TRUE if the action was successfully removed

cpg_link_get_actions ()

const GSList *      cpg_link_get_actions                (CpgLink *link);

Get link actions

link :

the CpgLink

Returns :

list of CpgLinkAction. The list is owned by the link and should not be freed. [element-type CpgLinkAction][transfer none]

cpg_link_get_action ()

CpgLinkAction *     cpg_link_get_action                 (CpgLink *link,
                                                         const gchar *target);

Get a CpgLinkAction targetting the property target.

link :

A CpgLink

target :

The target property name

Returns :

A CpgLinkAction. [transfer none]

cpg_link_attach ()

void                cpg_link_attach                     (CpgLink *link,
                                                         CpgObject *from,
                                                         CpgObject *to);

Attach link to the objects from and to. This is equivalent to:

1
g_object_set (link, "from", from, "to", to);

link :

A CpgLink. [allow-none]

from :

A CpgObject. [allow-none]

to :

A CpgObject

cpg_link_get_action_template ()

CpgLink *           cpg_link_get_action_template        (CpgLink *link,
                                                         CpgLinkAction *action,
                                                         gboolean match_full);

Get the template on which action is defined, if any. If match_full is TRUE, the template will only be possitively matched if both actions are equal (i.e. if an action originated from a template, but was later modified, this function will not return the original template object).

link :

A CpgLink

action :

A CpgLinkAction

match_full :

How to match the action

Returns :

A CpgLink or NULL if the template could not be found. [transfer none]

CpgLinkPrivate

typedef struct _CpgLinkPrivate CpgLinkPrivate;

Property Details

The "from" property

  "from"                     CpgObject*            : Read / Write / Construct

The from CpgObject


The "to" property

  "to"                       CpgObject*            : Read / Write / Construct

The to CpgObject

Signal Details

The "action-added" signal

void                user_function                      (CpgLink       *object,
                                                        CpgLinkAction *action,
                                                        gpointer       user_data)      : Run Last

Emitted when a link action is added to the link

object :

a CpgObject

action :

the added CpgLinkAction

user_data :

user data set when the signal handler was connected.

The "action-removed" signal

void                user_function                      (CpgLink       *object,
                                                        CpgLinkAction *action,
                                                        gpointer       user_data)      : Run Last

Emitted when a link action is removed from the link

object :

a CpgObject

action :

the removed CpgLinkAction

user_data :

user data set when the signal handler was connected.