<commit_before>/*
 * Copyright (C) 2010, 2011 Igalia S.L.
 *
 * Contact: <NAME> <<EMAIL>>
 *
 * This library is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Lesser General Public License
 * as published by the Free Software Foundation; version 2.1 of
 * the License, or (at your option) any later version.
 *
 * This library is distributed in the hope that it will be useful, but
 * WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
 * Lesser General Public License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public
 * License along with this library; if not, write to the Free Software
 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
 * 02110-1301 USA
 *
 */

#if !defined (_GRILO_H_INSIDE_) && !defined (GRILO_COMPILATION)
#error "Only <grilo.h> can be included directly."
#endif

#ifndef _GRL_REGISTRY_H_
#define _GRL_REGISTRY_H_

#include <glib.h>
#include <glib-object.h>
#include <gmodule.h>

#include <grl-source.h>
#include <grl-metadata-key.h>
#include <grl-config.h>
#include <grl-definitions.h>
#include <grl-plugin.h>

#define GRL_PLUGIN_PATH_VAR "GRL_PLUGIN_PATH"
#define GRL_PLUGIN_LIST_VAR "GRL_PLUGIN_LIST"
#define GRL_PLUGIN_RANKS_VAR "GRL_PLUGIN_RANKS"

/* Macros */

#define GRL_TYPE_REGISTRY                       \
  (grl_registry_get_type ())

#define GRL_REGISTRY(obj)                                       \
  (G_TYPE_CHECK_INSTANCE_CAST ((obj),                           \
                               GRL_TYPE_REGISTRY,               \
                               GrlRegistry))

#define GRL_IS_REGISTRY(obj)                                    \
  (G_TYPE_CHECK_INSTANCE_TYPE ((obj),                           \
                               GRL_TYPE_REGISTRY))

#define GRL_REGISTRY_CLASS(klass)                       \
  (G_TYPE_CHECK_CLASS_CAST((klass),                     \
                           GRL_TYPE_REGISTRY,           \
                           GrlRegistryClass))

#define GRL_IS_REGISTRY_CLASS(klass)                    \
  (G_TYPE_CHECK_CLASS_TYPE((klass),                     \
                           GRL_TYPE_REGISTRY))

#define GRL_REGISTRY_GET_CLASS(obj)                     \
  (G_TYPE_INSTANCE_GET_CLASS ((obj),                    \
                              GRL_TYPE_REGISTRY,        \
                              GrlRegistryClass))

/* Plugin registration */

/**
* GRL_PLUGIN_DEFINE:
* @major_version: the major version number of core that plugin was compiled for
* @minor_version: the minor version number of core that plugin was compiled for
* @id: the plugin identifier
* @name: name of plugin
* @description: description of plugin
* @author: author of plugin
* @version: version of plugin
* @license: license of plugin
* @site: URL to provider of plugin
* @init: the module initialization. It shall instantiate
* the #GrlPlugins provided
* @deinit: (allow-none): function to execute when the registry needs to dispose
* the module.
* @register_keys: (allow-none): function to execute before loading the
* plugin. It's aim is to register new keys
*
* Since: 0.3.0
*/
#define GRL_PLUGIN_DEFINE(major,                                \
                          minor,                                \
                          id,                                   \
                          name,                                 \
                          description,                          \
                          author,                               \
                          version,                              \
                          license,                              \
                          site,                                 \
                          init,                                 \
                          deinit,                               \
                          register_keys)                        \
  G_MODULE_EXPORT GrlPluginDescriptor GRL_PLUGIN_DESCRIPTOR = { \
    major,                                                      \
    minor,                                                      \
    id,                                                         \
    name,                                                       \
    description,                                                \
    author,                                                     \
    version,                                                    \
    license,                                                    \
    site,                                                       \
    init,                                                       \
    deinit,                                                     \
    register_keys                                               \
  }

/* Plugin descriptor */

typedef struct _GrlRegistry GrlRegistry;

typedef struct _GrlPluginDescriptor  GrlPluginDescriptor;

typedef gboolean (*GrlPluginInitFunc) (GrlRegistry *registry,
                                       GrlPlugin *plugin,
                                       GList *configs);

typedef void (*GrlPluginDeinitFunc) (GrlPlugin *plugin);

typedef void (*GrlPluginRegisterKeysFunc) (GrlRegistry *registry,
                                           GrlPlugin *plugin);

/**
* GrlPluginDescriptor:
* @major_version: the major version number of core that plugin was compiled for
* @minor_version: the minor version number of core that plugin was compiled for
* @id: the plugin identifier
* @name: name of plugin
* @description: description of plugin
* @author: author of plugin
* @version: version of plugin
* @license: license of plugin
* @site: URL to provider of plugin
* @plugin_init: the module initialization. It shall instantiate
* the #GrlPlugins provided
* @plugin_deinit: function to execute when the registry needs
* to dispose the module.
* @plugin_register_keys: function to execute before loading the plugin. It's aim
* is to register new keys
*
* This structure is used for the module loader
*
* Since: 0.3.0
*/
struct _GrlPluginDescriptor {
  gint major_version;
  gint minor_version;
  gchar *id;
  gchar *name;
  gchar *description;
  gchar *author;
  gchar *version;<commit_msg>core: Fix documentation for GrlPluginDescriptor<commit_after>/*
 * Copyright (C) 2010, 2011 Igalia S.L.
 *
 * Contact: <NAME> <<EMAIL>>
 *
 * This library is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Lesser General Public License
 * as published by the Free Software Foundation; version 2.1 of
 * the License, or (at your option) any later version.
 *
 * This library is distributed in the hope that it will be useful, but
 * WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
 * Lesser General Public License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public
 * License along with this library; if not, write to the Free Software
 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
 * 02110-1301 USA
 *
 */

#if !defined (_GRILO_H_INSIDE_) && !defined (GRILO_COMPILATION)
#error "Only <grilo.h> can be included directly."
#endif

#ifndef _GRL_REGISTRY_H_
#define _GRL_REGISTRY_H_

#include <glib.h>
#include <glib-object.h>
#include <gmodule.h>

#include <grl-source.h>
#include <grl-metadata-key.h>
#include <grl-config.h>
#include <grl-definitions.h>
#include <grl-plugin.h>

#define GRL_PLUGIN_PATH_VAR "GRL_PLUGIN_PATH"
#define GRL_PLUGIN_LIST_VAR "GRL_PLUGIN_LIST"
#define GRL_PLUGIN_RANKS_VAR "GRL_PLUGIN_RANKS"

/* Macros */

#define GRL_TYPE_REGISTRY                       \
  (grl_registry_get_type ())

#define GRL_REGISTRY(obj)                                       \
  (G_TYPE_CHECK_INSTANCE_CAST ((obj),                           \
                               GRL_TYPE_REGISTRY,               \
                               GrlRegistry))

#define GRL_IS_REGISTRY(obj)                                    \
  (G_TYPE_CHECK_INSTANCE_TYPE ((obj),                           \
                               GRL_TYPE_REGISTRY))

#define GRL_REGISTRY_CLASS(klass)                       \
  (G_TYPE_CHECK_CLASS_CAST((klass),                     \
                           GRL_TYPE_REGISTRY,           \
                           GrlRegistryClass))

#define GRL_IS_REGISTRY_CLASS(klass)                    \
  (G_TYPE_CHECK_CLASS_TYPE((klass),                     \
                           GRL_TYPE_REGISTRY))

#define GRL_REGISTRY_GET_CLASS(obj)                     \
  (G_TYPE_INSTANCE_GET_CLASS ((obj),                    \
                              GRL_TYPE_REGISTRY,        \
                              GrlRegistryClass))

/* Plugin registration */

/**
* GRL_PLUGIN_DEFINE:
* @major_version: the major version number of core that plugin was compiled for
* @minor_version: the minor version number of core that plugin was compiled for
* @id: the plugin identifier
* @name: name of plugin
* @description: description of plugin
* @author: author of plugin
* @version: version of plugin
* @license: license of plugin
* @site: URL to provider of plugin
* @init: the module initialization. It shall instantiate
* the #GrlPlugins provided
* @deinit: (allow-none): function to execute when the registry needs to dispose
* the module.
* @register_keys: (allow-none): function to execute before loading the
* plugin. It's aim is to register new keys
*
* Since: 0.3.0
*/
#define GRL_PLUGIN_DEFINE(major,                                \
                          minor,                                \
                          id,                                   \
                          name,                                 \
                          description,                          \
                          author,                               \
                          version,                              \
                          license,                              \
                          site,                                 \
                          init,                                 \
                          deinit,                               \
                          register_keys)                        \
  G_MODULE_EXPORT GrlPluginDescriptor GRL_PLUGIN_DESCRIPTOR = { \
    major,                                                      \
    minor,                                                      \
    id,                                                         \
    name,                                                       \
    description,                                                \
    author,                                                     \
    version,                                                    \
    license,                                                    \
    site,                                                       \
    init,                                                       \
    deinit,                                                     \
    register_keys                                               \
  }

/* Plugin descriptor */

typedef struct _GrlRegistry GrlRegistry;

typedef struct _GrlPluginDescriptor  GrlPluginDescriptor;

typedef gboolean (*GrlPluginInitFunc) (GrlRegistry *registry,
                                       GrlPlugin *plugin,
                                       GList *configs);

typedef void (*GrlPluginDeinitFunc) (GrlPlugin *plugin);

typedef void (*GrlPluginRegisterKeysFunc) (GrlRegistry *registry,
                                           GrlPlugin *plugin);

/**
* GrlPluginDescriptor:
* @major_version: the major version number of core that plugin was compiled for
* @minor_version: the minor version number of core that plugin was compiled for
* @id: the plugin identifier
* @name: name of plugin
* @description: description of plugin
* @author: author of plugin
* @version: version of plugin
* @license: license of plugin
* @site: URL to provider of plugin
* @init: the module initialization. It shall instantiate
* the #GrlPlugins provided
* @deinit: function to execute when the registry needs
* to dispose the module.
* @register_keys: function to execute before loading the plugin. It's aim
* is to register new keys
*
* This structure is used for the module loader
*
* Since: 0.3.0
*/
struct _GrlPluginDescriptor {
  gint major_version;
  gint minor_version;
  gchar *id;
  gchar *name;
  gchar *description;
  gchar *author;
  gchar *version;
{'fraction_non_alphanumeric': 0.06798123558877316, 'fraction_numerical': 0.004293551721396199, 'mean_word_length': 1.3159639108819738, 'pattern_counts': {'":': 0, '<': 27, '<?xml version=': 0, '>': 27, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 64, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6843266', 'n_tokens_mistral': 3185, 'n_tokens_neox': 3057, 'n_words': 947}