Main Page | Alphabetical List | Data Structures | Directories | File List | Data Fields | Globals | Related Pages

actions.h File Reference

Actions. More...

#include <gr/types.h>
#include <gr/graph.h>

Go to the source code of this file.

Defines

#define GR_MODE_ZERO   1
#define GR_MODE_FIX   2
#define GR_MODE_MAX   3
#define gr_actions_get_model(act)   ((act)->model)

Typedefs

typedef enum _gr_listener_action_event_t gr_listener_action_event_t
typedef _gr_match_t gr_match_t
typedef void() gr_act_listen_func_t (const struct _gr_actions_t *acts, const gr_match_t *match, void *context)
typedef _gr_actions_t gr_actions_t
typedef _gr_actions_model_t gr_actions_model_t
typedef gr_sequence_t_ gr_sequence_t

Enumerations

enum  gr_action_kind_t { gr_action_kind_invalid, gr_action_kind_test, gr_action_kind_rule }
enum  _gr_listener_action_event_t { GR_LISTENER_ACT_AFTER_MATCH = 0, GR_LISTENER_ACT_BEFORE_FINISH = 1, GR_LISTENER_ACT_AFTER_FINISH = 2, GR_LISTENER_ACT_MAX = 3 }
enum  gr_sequence_op_t {
  GRS_MAX = 1, GRS_STAR = 2, GRS_CONCAT = 3, GRS_RULE = 4,
  GRS_RULE_ALL = 5
}
enum  gr_dump_match_special_t { GR_ALL_MATCHES = -1, GR_ONLY_MATCHES = -2 }

Functions

void gr_actions_delete (gr_actions_t *actions)
void gr_actions_get_ids (const gr_actions_t *acts, gr_set_t *set)
gr_match_tgr_actions_match (const gr_actions_t *acts, gr_id_t action, int ins, const gr_value_t **in)
int gr_actions_finish (const gr_actions_t *acts, gr_match_t *match, int which)
int gr_actions_get_ins (const gr_actions_t *acts, gr_id_t action)
int gr_actions_get_outs (const gr_actions_t *acts, gr_id_t action)
gr_action_kind_t gr_actions_get_kind (const gr_actions_t *acts, gr_id_t action)
gr_id_t gr_actions_get_id (const gr_actions_t *acts, const char *name)
const char * gr_actions_get_name (const gr_actions_t *acts, gr_id_t id)
int gr_actions_custom (gr_actions_t *actions, const char *which,...)
void gr_dump_match (gr_graph_t *gr, gr_dump_t *gd, const gr_match_t *match, int which)
void * gr_action_add_listener (gr_actions_t *acts, gr_listener_action_event_t event, gr_act_listen_func_t *func, void *context)
void gr_action_remove_listener (gr_actions_t *acts, void *listener_ID)
int gr_actions_apply_graph_rewrite (const gr_actions_t *acts, const char *action_name, int mode, int times, int dump)
int gr_actions_apply_graph_rewrite_sequence (const gr_actions_t *acts, const gr_sequence_t *grs)


Detailed Description

Actions.

Date:
12.9.2003
Author:
Sebastian Hack
Id
actions.h,v 1.17 2006/03/15 16:52:18 rubino Exp

Definition in file actions.h.


Define Documentation

#define gr_actions_get_model act   )     ((act)->model)
 

Get the actions model of an actions object.

Parameters:
act The actions object.
Returns:
The actions model.

Definition at line 109 of file actions.h.

#define GR_MODE_FIX   2
 

gr_actions_apply_graph_rewrite iterates until the number of matches is constant for two iterations

Definition at line 41 of file actions.h.

Referenced by gr_actions_apply_graph_rewrite().

#define GR_MODE_MAX   3
 

gr_actions_apply_graph_rewrite iterates until the maximum number (parameter: times) of iterations is reached

Definition at line 42 of file actions.h.

#define GR_MODE_ZERO   1
 

gr_actions_apply_graph_rewrite iterates until zero matches are found

Definition at line 40 of file actions.h.

Referenced by gr_actions_apply_graph_rewrite().


Typedef Documentation

typedef void() gr_act_listen_func_t(const struct _gr_actions_t *acts, const gr_match_t *match, void *context)
 

Action listener

Definition at line 92 of file actions.h.

typedef struct _gr_actions_model_t gr_actions_model_t
 

The actions model, an action module must implement.

typedef struct _gr_actions_t gr_actions_t
 

An actions module.

typedef enum _gr_listener_action_event_t gr_listener_action_event_t
 

Possible listener events for action listener

typedef struct _gr_match_t gr_match_t
 

The match result structure.

typedef struct gr_sequence_t_ gr_sequence_t
 


Enumeration Type Documentation

enum _gr_listener_action_event_t
 

Possible listener events for action listener

Enumeration values:
GR_LISTENER_ACT_AFTER_MATCH  after an action was matched, reports the match
GR_LISTENER_ACT_BEFORE_FINISH  before an action will be finished, reports the match
GR_LISTENER_ACT_AFTER_FINISH  after an action was finished, reports the match
GR_LISTENER_ACT_MAX 

Definition at line 62 of file actions.h.

enum gr_action_kind_t
 

An enum, that represents all types of actions, gr is able to perform on graphs.

Enumeration values:
gr_action_kind_invalid  An invalid action kind.
gr_action_kind_test  A subgraph test
gr_action_kind_rule  A replacement rule

Definition at line 53 of file actions.h.

enum gr_dump_match_special_t
 

Special 'which' values for gr_dump_match

Enumeration values:
GR_ALL_MATCHES  insert virtual match nodes and connect the matches
GR_ONLY_MATCHES  show only the matches

Definition at line 267 of file actions.h.

enum gr_sequence_op_t
 

Enumeration values:
GRS_MAX 
GRS_STAR 
GRS_CONCAT 
GRS_RULE 
GRS_RULE_ALL 

Definition at line 138 of file actions.h.


Function Documentation

void* gr_action_add_listener gr_actions_t acts,
gr_listener_action_event_t  event,
gr_act_listen_func_t func,
void *  context
 

Add a new action listener function.

Parameters:
acts The actions.
event The event that should be listened.
func The listener function that will be called.
context The context that will be transmitted.
Returns:
a listener ID that can be used to remove the listener.

Definition at line 168 of file actions.c.

References ASSERT_ACTION, _gr_generic_listener_t::context, GR_LISTENER_ACT_MAX, GR_RANGE_CHECK, _gr_generic_listener_t::listener_func, _gr_generic_listener_t::next, and _gr_generic_listener_t::prev.

Referenced by gr_install_generations().

void gr_action_remove_listener gr_actions_t acts,
void *  listener_ID
 

Deletes a action listener function.

Parameters:
acts The actions.
listener_ID The listener ID of the listener that should be deleted.

Definition at line 197 of file actions.c.

References ASSERT_ACTION, _gr_generic_listener_t::next, and _gr_generic_listener_t::prev.

int gr_actions_apply_graph_rewrite const gr_actions_t acts,
const char *  action_name,
int  mode,
int  times,
int  dump
 

Apply a graph rewrite rule.

Parameters:
acts The actions
action_name The name of the action
times The maximum iterations performed
mode The mode for loop: fix, zero matches, single
Returns:
The number of rewrites actually performed

Definition at line 353 of file actions.c.

References apply_rewrite(), ASSERT_ACTION, gr_domain_get_printer(), gr_domain_register(), gr_domain_unregister(), GR_ML_NOTE, GR_MODE_FIX, GR_MODE_ZERO, gr_msg_printer_set_level_mask(), and gr_note().

int gr_actions_apply_graph_rewrite_sequence const gr_actions_t acts,
const gr_sequence_t grs
 

Apply a graph rewrite sequence (grs).

Parameters:
acts The actions
grs The graph rewrite sequence
Returns:
0 iff no rule could be applied form the current graph rewrite sequence

Definition at line 453 of file actions.c.

References apply_grs(), ASSERT_ACTION, gr_domain_get_printer(), gr_domain_register(), gr_domain_unregister(), GR_ML_NOTE, GR_ML_WARNING, gr_msg_printer_set_level_mask(), gr_note(), and msec().

int gr_actions_custom gr_actions_t actions,
const char *  which,
  ...
 

Do a graph-backend dependent thing for actions.

Parameters:
gr The actions.
which What to do.
Returns:
0, if failed, 1 else.

Definition at line 156 of file actions.c.

References ASSERT_ACTION, ASSERT_FKT, and ASSERT_MODEL.

void gr_actions_delete gr_actions_t actions  ) 
 

Delete a set of actions.

Parameters:
actions The actions to delete.

Definition at line 60 of file actions.c.

References ASSERT_ACTION, ASSERT_FKT, and ASSERT_MODEL.

int gr_actions_finish const gr_actions_t acts,
gr_match_t match,
int  which
 

Finish an action. This function has to be called always after gr_actions_match(). It frees the allocated match structure and does the things that have to be done after matching. Graph modification, redirection of edges and attribute writeback.

Parameters:
acts The actions.
match The match pointer which's address was passed to gr_actions_match()
which The match to be used for finishing the action. If this number is out of bounds, the function selects one randomly. I.e. passing -1 here lets the function select a match.
Returns:
1, if everything went right, 0 if not.

Definition at line 93 of file actions.c.

References ASSERT_ACTION, ASSERT_FKT, ASSERT_MODEL, GR_LISTENER_ACT_AFTER_FINISH, GR_LISTENER_ACT_BEFORE_FINISH, and run_action_listener().

Referenced by apply_rewrite().

gr_id_t gr_actions_get_id const gr_actions_t acts,
const char *  name
 

Get an ID for an action name.

Parameters:
acts The actions.
name The name to resolve to an ID.
Returns:
The ID of the action named by name, or gr_id_invalid, if no such action did exist.

Definition at line 138 of file actions.c.

References ASSERT_ACTION, ASSERT_FKT, and ASSERT_MODEL.

Referenced by apply_rewrite().

void gr_actions_get_ids const gr_actions_t acts,
gr_set_t set
 

Put the IDs of all valid actions in a set.

Parameters:
acts The actions.
set The set.

Definition at line 69 of file actions.c.

References ASSERT_ACTION, ASSERT_FKT, and ASSERT_MODEL.

int gr_actions_get_ins const gr_actions_t acts,
gr_id_t  action
 

Get the number of required input parameters for an action.

Parameters:
acts The actions.
action The action ID.

Definition at line 111 of file actions.c.

References ASSERT_ACTION, ASSERT_FKT, and ASSERT_MODEL.

gr_action_kind_t gr_actions_get_kind const gr_actions_t acts,
gr_id_t  action
 

Get the kind of an action.

Parameters:
acts The actions.
action The action ID.
Returns:
The kind of the action.

Definition at line 129 of file actions.c.

References ASSERT_ACTION, ASSERT_FKT, and ASSERT_MODEL.

const char* gr_actions_get_name const gr_actions_t acts,
gr_id_t  id
 

Get the name of an action.

Parameters:
acts The actions.
id The action ID.
Returns:
The name of the action, or NULL, if the ID was not valid.

Definition at line 147 of file actions.c.

References ASSERT_ACTION, ASSERT_FKT, and ASSERT_MODEL.

int gr_actions_get_outs const gr_actions_t acts,
gr_id_t  action
 

Get the number of delivered output parameters for an action.

Parameters:
acts The actions.
action The action ID.

Definition at line 120 of file actions.c.

References ASSERT_ACTION, ASSERT_FKT, and ASSERT_MODEL.

gr_match_t* gr_actions_match const gr_actions_t acts,
gr_id_t  action,
int  ins,
const gr_value_t **  in
 

Do the match part of an action.

Parameters:
acts The actions the action belongs to.
action The id of the action.
ins The number of input parameters.
in The array of input parameters.
outs The number of output parameters.
out The array of output parameters.
Returns:
The number of matches found.

Definition at line 78 of file actions.c.

References ASSERT_ACTION, ASSERT_FKT, ASSERT_MODEL, GR_LISTENER_ACT_AFTER_MATCH, and run_action_listener().

Referenced by apply_rewrite().

void gr_dump_match gr_graph_t gr,
gr_dump_t gd,
const gr_match_t match,
int  which
 

Dump the graph with a graph dumper, color given match.

Parameters:
gr The graph.
gd The graph dumper.
match The match.
which The match to be used for finishing the action.
If which is set to GR_ALL_MATCHES, all matches will be colored and virtual match nodes will be added. If which is set to GR_ONLY_MATCHES, only the matches with the virtual match nodes are dumped.

The following colors are used:

  • normal nodes & edges : GR_COLOR_DEFAULT
  • single matched nodes & edges : GR_COLOR_RED
  • multiple matched " " : GR_COLOR_PURPLE
  • "virtual" match " " : GR_COLOR_GREEN

Definition at line 1096 of file graph.c.

References ASSERT_GR, dump_groups(), dump_ctx_t::edge_root, dump_ctx_t::exclude_edges, dump_ctx_t::gd, dump_ctx_t::gr, gr_alloc_temp_ids(), GR_COLOR_DEFAULT, gr_dump_edge(), gr_dump_edge_attr(), gr_dump_get_node_color(), GR_DUMP_INDEX_MATCH_SEV, GR_DUMP_INDEX_MATCH_SNG, GR_DUMP_INDEX_VIRT_MATCH, gr_dump_node(), gr_dump_node_attr(), gr_edge_label(), gr_get_all_nodes_instance_of(), gr_get_def_node_color(), gr_get_edge_root_type(), gr_get_node_root_type(), gr_get_source(), gr_get_target(), GR_ID_FMT, gr_iterator_delete(), gr_iterator_has_next(), gr_iterator_next(), gr_kind_id, GR_LINE_DEFAULT, gr_node_label(), GR_ONLY_MATCHES, gr_set_add(), gr_set_clear(), gr_set_contains(), gr_set_copy(), gr_set_delete(), gr_set_diff(), gr_set_iterator(), gr_set_new(), gr_value_get_id(), gr_value_init, gr_value_set_id(), dump_ctx_t::group_types, _gr_id_entry_t::id, dump_ctx_t::initial_nodes, dump_ctx_t::m_edges, dump_ctx_t::m_nodes, _gr_id_entry_t::next, dump_ctx_t::num_groups, dump_ctx_t::x_edges, and dump_ctx_t::x_nodes.

Referenced by gr_dump(), and vcg_dump_match().


Generated on Wed Apr 5 15:28:19 2006 for libgr by  doxygen 1.4.1