<commit_before>/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*- */
/* gck-object-cache.c - the GObject PKCS#11 wrapper library

   Copyright (C) 2011 Collabora Ltd.

   The Gnome Keyring Library is free software; you can redistribute it and/or
   modify it under the terms of the GNU Library General Public License as
   published by the Free Software Foundation; either version 2 of the
   License, or (at your option) any later version.

   The Gnome Keyring 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
   Library General Public License for more details.

   You should have received a copy of the GNU Library General Public
   License along with the Gnome Library; see the file COPYING.LIB.  If not,
   see <http://www.gnu.org/licenses/>.

   Author: <NAME> <<EMAIL>>
*/

#include "config.h"

#include "gck.h"
#include "gck-private.h"

#include <string.h>

/**
 * SECTION:gck-object-cache
 * @title: GckObjectCache
 * @short_description: An interface which holds attributes for a PKCS\#11 object
 *
 * #GckObjectCache is an interface implemented by derived classes of
 * #GckObject to indicate which attributes they'd like an enumerator to retrieve.
 * These attributes are then cached on the object and can be retrieved through
 * the #GckObjectCache:attributes property.
 */

/**
 * GckObjectCache:
 *
 * An interface implemented on an #GckObject which contains a cache of attributes.
 */

/**
 * GckObjectCacheIface:
 * @interface: parent interface
 * @default_types: (array length=n_default_types): attribute types that an
 *                   enumerator should retrieve
 * @n_default_types: number of attribute types to be retrieved
 * @fill: virtual method to add attributes to the cache
 *
 * Interface for #GckObjectCache. If the @default_types field is set by
 * a implementing class, then the a #GckEnumerator which has been setup using
 * gck_enumerator_set_object_type()
 *
 * The implementation for @populate should add the attributes to the
 * cache. It must be thread safe.
 */

typedef GckObjectCacheIface GckObjectCacheInterface;
G_DEFINE_INTERFACE (GckObjectCache, gck_object_cache, GCK_TYPE_OBJECT);

static void
gck_object_cache_default_init (GckObjectCacheIface *iface)
{
	static volatile gsize initialized = 0;
	if (g_once_init_enter (&initialized)) {

		/**
		 * GckObjectCache:attributes:
		 *
		 * The attributes cached on this object.
		 */
		g_object_interface_install_property (iface,
		         g_param_spec_boxed ("attributes", "Attributes", "PKCS#11 Attributes",
		                             GCK_TYPE_ATTRIBUTES, G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));

		g_once_init_leave (&initialized, 1);
	}
}

/**
 * gck_object_cache_get_attributes:<commit_msg>Add (skip) annotation to gck_object_cache_get_attributes<commit_after>/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*- */
/* gck-object-cache.c - the GObject PKCS#11 wrapper library

   Copyright (C) 2011 Collabora Ltd.

   The Gnome Keyring Library is free software; you can redistribute it and/or
   modify it under the terms of the GNU Library General Public License as
   published by the Free Software Foundation; either version 2 of the
   License, or (at your option) any later version.

   The Gnome Keyring 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
   Library General Public License for more details.

   You should have received a copy of the GNU Library General Public
   License along with the Gnome Library; see the file COPYING.LIB.  If not,
   see <http://www.gnu.org/licenses/>.

   Author: <NAME> <<EMAIL>>
*/

#include "config.h"

#include "gck.h"
#include "gck-private.h"

#include <string.h>

/**
 * SECTION:gck-object-cache
 * @title: GckObjectCache
 * @short_description: An interface which holds attributes for a PKCS\#11 object
 *
 * #GckObjectCache is an interface implemented by derived classes of
 * #GckObject to indicate which attributes they'd like an enumerator to retrieve.
 * These attributes are then cached on the object and can be retrieved through
 * the #GckObjectCache:attributes property.
 */

/**
 * GckObjectCache:
 *
 * An interface implemented on an #GckObject which contains a cache of attributes.
 */

/**
 * GckObjectCacheIface:
 * @interface: parent interface
 * @default_types: (array length=n_default_types): attribute types that an
 *                   enumerator should retrieve
 * @n_default_types: number of attribute types to be retrieved
 * @fill: virtual method to add attributes to the cache
 *
 * Interface for #GckObjectCache. If the @default_types field is set by
 * a implementing class, then the a #GckEnumerator which has been setup using
 * gck_enumerator_set_object_type()
 *
 * The implementation for @populate should add the attributes to the
 * cache. It must be thread safe.
 */

typedef GckObjectCacheIface GckObjectCacheInterface;
G_DEFINE_INTERFACE (GckObjectCache, gck_object_cache, GCK_TYPE_OBJECT);

static void
gck_object_cache_default_init (GckObjectCacheIface *iface)
{
	static volatile gsize initialized = 0;
	if (g_once_init_enter (&initialized)) {

		/**
		 * GckObjectCache:attributes:
		 *
		 * The attributes cached on this object.
		 */
		g_object_interface_install_property (iface,
		         g_param_spec_boxed ("attributes", "Attributes", "PKCS#11 Attributes",
		                             GCK_TYPE_ATTRIBUTES, G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));

		g_once_init_leave (&initialized, 1);
	}
}

/**
 * gck_object_cache_get_attributes: (skip):
{'fraction_non_alphanumeric': 0.07902472765000865, 'fraction_numerical': 0.005187618882932734, 'mean_word_length': 3.926746166950596, 'pattern_counts': {'":': 0, '<': 13, '<?xml version=': 0, '>': 13, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2093805', 'n_tokens_mistral': 1732, 'n_tokens_neox': 1648, 'n_words': 634}