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

libgr_demo_simple.c

Go to the documentation of this file.
00001 #include "assert.h"
00002 
00003 #include "gr/gr.h"
00004 #include "gr/set_soset.h"
00005 #include "gr/vcg.h"
00006 
00007 #define GR_BACKEND_MODEL "grbe_frame_based.so"
00008 #define GR_GRAPH_MODEL   "gr_model_Mutex_fb.so"
00009 #define GR_ACTION_MODEL  "gr_actions_Mutex_fb.so"
00010 
00014 static gr_graph_t *init_graph(void)
00015 {
00016   const gr_backend_model_t *be_model;
00017   const gr_backend_t       *backend;
00018   const gr_graph_model_t   *gr_model;
00019   gr_msg_printer_t         *printer = gr_msg_printer_file_new(stdout);
00020   gr_graph_t               *res;
00021   gr_domain_t              *dom = gr_domain_get_root();
00022 
00023   gr_msg_printer_set_level_mask(printer, GR_ML_FATAL | GR_ML_ERROR);
00024   gr_init(gr_set_soset_factory, printer);
00025   gr_domain_set_printer(dom, printer);
00026 
00027   be_model = gr_load_backend_model(GR_BACKEND_MODEL);
00028   backend  = gr_backend_new(be_model, 0, NULL);
00029 
00030   gr_model = gr_backend_load_graph_model(backend, GR_GRAPH_MODEL);
00031   res = gr_backend_new_graph(backend, gr_model, "libgr_demo_graph");
00032 
00033   assert(res && "gr_backend_new_graph() did not return a graph!");
00034   return res;
00035 }
00036 
00043 static void vcg_dump(const char *filename, gr_graph_t *gr)
00044 {
00045   FILE *f = fopen(filename, "w");
00046   gr_dump_t *gd  = gr_dump_vcg_new(f, VCG_ORIENTATION_BOTTOM_TO_TOP);
00047 
00048 #if 0
00049         gr_dump_color_node_type(gd, env->ids.N_Type,       GR_COLOR_BROWN);
00050   gr_dump_color_edge_type(gd, env->ids.E_cf,         GR_COLOR_RED);
00051 
00052   gr_dump_group_incoming(gd, env->ids.N_Method_IRG);
00053 
00054   /* remove the modes */
00055   gr_dump_exclude_node_type(gd, env->ids.N_Mode);
00056 
00057   /* add infotags */
00058   gr_dump_set_node_infotag(gd, env->ids.N_Const,
00059                         gr_get_node_attr_id(env->graph, env->ids.N_Const, "value"));
00060 #endif  
00061 
00062   gr_dump(gr, gd);
00063 
00064   gr_dump_delete(gd);
00065   fclose(f);
00066 }
00067 
00071 static void add_nodes(gr_graph_t *gr, char *type_name, int num)
00072 {
00073         int i;
00074         gr_id_t type = gr_get_node_type_id(gr, type_name);
00075         
00076         assert(gr_id_is_valid(type));
00077                 
00078         for(i=0; i < num; i++) {
00079                 gr_id_t node = gr_add_node(gr, type);
00080         }
00081 }
00082 
00083 
00084 int main(void) {
00085         gr_graph_t *graph;
00086         
00087         graph = init_graph();
00088         //vcg_dump("01-init.vcg", graph);
00089 
00090         add_nodes(graph, "Process", 500000);
00091         
00092         //vcg_dump("02-before.vcg", graph);
00093         //vcg_dump("03-after.vcg", graph);
00094         
00095         return 0;
00096 }

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