00001 /* 00002 * Copyright (C) 1997-2004 The CDG Team <cdg@nats.informatik.uni-hamburg.de> 00003 * 00004 * This file is free software; as a special exception the author gives 00005 * unlimited permission to copy and/or distribute it, with or without 00006 * modifications, as long as this notice is preserved. 00007 * 00008 * This program is distributed in the hope that it will be useful, but 00009 * WITHOUT ANY WARRANTY, to the extent permitted by law; without even the 00010 * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 00011 * 00012 * Author: Michael Schulz (see also AUTHORS and THANKS for more) 00013 * Birth: 12 Juli 1998 00014 * 00015 * $Id: hook.h,v 1.25 2004/02/25 14:28:05 micha Exp $ 00016 */ 00017 00018 /* ------------------------------------------------------------------------- 00019 * @addtogroup Hook Hook - A callback system 00020 * @{ 00021 * @author Michael Schulz 00022 * 00023 * @} */ 00024 00025 /* ------------------------------------------------------------------------- 00026 * @addtogroup HookCore 00027 * @ingroup Hook 00028 * @{ */ 00029 00030 #ifndef _HOOK_H 00031 #define _HOOK_H 00032 00033 /* -- INCLUDES ---------------------------------------------------------- */ 00034 #include "cdg.h" 00035 #include "stdarg.h" 00036 00037 /* -- MACROS ------------------------------------------------------------ */ 00038 00039 #ifndef SWIG 00040 /* ------------------------------------------------------------------------ 00041 * callback after building constraintnodes. 00042 */ 00043 #define HOOK_CNBUILDNODES 0 00044 00045 /* ------------------------------------------------------------------------ 00046 * callback after evaluation of constraints. 00047 */ 00048 #define HOOK_EVAL 1 00049 00050 /* ------------------------------------------------------------------------ 00051 * callback in netsearching. 00052 */ 00053 #define HOOK_NSSEARCH 2 00054 00055 /* ------------------------------------------------------------------------ 00056 * callback for printfing. 00057 */ 00058 #define HOOK_PRINTF 3 00059 00060 /* ------------------------------------------------------------------------ 00061 * callback for flushing the output channels. 00062 */ 00063 #define HOOK_FLUSH 4 00064 00065 /* ------------------------------------------------------------------------ 00066 notification that parses, constraint nets etc. have become invalid 00067 because of grammar changes. 00068 */ 00069 #define HOOK_RESET 5 00070 00071 /* ------------------------------------------------------------------------ 00072 * callback for user interaction in the gls module. 00073 */ 00074 #define HOOK_GLSINTERACTION 6 00075 00076 /* ------------------------------------------------------------------------ 00077 * callback in to get a string from the user. 00078 */ 00079 #define HOOK_GETS 7 00080 00081 /* ------------------------------------------------------------------------ 00082 * callback to indicate progress in a heavy computation. 00083 */ 00084 #define HOOK_PROGRESS 8 00085 00086 /* ------------------------------------------------------------------------ 00087 * callback to hand over partial results. 00088 */ 00089 #define HOOK_PARTIALRESULT 9 00090 00091 /* ------------------------------------------------------------------------ 00092 * callback for user interaction in the incrementalcompletion module. 00093 */ 00094 #define HOOK_ICINTERACTION 10 00095 00096 00097 #endif 00098 00099 /* ------------------------------------------------------------------------ 00100 * identification of the \c HINT channel. 00101 * \todo The \c HINT channel is bogus and never used. 00102 */ 00103 #define CDG_HINT (1L << 0) 00104 00105 /* ------------------------------------------------------------------------ 00106 * identification of the \c INFO channel. 00107 * Most of the output of the \c CDG library is tagged as \c INFO. A message 00108 * to the \c INFO channel is \e informal. 00109 */ 00110 #define CDG_INFO (1L << 1) 00111 00112 /* ------------------------------------------------------------------------ 00113 * identification of the \c WARNING channel. 00114 * A message to this channel informs about an unexpected situation. Operations 00115 * continue. If a normal continuation is not possible the message should 00116 * be emitted on the \c ERROR channel. 00117 */ 00118 #define CDG_WARNING (1L << 2) 00119 00120 /* ------------------------------------------------------------------------ 00121 * identification of the \c PROLOG channel. 00122 * \todo The \c PROLOG channel is bogus and never used. 00123 */ 00124 #define CDG_PROLOG (1L << 3) 00125 00126 /* ------------------------------------------------------------------------ 00127 * identification of the \c EVAL channel. 00128 * \todo The \c EVAL channel is bogus and never used. 00129 */ 00130 #define CDG_EVAL (1L << 4) 00131 00132 /* ------------------------------------------------------------------------ 00133 * identification of the \c SEARCHRESULT channel. 00134 * Results in a parser are emited on this channel. All parsing falvours 00135 * should obey to this channel semantics. Most of them do. 00136 */ 00137 #define CDG_SEARCHRESULT (1L << 5) 00138 00139 /* ------------------------------------------------------------------------ 00140 * identification of the \c PROFILE channel. 00141 * This channel is used to emit profiling information, that is time statistics 00142 * on computations. 00143 */ 00144 #define CDG_PROFILE (1L << 6) 00145 00146 /* ------------------------------------------------------------------------ 00147 * global hook flag. 00148 * This flag switches on/off the complete hook system. 00149 * \todo By no means this is an output channel. This define should be 00150 * removed and replaced with a proper variable that is altered by the 00151 * hook command. 00152 */ 00153 #define CDG_HOOK (1L << 7) 00154 00155 /* ------------------------------------------------------------------------ 00156 * identification of the \c ERROR channel. 00157 * This channel transmits messages about unexpected events that lead to 00158 * an abortion of further computation. Compare to \c WARNING. 00159 */ 00160 #define CDG_ERROR (1L << 8) 00161 00162 /* ------------------------------------------------------------------------ 00163 * identification of the \c DEBUG channel. 00164 * This message increases the normal output verbosity by offering debug 00165 * information. 00166 */ 00167 #define CDG_DEBUG (1L << 9) 00168 00169 /* ------------------------------------------------------------------------ 00170 * identification of the \c DEFAULT channel. 00171 * Unclassified messages of messages that should only be supressed in very 00172 * rare cases are emitet on the \c DEFAULT channel. 00173 */ 00174 #define CDG_DEFAULT (1L << 10) 00175 00176 /* ------------------------------------------------------------------------ 00177 * identification of the \c PROGRESS channel. 00178 * Messages about progress are emited on this channel and might be 00179 * redirected over the \c HOOK_PROGRESS callback. 00180 */ 00181 #define CDG_PROGRESS (1L << 11) 00182 00183 /* ------------------------------------------------------------------------ 00184 * identification of the \c PROGRESS channel. 00185 * All xml output goes in this channel. See the write module for more 00186 * infofmation on xml output. 00187 */ 00188 #define CDG_XML (1L << 12) 00189 00190 00191 /* -- TYPE DEFINITIONS -------------------------------------------------- */ 00192 #ifndef SWIG 00193 00194 /* ------------------------------------------------------------------------ 00195 * type of a callback function. 00196 * This function is installed into a callback hook and executed whenever 00197 * this callback is triggered. This is only a indicator definition without 00198 * any grants on the arguments. But be aware of the arguments that are 00199 * actually needed by every callback. 00200 */ 00201 typedef void HookFunction(); 00202 00203 /* ------------------------------------------------------------------------ 00204 * callback information. 00205 * This structure bundles the state of a callback. 00206 */ 00207 typedef struct { 00208 int no; /**< index in vector hkHooks */ 00209 unsigned long count; /**< number of past invocations */ 00210 String name; /**< identifier required to be unique among all hooks*/ 00211 String cmd; /**< command to be executed in tcl */ 00212 Boolean active; /**< flag indicating the status of the hook */ 00213 HookFunction *function; /**< function which is called with a va_list 00214 argument */ 00215 } HookStruct; 00216 typedef HookStruct *Hook; /**< type of a Hook */ 00217 #endif 00218 00219 /* -- VARIABLES --------------------------------------------------------- */ 00220 00221 #ifdef SWIG 00222 #ifdef OLD_SWIG 00223 %readwrite 00224 #else 00225 %mutable; 00226 #endif 00227 #endif 00228 extern unsigned long int hkVerbosity; 00229 #ifdef SWIG 00230 #ifdef OLD_SWIG 00231 %readonly; 00232 #else 00233 %immutable; 00234 #endif 00235 #endif 00236 extern Vector hkHooks; 00237 00238 /* -- FUNCTIONS --------------------------------------------------------- */ 00239 00240 #ifndef SWIG 00241 extern void hkInitialize(void); 00242 extern void hkFinalize(void); 00243 extern int hkFindNoOfHook(String name); 00244 extern void cdgExecHook(int hookNo, ...); 00245 extern void cdgFlush(void); 00246 extern void cdgPrintf(int mode, String format, ...); 00247 extern void cdgGetString(String buffer, int size); 00248 extern void hkCallback(String name, Boolean *var); 00249 extern Boolean hkValidate(String name, String value, Boolean *var); 00250 #endif 00251 00252 /* ---------------------------------------------------------------------- */ 00253 /** @} */ 00254 #endif /* don't insert anything after this #endif */ 00255