1 /* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 4; tab-width: 4 -*- */
4 * Copyright (C) Massimo Cora' 2007-2008 <maxcvs@email.it>
6 * anjuta is free software.
8 * You may redistribute it and/or modify it under the terms of the
9 * GNU General Public License, as published by the Free Software
10 * Foundation; either version 2 of the License, or (at your option)
13 * anjuta is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
16 * See the GNU General Public License for more details.
18 * You should have received a copy of the GNU General Public License
19 * along with anjuta. If not, write to:
20 * The Free Software Foundation, Inc.,
21 * 51 Franklin Street, Fifth Floor
22 * Boston, MA 02110-1301, USA.
25 #ifndef _SYMBOL_DB_ENGINE_PRIV_H_
26 #define _SYMBOL_DB_ENGINE_PRIV_H_
28 #include <glib-object.h>
30 #include <libanjuta/anjuta-launcher.h>
31 #include <libgda/libgda.h>
32 #include <sql-parser/gda-sql-parser.h>
34 #include <libanjuta/interfaces/ianjuta-symbol-manager.h>
35 #include <libanjuta/interfaces/ianjuta-symbol.h>
37 /* file should be specified without the ".db" extension. */
38 #define ANJUTA_DB_FILE ".anjuta_sym_db"
40 /* if tables.sql changes or general db structure changes modify also the value here */
41 #define SYMBOL_DB_VERSION "373.0"
43 #define TABLES_SQL PACKAGE_DATA_DIR"/tables.sql"
45 #define CTAGS_MARKER "#_#\n"
47 #define SHARED_MEMORY_PREFIX SYMBOL_DB_SHM
49 #define THREADS_MAX_CONCURRENT 2
50 #define TRIGGER_SIGNALS_DELAY 100
52 #define BATCH_SYMBOL_NUMBER 15000
54 #define SDB_QUERY_SEARCH_HEADER \
56 SymbolDBQueryPriv *priv; \
57 g_return_val_if_fail (SYMBOL_DB_IS_QUERY (query), NULL); \
58 priv = SYMBOL_DB_QUERY (query)->priv;
60 #define SDB_GVALUE_SET_INT(value, int_value) \
61 g_value_init (&value, G_TYPE_INT); \
62 g_value_set_int (&value, (int_value));
64 #define SDB_GVALUE_SET_DOUBLE(value, double_value) \
65 g_value_init (&value, G_TYPE_DOUBLE); \
66 g_value_set_double (&value, (double_value));
68 #define SDB_GVALUE_SET_STRING(value, str_value) \
69 g_value_init (&value, G_TYPE_STRING); \
70 g_value_set_string (&value, (str_value));
72 #define SDB_GVALUE_SET_STATIC_STRING(value, str_value) \
73 g_value_init (&value, G_TYPE_STRING); \
74 g_value_set_static_string (&value, (str_value));
77 #define SDB_PARAM_SET_INT(gda_param, int_value) \
78 SDB_GVALUE_SET_INT(v, int_value); \
79 gda_holder_set_value ((gda_param), &v, NULL); \
82 #define SDB_PARAM_SET_DOUBLE(gda_param, double_value) \
83 SDB_GVALUE_SET_DOUBLE(v, double_value); \
84 gda_holder_set_value ((gda_param), &v, NULL); \
87 #define SDB_PARAM_SET_STRING(gda_param, str_value) \
88 SDB_GVALUE_SET_STRING(v, str_value); \
89 gda_holder_set_value ((gda_param), &v, NULL); \
92 #define SDB_PARAM_SET_STATIC_STRING(gda_param, str_value) \
93 SDB_GVALUE_SET_STATIC_STRING(v, str_value); \
94 gda_holder_set_value ((gda_param), &v, NULL); \
97 #define SDB_PARAM_TAKE_STRING(gda_param, str_value) \
98 g_value_init (&v, G_TYPE_STRING); \
99 g_value_take_string (&v, (str_value)); \
100 gda_holder_set_value ((gda_param), &v, NULL); \
103 #define SDB_LOCK(priv) g_mutex_lock (&priv->mutex);
104 #define SDB_UNLOCK(priv) g_mutex_unlock (&priv->mutex);
108 PREP_QUERY_WORKSPACE_NEW
= 0,
109 PREP_QUERY_GET_WORKSPACE_ID_BY_UNIQUE_NAME
,
110 PREP_QUERY_PROJECT_NEW
,
111 PREP_QUERY_GET_PROJECT_ID_BY_UNIQUE_NAME
,
112 PREP_QUERY_UPDATE_PROJECT_ANALYSE_TIME
,
114 PREP_QUERY_GET_FILE_ID_BY_UNIQUE_NAME
,
115 PREP_QUERY_GET_ALL_FROM_FILE_BY_PROJECT_NAME
,
116 PREP_QUERY_UPDATE_FILE_ANALYSE_TIME
,
117 PREP_QUERY_GET_ALL_FROM_FILE_WHERE_NOT_IN_SYMBOLS
,
118 PREP_QUERY_LANGUAGE_NEW
,
119 PREP_QUERY_GET_LANGUAGE_ID_BY_UNIQUE_NAME
,
120 PREP_QUERY_SYM_KIND_NEW
,
121 PREP_QUERY_GET_SYM_KIND_BY_UNIQUE_NAME
,
122 PREP_QUERY_SYM_ACCESS_NEW
,
123 PREP_QUERY_GET_SYM_ACCESS_BY_UNIQUE_NAME
,
124 PREP_QUERY_SYM_IMPLEMENTATION_NEW
,
125 PREP_QUERY_GET_SYM_IMPLEMENTATION_BY_UNIQUE_NAME
,
126 PREP_QUERY_HERITAGE_NEW
,
127 PREP_QUERY_SCOPE_NEW
,
128 PREP_QUERY_GET_SCOPE_ID
,
129 PREP_QUERY_SYMBOL_NEW
,
130 PREP_QUERY_GET_SYMBOL_ID_BY_CLASS_NAME
,
131 PREP_QUERY_GET_SYMBOL_ID_BY_CLASS_NAME_AND_NAMESPACE
,
132 PREP_QUERY_UPDATE_SYMBOL_SCOPE_ID
,
133 PREP_QUERY_GET_SYMBOL_ID_BY_UNIQUE_INDEX_KEY_EXT
,
134 PREP_QUERY_UPDATE_SYMBOL_ALL
,
135 PREP_QUERY_REMOVE_NON_UPDATED_SYMBOLS
,
136 PREP_QUERY_RESET_UPDATE_FLAG_SYMBOLS
,
137 PREP_QUERY_GET_REMOVED_IDS
,
138 PREP_QUERY_TMP_REMOVED_DELETE_ALL
,
139 PREP_QUERY_REMOVE_FILE_BY_PROJECT_NAME
,
144 typedef struct _static_query_node
146 static_query_type query_id
;
147 const gchar
*query_str
;
153 /* normalize with iface naming */
154 typedef IAnjutaSymbolType SymType
;
156 typedef struct _DBESignal
163 /* the SymbolDBEngine Private structure */
164 struct _SymbolDBEnginePriv
166 gchar
*anjuta_db_file
;
170 GdaConnection
*db_connection
;
171 GdaSqlParser
*sql_parser
;
173 gchar
*project_directory
;
177 gint scan_process_id_sequence
;
178 gint current_scan_process_id
;
180 GAsyncQueue
*scan_aqueue
;
181 GAsyncQueue
*updated_syms_id_aqueue
;
182 GAsyncQueue
*updated_scope_syms_id_aqueue
;
183 GAsyncQueue
*inserted_syms_id_aqueue
;
184 gboolean is_scanning
;
186 gchar
*shared_mem_str
;
187 FILE *shared_mem_file
;
189 AnjutaLauncher
*ctags_launcher
;
190 GList
*removed_launchers
;
191 gboolean shutting_down
;
192 gboolean is_first_population
;
193 gsize symbols_scanned_count
;
195 GAsyncQueue
*waiting_scan_aqueue
;
196 gulong waiting_scan_handler
;
198 /* Threads management */
200 GAsyncQueue
* signals_aqueue
;
202 GThreadPool
*thread_pool
;
203 gint timeout_trigger_handler
;
204 gint trigger_closure_retries
;
205 gint thread_closure_retries
;
208 GHashTable
*sym_type_conversion_hash
;
209 GHashTable
*garbage_shared_mem_files
;
212 GHashTable
*kind_cache
;
213 GHashTable
*access_cache
;
214 GHashTable
*implementation_cache
;
215 GHashTable
*language_cache
;
218 GQueue
*tmp_heritage_tablemap
;
220 static_query_node
*static_query_list
[PREP_QUERY_COUNT
];
223 GTimer
*first_scan_timer_DEBUG
;