1 /* EXTRAITS DE LA LICENCE 2 Copyright CEA, contributeurs : Luc BILLARD et Damien 3 CALISTE, laboratoire L_Sim, (2001-2005) 4 5 Adresse mèl : 6 BILLARD, non joignable par mèl ; 7 CALISTE, damien P caliste AT cea P fr. 8 9 Ce logiciel est un programme informatique servant à visualiser des 10 structures atomiques dans un rendu pseudo-3D. 11 12 Ce logiciel est régi par la licence CeCILL soumise au droit français et 13 respectant les principes de diffusion des logiciels libres. Vous pouvez 14 utiliser, modifier et/ou redistribuer ce programme sous les conditions 15 de la licence CeCILL telle que diffusée par le CEA, le CNRS et l'INRIA 16 sur le site "http://www.cecill.info". 17 18 Le fait que vous puissiez accéder à cet en-tête signifie que vous avez 19 pris connaissance de la licence CeCILL, et que vous en avez accepté les 20 termes (cf. le fichier Documentation/licence.fr.txt fourni avec ce logiciel). 21 */ 22 23 /* LICENCE SUM UP 24 Copyright CEA, contributors : Luc BILLARD et Damien 25 CALISTE, laboratoire L_Sim, (2001-2005) 26 27 E-mail address: 28 BILLARD, not reachable any more ; 29 CALISTE, damien P caliste AT cea P fr. 30 31 This software is a computer program whose purpose is to visualize atomic 32 configurations in 3D. 33 34 This software is governed by the CeCILL license under French law and 35 abiding by the rules of distribution of free software. You can use, 36 modify and/ or redistribute the software under the terms of the CeCILL 37 license as circulated by CEA, CNRS and INRIA at the following URL 38 "http://www.cecill.info". 39 40 The fact that you are presently reading this means that you have had 41 knowledge of the CeCILL license and that you accept its terms. You can 42 find a copy of this licence shipped with this software at Documentation/licence.en.txt. 43 */ 44 45 #ifndef VISU_CONFIG_FILE_H 46 #define VISU_CONFIG_FILE_H 47 48 #include <glib.h> 49 #include <glib-object.h> 50 #include <stdarg.h> 51 #include <visu_data.h> 52 #include <coreTools/toolColor.h> 53 54 typedef struct _VisuConfigFileEntry VisuConfigFileEntry; 55 56 /** 57 * VisuConfigFileKind: 58 * @VISU_CONFIG_FILE_KIND_PARAMETER: a kind of configuration that is 59 * used to change settings in the way V_Sim is working. 60 * @VISU_CONFIG_FILE_KIND_RESOURCE: a kind of configuartion that is 61 * used to change the rendering output of V_Sim. 62 * 63 * This defines a parameter entry in the config files. 64 */ 65 typedef enum { 66 VISU_CONFIG_FILE_KIND_PARAMETER, 67 VISU_CONFIG_FILE_KIND_RESOURCE 68 } VisuConfigFileKind; 69 70 /** 71 * VISU_TYPE_CONFIG_FILE: 72 * 73 * return the type of #VisuConfigFile. 74 */ 75 #define VISU_TYPE_CONFIG_FILE (visu_config_file_get_type ()) 76 /** 77 * VISU_CONFIG_FILE: 78 * @obj: a #GObject to cast. 79 * 80 * Cast the given @obj into #VisuConfigFile type. 81 */ 82 #define VISU_CONFIG_FILE(obj) (G_TYPE_CHECK_INSTANCE_CAST(obj, VISU_TYPE_CONFIG_FILE, VisuConfigFile)) 83 /** 84 * VISU_CONFIG_FILE_CLASS: 85 * @klass: a #GObjectClass to cast. 86 * 87 * Cast the given @klass into #VisuConfigFileClass. 88 */ 89 #define VISU_CONFIG_FILE_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST(klass, VISU_TYPE_CONFIG_FILE, VisuConfigFileClass)) 90 /** 91 * VISU_IS_CONFIG_FILE: 92 * @obj: a #GObject to test. 93 * 94 * Test if the given @ogj is of the type of #VisuConfigFile object. 95 */ 96 #define VISU_IS_CONFIG_FILE(obj) (G_TYPE_CHECK_INSTANCE_TYPE(obj, VISU_TYPE_CONFIG_FILE)) 97 /** 98 * VISU_IS_CONFIG_FILE_CLASS: 99 * @klass: a #GObjectClass to test. 100 * 101 * Test if the given @klass is of the type of #VisuConfigFileClass class. 102 */ 103 #define VISU_IS_CONFIG_FILE_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE(klass, VISU_TYPE_CONFIG_FILE)) 104 /** 105 * VISU_CONFIG_FILE_GET_CLASS: 106 * @obj: a #GObject to get the class of. 107 * 108 * It returns the class of the given @obj. 109 */ 110 #define VISU_CONFIG_FILE_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS(obj, VISU_TYPE_CONFIG_FILE, VisuConfigFileClass)) 111 112 typedef struct _VisuConfigFilePrivate VisuConfigFilePrivate; 113 typedef struct _VisuConfigFile VisuConfigFile; 114 struct _VisuConfigFile 115 { 116 VisuObject parent; 117 118 VisuConfigFilePrivate *priv; 119 }; 120 121 /** 122 * VisuConfigFileClass: 123 * @parent: the parent class. 124 * 125 * A short way to identify #_VisuConfigFileClass structure. 126 */ 127 typedef struct _VisuConfigFileClass VisuConfigFileClass; 128 struct _VisuConfigFileClass 129 { 130 VisuObjectClass parent; 131 }; 132 133 /** 134 * visu_config_file_get_type: 135 * 136 * This method returns the type of #VisuConfigFile, use VISU_TYPE_CONFIG_FILE instead. 137 * 138 * Returns: the type of #VisuConfigFile. 139 */ 140 GType visu_config_file_get_type(void); 141 142 VisuConfigFile* visu_config_file_getStatic(VisuConfigFileKind kind); 143 144 /** 145 * VISU_CONFIG_FILE_RESOURCE: 146 * 147 * Default instance of #VisuConfigFile object handling resource data. 148 * 149 * Since: 3.8 150 */ 151 #define VISU_CONFIG_FILE_RESOURCE visu_config_file_getStatic(VISU_CONFIG_FILE_KIND_RESOURCE) 152 /** 153 * VISU_CONFIG_FILE_PARAMETER: 154 * 155 * Default instance of #VisuConfigFile object handling parameter data. 156 * 157 * Since: 3.8 158 */ 159 #define VISU_CONFIG_FILE_PARAMETER visu_config_file_getStatic(VISU_CONFIG_FILE_KIND_PARAMETER) 160 161 /** 162 * VisuConfigFileReadFunc: 163 * @entry: the #VisuConfigFileEntry that raises this callback. 164 * @lines: an array of strings ; 165 * @nbLines: an integer ; 166 * @position: an integer ; 167 * @error: a pointer to a GError pointer. 168 * 169 * This prototype corresponds to methods called when an entry is 170 * found. The @lines argument is an array of lines read from the files. 171 * These strings are copies and can be modified but not freed. There are 172 * @nbLines and this value correspond to the number of lines defined 173 * for the entry. The @error argument is used to store some text 174 * messages and error ids. They should be in UTF8. The @error argument 175 * must be initialised with (GError*)0. The @position argument give the number 176 * of the first line given in @lines argument. 177 * 178 * Returns: TRUE if everything goes right, FALSE otherwise. 179 */ 180 typedef gboolean (*VisuConfigFileReadFunc)(VisuConfigFileEntry *entry, 181 gchar **lines, int nbLines, 182 int position, GError **error); 183 /** 184 * VisuConfigFileExportFunc: 185 * @data: an empty GString to store the export ; 186 * @dataObj: (allow-none): a #VisuData object ; 187 * 188 * This prototype defines a method that is used to export some resources 189 * or parameters. The @data argument is an empty GString where the export has 190 * to be written. If the argument @dataObj is not null, only resources related 191 * to the #VisuData object should be exported (for parameters files, @dataObj is 192 * always NULL). 193 */ 194 typedef void (*VisuConfigFileExportFunc)(GString *data, VisuData* dataObj); 195 196 /** 197 * VisuConfigFileEnumFunc: 198 * @label: a string. 199 * @value: a location to store an enum value. 200 * 201 * Try to match @label with a enum @value. 202 * 203 * Since: 3.8 204 * 205 * Returns: TRUE if found. 206 */ 207 typedef gboolean (*VisuConfigFileEnumFunc)(const gchar *label, guint *value); 208 /** 209 * VisuConfigFileForeachFuncExport: 210 * @data: the string where the values are exported to ; 211 * @dataObj: the current #VisuData object, values are related to. 212 * 213 * This structure can be used to encapsulate the arguments of an export method 214 * when used in a foreach glib loop. 215 */ 216 struct _VisuConfigFileForeachFuncExport 217 { 218 GString *data; 219 VisuData *dataObj; 220 }; 221 222 GType visu_config_file_entry_get_type(void); 223 #define VISU_TYPE_CONFIG_FILE_ENTRY (visu_config_file_entry_get_type()) 224 225 VisuConfigFileEntry* visu_config_file_addEntry(VisuConfigFile *conf, const gchar *key, 226 const gchar* description, int nbLines, 227 VisuConfigFileReadFunc readFunc); 228 VisuConfigFileEntry* visu_config_file_ignoreEntry(VisuConfigFile *conf, const gchar *key, 229 guint nbLines); 230 VisuConfigFileEntry* visu_config_file_addTokenizedEntry(VisuConfigFile *conf, const gchar *key, 231 const gchar* description, 232 gboolean labelled); 233 VisuConfigFileEntry* visu_config_file_addBooleanEntry(VisuConfigFile *conf, const gchar *key, 234 const gchar* description, 235 gboolean *location, gboolean labelled); 236 VisuConfigFileEntry* visu_config_file_addBooleanArrayEntry(VisuConfigFile *conf, const gchar *key, 237 const gchar* description, 238 guint nValues, gboolean *location, 239 gboolean labelled); 240 VisuConfigFileEntry* visu_config_file_addIntegerArrayEntry(VisuConfigFile *conf, const gchar *key, 241 const gchar* description, 242 guint nValues, int *location, 243 int clamp[2], gboolean labelled); 244 VisuConfigFileEntry* visu_config_file_addFloatArrayEntry(VisuConfigFile *conf, const gchar *key, 245 const gchar* description, 246 guint nValues, float *location, 247 float clamp[2], gboolean labelled); 248 VisuConfigFileEntry* visu_config_file_addEnumEntry(VisuConfigFile *conf, const gchar *key, 249 const gchar* description, guint *location, 250 VisuConfigFileEnumFunc toEnum, 251 gboolean labelled); 252 VisuConfigFileEntry* visu_config_file_addStringEntry(VisuConfigFile *conf, const gchar *key, 253 const gchar* description, 254 gchar **location); 255 VisuConfigFileEntry* visu_config_file_addStippleArrayEntry(VisuConfigFile *conf, const gchar *key, 256 const gchar* description, 257 guint nValues, guint16 *location); 258 void visu_config_file_addExportFunction(VisuConfigFile *conf, VisuConfigFileExportFunc writeFunc); 259 260 void visu_config_file_entry_setTag(VisuConfigFileEntry *entry, const gchar *tag); 261 void visu_config_file_entry_setVersion(VisuConfigFileEntry *entry, float version); 262 void visu_config_file_entry_setReplace(VisuConfigFileEntry *newEntry, 263 VisuConfigFileEntry *oldEntry); 264 const gchar* visu_config_file_entry_getKey(const VisuConfigFileEntry *entry); 265 const gchar* visu_config_file_entry_getLabel(const VisuConfigFileEntry *entry); 266 gboolean visu_config_file_entry_popToken(VisuConfigFileEntry *entry, const gchar **value); 267 gboolean visu_config_file_entry_popTokenAsBoolean(VisuConfigFileEntry *entry, guint nValues, 268 gboolean *values); 269 gboolean visu_config_file_entry_popTokenAsInt(VisuConfigFileEntry *entry, guint nValues, 270 int *values, const int clamp[2]); 271 gboolean visu_config_file_entry_popTokenAsColor(VisuConfigFileEntry *entry, const ToolColor **color); 272 gboolean visu_config_file_entry_popTokenAsFloat(VisuConfigFileEntry *entry, guint nValues, 273 float *values, const float clamp[2]); 274 gboolean visu_config_file_entry_popTokenAsEnum(VisuConfigFileEntry *entry, guint *value, 275 VisuConfigFileEnumFunc toEnum); 276 gchar* visu_config_file_entry_popAllTokens(VisuConfigFileEntry *entry); 277 void visu_config_file_entry_setErrorMessage(VisuConfigFileEntry *entry, const gchar *mess, ...); 278 279 gboolean visu_config_file_load(VisuConfigFile *conf, const char* filename, GError **error); 280 gboolean visu_config_file_loadCommandLine(GError **error); 281 gboolean visu_config_file_save(VisuConfigFile *conf, const char* fileName, int *lines, 282 VisuData *dataObj, GError **error); 283 gboolean visu_config_file_saveResourcesToXML(const char* filename, int *lines, 284 VisuData *dataObj, GError **error); 285 286 void visu_config_file_addKnownTag(gchar* tag); 287 288 void visu_config_file_exportComment(GString *buffer, const gchar *comment); 289 void visu_config_file_exportEntry(GString *buffer, const gchar *name, 290 const gchar *id_value, const gchar *format_, ...); 291 292 gchar* visu_config_file_getValidPath(VisuConfigFile *conf, int mode, int utf8); 293 gchar* visu_config_file_getNextValidPath(VisuConfigFile *conf, int accessMode, GList **list, int utf8); 294 const gchar* visu_config_file_getDefaultFilename(VisuConfigFileKind kind); 295 GList* visu_config_file_getPathList(VisuConfigFile *conf); 296 297 298 GList* visu_config_file_getEntries(VisuConfigFile *conf); 299 gboolean visu_config_file_exportToXML(VisuConfigFile *conf, const gchar *filename, GError **error); 300 301 const gchar* visu_config_file_getPath(VisuConfigFile *conf); 302 303 #endif 304