Welcome    Usage    Browse    Find CID    Search     Log in

cM API Documentation

openme.h

Go to the documentation of this file.
00001 /*
00002 
00003  OpenME - Event-driven, plugin-based interactive interface to "open up" 
00004           any software (C/C++/Fortran/Java/PHP) and possibly connect it to cM
00005 
00006  cM - Collective Mind infrastructure to discover, collect,
00007       share and reuse knowledge
00008 
00009  Developer(s): (C) Grigori Fursin
00010  http://cTuning.org/lab/people/gfursin
00011 
00012  */
00013 
00014 #ifndef CM_H
00015 #define CM_H
00016 
00017 #include <stdio.h>
00018 #include <stdlib.h>
00019 #include <cJSON.h>
00020 
00021 #ifdef __cplusplus
00022 extern "C"
00023 {
00024 #endif
00025 
00026 #define OPENME_USE "OPENME_USE"
00027 #define OPENME_PLUGINS "OPENME_PLUGINS"
00028 #define OPENME_PLUGIN_INIT_FUNC "openme_plugin_init"
00029 #define OPENME_OUTPUT_FILE "OPENME_OUTPUT_FILE"
00030 #define OPENME_DEBUG "OPENME_DEBUG"
00031 
00032 /*
00033    OpenME event structure
00034 
00035    name - name of event (simple string)
00036    func - address of a function with 1 void pointer as a parameter
00037    next - pointer to next event (chaining)
00038 */
00039 
00040 struct openme_event
00041 {
00042   char *name;
00043   void (*func) (void *params);
00044   struct openme_event *next;
00045 };
00046 
00047 /*
00048    OpenME hooks
00049 
00050    We need to update all functions that use malloc and free
00051    and that we want to use in OpenME library
00052 */
00053 
00054 struct openme_hooks
00055 {
00056   void *(*malloc)(size_t sz);
00057   void (*free)(void *ptr);
00058   FILE *(*fopen)(const char *ptr1, const char *ptr2);
00059   int (*fprintf)(FILE*, const char*, ...);
00060   int (*fseek)(FILE *, long, int);
00061   long (*ftell)(FILE *);
00062   size_t (*fread)(void *, size_t, size_t, FILE *);
00063   int (*fclose)(FILE *f1);
00064 };
00065 
00066 /*
00067    OpenME initalization info
00068 
00069    event_list    - point to 1st event (openm_event)
00070    openme_hooks  - local hooks
00071    error         - last error message
00072 */
00073 
00074 struct openme_info
00075 {
00076   struct openme_event *event_list;
00077   struct openme_hooks *hooks;
00078   char error[1024];
00079 };
00080 
00081 /* OpenME interface functions */
00082 extern int openme_init (char *env_use, char *env_plugins, char *plugin_names, int force_use);
00083 
00084 extern void openme_callback (char *event_name, void *params);
00085 extern void openme_register_callback (struct openme_info *ome_info, char *event_name, void *func);
00086 
00087 extern cJSON *openme_create_obj (char *str);
00088 extern cJSON *openme_get_obj (cJSON*json, char *str);
00089 extern void openme_print_obj (cJSON *obj);
00090 
00091 extern cJSON *cm_action(cJSON *inp);
00092 
00093 extern void openme_init_hooks(struct openme_hooks *ome_hooks);
00094 
00095 extern cJSON *openme_load_json_file(char *file_name);
00096 extern int openme_store_json_file(cJSON *json, char *file_name);
00097 extern void openme_set_error(char *format, char *text);
00098 extern void openme_print_error(void);
00099 
00100 /* Fortran interface */
00101 extern int openme_init_f_ (char *env_use, char *env_plugins, char *plugin_names, int force_use);
00102 extern int OPENME_INIT_F (char *env_use, char *env_plugins, char *plugin_names, int force_use);
00103 
00104 extern void openme_callback_f (char *event_name, void *params);
00105 extern void OPENME_CALLBACK_F (char *event_name, void *params);
00106 
00107 extern cJSON *openme_create_obj_f_ (char *str);
00108 extern cJSON *OPENME_CREATE_OBJ_F (char *str);
00109 
00110 extern cJSON *openme_get_obj_f_ (char *str);
00111 extern cJSON *OPENME_GET_OBJ_F (char *str);
00112 
00113 extern void openme_print_obj_f_ (cJSON **obj);
00114 extern void OPENME_PRINT_OBJ_F (cJSON **obj);
00115 
00116 #ifdef __cplusplus
00117 }
00118 #endif
00119 
00120 #endif

Generated on Wed May 28 02:49:01 2014 for Collective Mind Framework by DoxyGen 1.6.1
Concept, design and coordination: Grigori Fursin (C) 1993-2013