Module - Accessor

Module - Accessor — A module class to extend features in lt_extension_t.

Synopsis

#define             LT_EXT_MODULE_VERSION
#define             LT_MODULE_SYMBOL                    (__sym__)
#define             LT_MODULE_SYMBOL_                   (__prefix__,
                                                         __sym__)
#define             LT_MODULE_SYMBOL__                  (__prefix__,
                                                         __sym__)
lt_ext_module_data_t * (*lt_ext_module_data_new_func_t) (void);
struct              lt_ext_module_funcs_t;
const lt_ext_module_funcs_t * (*lt_ext_module_get_funcs_func_t)
                                                        (void);
char *              (*lt_ext_module_get_tag_func_t)     (lt_ext_module_data_t *data);
lt_bool_t           (*lt_ext_module_parse_func_t)       (lt_ext_module_data_t *data,
                                                         const char *subtag,
                                                         lt_error_t **error);
lt_bool_t           (*lt_ext_module_precheck_func_t)    (lt_ext_module_data_t *data,
                                                         const lt_tag_t *tag,
                                                         lt_error_t **error);
lt_ext_module_t *   lt_ext_module_ref                   (lt_ext_module_t *module);
char                (*lt_ext_module_singleton_func_t)   (void);
                    lt_ext_module_t;
void                lt_ext_module_unref                 (lt_ext_module_t *module);
lt_bool_t           (*lt_ext_module_validate_func_t)    (lt_ext_module_data_t *data);
int                 (*lt_ext_module_version_func_t)     (void);
void                lt_ext_modules_load                 (void);
void                lt_ext_modules_unload               (void);
const lt_ext_module_funcs_t * module_get_funcs          (void);
int                 module_get_version                  (void);

Description

This class provides functionality to extend features in lt_extension_t, such as validating tags more strictly.

Details

LT_EXT_MODULE_VERSION

#define LT_EXT_MODULE_VERSION		1

Static variable for the module version. this is used to ensure if the built module is compatible with the runtime library.


LT_MODULE_SYMBOL()

#  define LT_MODULE_SYMBOL(__sym__)		LT_MODULE_SYMBOL_(LT_MODULE_PREFIX, __sym__)


LT_MODULE_SYMBOL_()

#define LT_MODULE_SYMBOL_(__prefix__,__sym__) LT_MODULE_SYMBOL__(__prefix__, __sym__)


LT_MODULE_SYMBOL__()

#define LT_MODULE_SYMBOL__(__prefix__,__sym__) __prefix__##_module_##__sym__


lt_ext_module_data_new_func_t ()

lt_ext_module_data_t * (*lt_ext_module_data_new_func_t) (void);

The type of the callback function used to create a new instance of lt_ext_module_data_t. This is invoked when new Extension subtag appears and keep data.

Returns :

a new instance of lt_ext_module_data_t.

struct lt_ext_module_funcs_t

struct lt_ext_module_funcs_t {
	const lt_ext_module_singleton_func_t get_singleton;
	const lt_ext_module_data_new_func_t  create_data;
	const lt_ext_module_precheck_func_t  precheck_tag;
	const lt_ext_module_parse_func_t     parse_tag;
	const lt_ext_module_get_tag_func_t   get_tag;
	const lt_ext_module_validate_func_t  validate_tag;
};

The lt_ext_module_funcs_t struct is a callback collection to provide an accessor between lt_extension_t and lt_ext_module_t and extend features.

const lt_ext_module_singleton_func_t get_singleton;

A callback function to obtain the singleton character that are supposed in the module.

const lt_ext_module_data_new_func_t create_data;

A callback function to create a new instance of lt_ext_module_data_t for the module.

const lt_ext_module_precheck_func_t precheck_tag;

A callback function to check tags prior to parse subtags.

const lt_ext_module_parse_func_t parse_tag;

A callback function to parse a tag.

const lt_ext_module_get_tag_func_t get_tag;

A callback function to obtain the tag string.

const lt_ext_module_validate_func_t validate_tag;

A callback function to validate the tag.

lt_ext_module_get_funcs_func_t ()

const lt_ext_module_funcs_t * (*lt_ext_module_get_funcs_func_t)
                                                        (void);

The type of the module_get_funcs() that is required to implement an extension module.

Returns :

a lt_ext_module_funcs_t. [transfer none]

lt_ext_module_get_tag_func_t ()

char *              (*lt_ext_module_get_tag_func_t)     (lt_ext_module_data_t *data);

The type of the callback function used to obtain the tag.

data :

a lt_ext_module_data_t.

Returns :

a tag string.

lt_ext_module_parse_func_t ()

lt_bool_t           (*lt_ext_module_parse_func_t)       (lt_ext_module_data_t *data,
                                                         const char *subtag,
                                                         lt_error_t **error);

The type of the callback function used to parse tags.

data :

a lt_ext_module_data_t.

subtag :

a subtag string to parse.

error :

a lt_error_t. [allow-none]

Returns :

TRUE if the subtag is valid for Extension. otherwise FALSE.

lt_ext_module_precheck_func_t ()

lt_bool_t           (*lt_ext_module_precheck_func_t)    (lt_ext_module_data_t *data,
                                                         const lt_tag_t *tag,
                                                         lt_error_t **error);

The type of the callback function used to check tag prior to process parsing subtags for the extension.

data :

a lt_ext_module_data_t.

tag :

a lt_tag_t.

error :

a lt_error_t. [allow-none]

Returns :

TRUE if tag is valid to process parsing subtags for the extension. otherwise FALSE.

lt_ext_module_ref ()

lt_ext_module_t *   lt_ext_module_ref                   (lt_ext_module_t *module);

Increases the reference count of module.

module :

a lt_ext_module_t.

Returns :

the same module object. [transfer none]

lt_ext_module_singleton_func_t ()

char                (*lt_ext_module_singleton_func_t)   (void);

The type of the callback function used to obtain a singleton character for Extension subtag that the module would support.

Returns :

a singleton character.

lt_ext_module_t

typedef struct _lt_ext_module_t lt_ext_module_t;

All the fields in the lt_ext_module_t structure are private to the lt_ext_module_t implementation.


lt_ext_module_unref ()

void                lt_ext_module_unref                 (lt_ext_module_t *module);

Decreases the reference count of module. when its reference count drops to 0, the object is finalized (i.e. its memory is freed).

module :

a lt_ext_module_t.

lt_ext_module_validate_func_t ()

lt_bool_t           (*lt_ext_module_validate_func_t)    (lt_ext_module_data_t *data);

The type of the callback function used to validate the tags in data.

data :

a lt_ext_module_data_t.

Returns :

TRUE if it's valid, otherwise FALSE.

lt_ext_module_version_func_t ()

int                 (*lt_ext_module_version_func_t)     (void);

The type of the module_get_version() that is required to implement an extension module.

Returns :

a version number. this is the same to LT_EXT_MODULE_VERSION when the module was built.

lt_ext_modules_load ()

void                lt_ext_modules_load                 (void);

Load all of the modules on the system, including the internal accessor. This has to be invoked before processing something with lt_extension_t. or lt_db_initialize() does.


lt_ext_modules_unload ()

void                lt_ext_modules_unload               (void);

Unload all of the modules already loaded.


module_get_funcs ()

const lt_ext_module_funcs_t * module_get_funcs          (void);

Obtains a lt_ext_module_funcs_t, callback collection structure that the module would process. this must be implemented in the external module.

Returns :

a lt_ext_module_funcs_t.

module_get_version ()

int                 module_get_version                  (void);

Obtains the module version. this must be implemented in a module.

Returns :

a version number. this is the same to LT_EXT_MODULE_VERSION when the module was built.