project_files/frontlib/model/schemelist.h
changeset 7230 240620f46dd7
child 7314 6171f0bad318
equal deleted inserted replaced
7227:1c859f572d72 7230:240620f46dd7
       
     1 /**
       
     2  * Functions for managing a list of schemes.
       
     3  * This is in here because the scheme config file of the QtFrontend (which we are staying compatble with) contains
       
     4  * all the schemes at once, so we need functions to work with a list like that.
       
     5  */
       
     6 
       
     7 #ifndef SCHEMELIST_H_
       
     8 #define SCHEMELIST_H_
       
     9 
       
    10 #include "cfg.h"
       
    11 
       
    12 typedef struct {
       
    13 	int _referenceCount;
       
    14 	int schemeCount;
       
    15 	flib_cfg **schemes;
       
    16 } flib_schemelist;
       
    17 
       
    18 /**
       
    19  * Load a list of configurations from the ini file.
       
    20  * Returns NULL on error.
       
    21  */
       
    22 flib_schemelist *flib_schemelist_from_ini(flib_cfg_meta *meta, const char *filename);
       
    23 
       
    24 /**
       
    25  * Store the list of configurations to an ini file.
       
    26  * Returns NULL on error.
       
    27  */
       
    28 int flib_schemelist_to_ini(const char *filename, const flib_schemelist *config);
       
    29 
       
    30 /**
       
    31  * Create an empty scheme list. Returns NULL on error.
       
    32  */
       
    33 flib_schemelist *flib_schemelist_create();
       
    34 
       
    35 /**
       
    36  * Insert a new scheme into the list at position pos, moving all higher schemes to make place.
       
    37  * pos must be at least 0 (insert at the start) and at most list->schemeCount (insert at the end).
       
    38  * The scheme is retained automatically.
       
    39  * Returns 0 on success.
       
    40  */
       
    41 int flib_schemelist_insert(flib_schemelist *list, flib_cfg *cfg, int pos);
       
    42 
       
    43 /**
       
    44  * Delete a cfg from the list at position pos, moving down all higher schemes.
       
    45  * The scheme is released automatically.
       
    46  * Returns 0 on success.
       
    47  */
       
    48 int flib_schemelist_delete(flib_schemelist *list, int pos);
       
    49 
       
    50 /**
       
    51  * Find the scheme with a specific name
       
    52  */
       
    53 flib_cfg *flib_schemelist_find(flib_schemelist *list, const char *name);
       
    54 
       
    55 /**
       
    56  * Increase the reference count of the object. Call this if you store a pointer to it somewhere.
       
    57  * Returns the parameter.
       
    58  */
       
    59 flib_schemelist *flib_schemelist_retain(flib_schemelist *list);
       
    60 
       
    61 /**
       
    62  * Decrease the reference count of the object and free it if this was the last reference.
       
    63  */
       
    64 void flib_schemelist_release(flib_schemelist *list);
       
    65 
       
    66 
       
    67 #endif /* SCHEMELIST_H_ */