libqaeda

Unnamed repository; edit this file 'description' to name the repository.
Info | Log | Files | Refs | README | LICENSE

config.h (1738B)


      1 #ifndef LQ_CONFIG_H_
      2 #define LQ_CONFIG_H_
      3 
      4 #ifndef LQ_CONFIG_MEMCAP
      5 #define LQ_CONFIG_MEMCAP 65536
      6 #endif
      7 
      8 #ifndef LQ_CONFIG_MAX
      9 #define LQ_CONFIG_MAX 128
     10 #endif
     11 
     12 #include "lq/mem.h"
     13 
     14 /**
     15  * \brief Configuration data types
     16  */
     17 enum lq_typ_e {
     18 	LQ_TYP_VOID,
     19 	LQ_TYP_NUM,
     20 	LQ_TYP_STR,
     21 };
     22 
     23 /**
     24  * \brief Core configuration keys.
     25  */
     26 enum lq_config_core_e {
     27 	LQ_CFG_DIR_BASE, ///< Base working directory.
     28 	LQ_CFG_DIR_CONFIG, ///< Configurations directory.
     29 	LQ_CFG_DIR_DATA, ///< Data directory.
     30 	LQ_CFG_DIR_CACHE, ///< Cache directory.
     31 	LQ_CFG_LAST, ///< Start of subsystem defined configuration keys.
     32 };
     33 
     34 
     35 /**
     36  * \brief Initialize the instance-wide config singleton.
     37  *
     38  * \warning This method is called by lq_init, and should most likely not be called directly.
     39  *
     40  * \return ERR_OK on success.
     41  *
     42  * \see lq_init
     43  */
     44 int lq_config_init();
     45 
     46 /**
     47  * \brief Register a configuration key/value pair.
     48  *
     49  * \param[in] Type of value to be stored under key.
     50  * \param[in] Configuration key.
     51  * \return ERR_OK on success.
     52  */
     53 int lq_config_register(enum lq_typ_e typ, const char *name);
     54 
     55 /**
     56  * \brief Set value for a configuration key.
     57  *
     58  * \param[in] Configuration key.
     59  * \param[in] Value to set. Must correspond to the previously registered value type.
     60  * \return ERR_OK on success.
     61  *
     62  * \see lq_config_register
     63  */
     64 int lq_config_set(int k, void *v); 
     65 
     66 /**
     67  * \brief Retrieve a value stored under a configuration key.
     68  *
     69  * \param[in] Configuration key.
     70  * \param[out] Pointer to value write location. Must have sufficient to hold the registered value type.
     71  * \return ERR_OK on success.
     72  *
     73  * \see lq_config_register
     74  */
     75 int lq_config_get(int k, void **r);
     76 
     77 /**
     78  * \brief Release configuration resources.
     79  */
     80 void lq_config_free();
     81 
     82 #endif