Changed return value to void.
2000-11-26 Martin Baulig <martin@home-of-linux.org> * include/glibtop/glibtop-client.h (glibtop_client_open_backend): Changed return value to void. * lib/glibtop-client.c: Implement glibtop_client_add_backend() and glibtop_client_remove_backend().
This commit is contained in:
committed by
Martin Baulig
parent
16b81f0d91
commit
98930be564
@@ -1,5 +1,11 @@
|
|||||||
2000-11-26 Martin Baulig <martin@home-of-linux.org>
|
2000-11-26 Martin Baulig <martin@home-of-linux.org>
|
||||||
|
|
||||||
|
* include/glibtop/glibtop-client.h (glibtop_client_open_backend):
|
||||||
|
Changed return value to void.
|
||||||
|
|
||||||
|
* lib/glibtop-client.c: Implement glibtop_client_add_backend() and
|
||||||
|
glibtop_client_remove_backend().
|
||||||
|
|
||||||
* include/glibtop/backend.h: Removed. Split into glibtop-backend.h
|
* include/glibtop/backend.h: Removed. Split into glibtop-backend.h
|
||||||
and glibtop-backend-info.h.
|
and glibtop-backend-info.h.
|
||||||
|
|
||||||
|
@@ -79,7 +79,7 @@ glibtop_client_propagate_error (glibtop_client *client, GError *error);
|
|||||||
void
|
void
|
||||||
glibtop_client_propagate_warning (glibtop_client *client, GError *error);
|
glibtop_client_propagate_warning (glibtop_client *client, GError *error);
|
||||||
|
|
||||||
glibtop_backend *
|
void
|
||||||
glibtop_client_open_backend (glibtop_client *client, const char *backend_name,
|
glibtop_client_open_backend (glibtop_client *client, const char *backend_name,
|
||||||
u_int64_t features, const char **backend_args);
|
u_int64_t features, const char **backend_args);
|
||||||
|
|
||||||
|
@@ -39,6 +39,7 @@ static gpointer parent_class = NULL;
|
|||||||
|
|
||||||
struct _glibtop_client_private
|
struct _glibtop_client_private
|
||||||
{
|
{
|
||||||
|
GSList *backend_list;
|
||||||
};
|
};
|
||||||
|
|
||||||
enum {
|
enum {
|
||||||
@@ -189,10 +190,15 @@ glibtop_client_finalize (GObject *object)
|
|||||||
{
|
{
|
||||||
glibtop_client *glibtop;
|
glibtop_client *glibtop;
|
||||||
glibtop_client_private *priv = NULL;
|
glibtop_client_private *priv = NULL;
|
||||||
|
GSList *c;
|
||||||
|
|
||||||
glibtop = GLIBTOP_CLIENT (object);
|
glibtop = GLIBTOP_CLIENT (object);
|
||||||
priv = glibtop->_priv;
|
priv = glibtop->_priv;
|
||||||
|
|
||||||
|
for (c = priv->backend_list; c; c = c->next)
|
||||||
|
g_object_unref (G_OBJECT (c->data));
|
||||||
|
g_slist_free (priv->backend_list);
|
||||||
|
|
||||||
g_free (priv);
|
g_free (priv);
|
||||||
|
|
||||||
if (G_OBJECT_CLASS (parent_class)->finalize)
|
if (G_OBJECT_CLASS (parent_class)->finalize)
|
||||||
@@ -253,26 +259,24 @@ glibtop_client_propagate_warning (glibtop_client *client, GError *error)
|
|||||||
g_value_unset (params + 0);
|
g_value_unset (params + 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
glibtop_backend *
|
void
|
||||||
glibtop_client_open_backend (glibtop_client *client, const char *backend_name,
|
glibtop_client_open_backend (glibtop_client *client, const char *backend_name,
|
||||||
u_int64_t features, const char **backend_args)
|
u_int64_t features, const char **backend_args)
|
||||||
{
|
{
|
||||||
glibtop_backend *backend;
|
glibtop_backend *backend;
|
||||||
GError *error = NULL;
|
GError *error = NULL;
|
||||||
|
|
||||||
g_return_val_if_fail (GLIBTOP_IS_CLIENT (client), NULL);
|
g_return_if_fail (GLIBTOP_IS_CLIENT (client));
|
||||||
|
|
||||||
backend = glibtop_backend_open (backend_name, features, backend_args,
|
backend = glibtop_backend_open (backend_name, features, backend_args,
|
||||||
&error);
|
&error);
|
||||||
if (!backend) {
|
if (!backend) {
|
||||||
glibtop_client_propagate_error (client, error);
|
glibtop_client_propagate_error (client, error);
|
||||||
g_error_free (error);
|
g_error_free (error);
|
||||||
return NULL;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
glibtop_client_add_backend (client, backend);
|
glibtop_client_add_backend (client, backend);
|
||||||
|
|
||||||
return backend;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
@@ -282,13 +286,22 @@ glibtop_client_add_backend (glibtop_client *client,
|
|||||||
g_return_if_fail (GLIBTOP_IS_CLIENT (client));
|
g_return_if_fail (GLIBTOP_IS_CLIENT (client));
|
||||||
g_return_if_fail (GLIBTOP_IS_BACKEND (backend));
|
g_return_if_fail (GLIBTOP_IS_BACKEND (backend));
|
||||||
|
|
||||||
|
client->_priv->backend_list = g_slist_append
|
||||||
|
(client->_priv->backend_list, backend);
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
glibtop_client_remove_backend (glibtop_client *client,
|
glibtop_client_remove_backend (glibtop_client *client,
|
||||||
glibtop_backend *backend)
|
glibtop_backend *backend)
|
||||||
{
|
{
|
||||||
|
GSList *c;
|
||||||
|
|
||||||
g_return_if_fail (GLIBTOP_IS_CLIENT (client));
|
g_return_if_fail (GLIBTOP_IS_CLIENT (client));
|
||||||
g_return_if_fail (GLIBTOP_IS_BACKEND (backend));
|
g_return_if_fail (GLIBTOP_IS_BACKEND (backend));
|
||||||
|
|
||||||
|
c = g_slist_find (client->_priv->backend_list, backend);
|
||||||
|
if (!c) return;
|
||||||
|
|
||||||
|
g_slist_remove_link (client->_priv->backend_list, c);
|
||||||
|
g_object_unref (G_OBJECT (backend));
|
||||||
}
|
}
|
||||||
|
@@ -24,7 +24,6 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
#include <glibtop.h>
|
#include <glibtop.h>
|
||||||
#include <glibtop/glibtop-backend.h>
|
|
||||||
|
|
||||||
#include <glibtop/cpu.h>
|
#include <glibtop/cpu.h>
|
||||||
|
|
||||||
@@ -34,23 +33,33 @@ main (int argc, char *argv [])
|
|||||||
glibtop_client *client;
|
glibtop_client *client;
|
||||||
glibtop_backend *backend_common;
|
glibtop_backend *backend_common;
|
||||||
glibtop_backend *backend_sysdeps;
|
glibtop_backend *backend_sysdeps;
|
||||||
/* glibtop_cpu cpu; */
|
GError *error = NULL;
|
||||||
|
|
||||||
g_type_init ();
|
g_type_init ();
|
||||||
|
|
||||||
client = glibtop_client_new ();
|
client = glibtop_client_new ();
|
||||||
|
|
||||||
backend_common = glibtop_client_open_backend
|
backend_common = glibtop_backend_open ("glibtop-backend-common",
|
||||||
(client, "glibtop-backend-common", 0, NULL);
|
0, NULL, &error);
|
||||||
|
|
||||||
|
if (error != NULL) {
|
||||||
|
glibtop_client_propagate_warning (client, error);
|
||||||
|
g_error_free (error);
|
||||||
|
error = NULL;
|
||||||
|
}
|
||||||
|
|
||||||
g_message (G_STRLOC ": backend = %p", backend_common);
|
g_message (G_STRLOC ": backend = %p", backend_common);
|
||||||
|
|
||||||
backend_sysdeps = glibtop_client_open_backend
|
backend_sysdeps = glibtop_backend_open ("glibtop-backend-sysdeps",
|
||||||
(client, "glibtop-backend-sysdeps", 0, NULL);
|
0, NULL, &error);
|
||||||
|
|
||||||
|
if (error != NULL) {
|
||||||
|
glibtop_client_propagate_warning (client, error);
|
||||||
|
g_error_free (error);
|
||||||
|
error = NULL;
|
||||||
|
}
|
||||||
|
|
||||||
g_message (G_STRLOC ": backend = %p", backend_sysdeps);
|
g_message (G_STRLOC ": backend = %p", backend_sysdeps);
|
||||||
|
|
||||||
/* glibtop_get_cpu_l (client, &cpu); */
|
|
||||||
|
|
||||||
exit (0);
|
exit (0);
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user