File: fo-libfo-module.c

package info (click to toggle)
xmlroff 0.6.2-1
  • links: PTS, VCS
  • area: main
  • in suites: squeeze
  • size: 36,456 kB
  • ctags: 25,964
  • sloc: ansic: 178,200; xml: 109,155; sh: 8,973; makefile: 1,331; perl: 30
file content (179 lines) | stat: -rw-r--r-- 4,438 bytes parent folder | download | duplicates (5)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
/* Fo
 * fo-libfo-module.c: Formatting object that is module of possible fo:libfo
 *
 * Copyright (C) 2003 Sun Microsystems
 * Copyright (C) 2007 Menteith Consulting Ltd
 *
 * See COPYING for the status of this software.
 */

#include "fo-libfo-module-private.h"
#include "fo-libfo.h"

enum {
  PROP_0
};

static void     fo_libfo_module_base_init (FoLibfoModuleClass *klass);

static gint                     _version_default        (void);
static const gchar *            _version_string_default (void);
static const LibfoVersionInfo * _version_info_default   (void);


GType
fo_libfo_module_get_type (void)
{
  static GType object_type = 0;

  if (!object_type)
    {
      static const GTypeInfo object_info =
      {
        sizeof (FoLibfoModuleClass),
        (GBaseInitFunc) fo_libfo_module_base_init,
        (GBaseFinalizeFunc) NULL,
        (GClassInitFunc) NULL,
        NULL,           /* class_finalize */
        NULL,           /* class_data */
        sizeof (FoLibfoModule),
        0,              /* n_preallocs */
        NULL,		/* instance_init */
	NULL		/* value_table */
      };

      object_type = g_type_register_static (FO_TYPE_OBJECT,
                                            "FoLibfoModule",
                                            &object_info,
					    G_TYPE_FLAG_ABSTRACT);
    }

  return object_type;
}

/**
 * fo_libfo_module_base_init:
 * @klass: #FoLibfoModuleClass base class object to initialise.
 * 
 * Implements #GBaseInitFunc for #FoLibfoModuleClass.
 **/
void
fo_libfo_module_base_init (FoLibfoModuleClass *klass)
{
  klass->version             = _version_default;
  klass->version_string      = _version_string_default;
  klass->version_info        = _version_info_default;
}

gint
_version_default ()
{
  return 0;
}

/**
 * fo_libfo_module_version_from_name:
 * @name: Registered #FoObject type name, e.g., "FoDocCairo"
 * 
 * Gets the runtime version of the library underlying the
 * #FoLibfoModule implementation.
 *
 * This function just returns what the underlying library provides, if
 * anything, so version numbers can only meaningfully be compared
 * against version numbers of the same library implementation.
 * 
 * Returns: Library version, or 0 if the underlying library does not
 *   make its version number available at runtime
 **/
gint
fo_libfo_module_version_from_name (const gchar *name)
{
  g_return_val_if_fail (name != NULL, 0);

  gint version = 0;
  GType type = g_type_from_name (name);

  if (g_type_is_a (type, fo_libfo_module_get_type ()))
    {
      gpointer klass = g_type_class_ref (type);
      version =
	((FoLibfoModuleClass *) klass)->version ();
      g_type_class_unref (klass);
    }

  return version;
}

const gchar *
_version_string_default ()
{
  return NULL;
}

/**
 * fo_libfo_module_version_string_from_name:
 * @name: Registered #FoObject type name, e.g., "FoDocCairo"
 * 
 * Gets the runtime version of the library underlying the
 * #FoLibfoModule implementation as a human-readable string.
 * 
 * The string is likely to be of the form "X.Y.Z", e.g., "1.0.0", but
 * this function just returns what the underlying library provides, so
 * nothing is guaranteed.
 * 
 * Returns: Library version, or %NULL if the underlying library does
 *   not make its version number available at runtime
 **/
const gchar *
fo_libfo_module_version_string_from_name (const gchar *name)
{
  g_return_val_if_fail (name != NULL, NULL);

  const gchar *version = NULL;
  GType type = g_type_from_name (name);

  if (g_type_is_a (type, fo_libfo_module_get_type ()))
    {
      gpointer klass = g_type_class_ref (type);
      version =
	((FoLibfoModuleClass *) klass)->version_string ();
      g_type_class_unref (klass);
    }

  return version;
}

const LibfoVersionInfo *
_version_info_default ()
{
  return NULL;
}


/**
 * fo_libfo_module_version_info_from_name:
 * @name: Registered #FoObject type name, e.g., "FoDocCairo"
 * 
 * Gets the #LibfoVersionInfo for
 * 
 * Returns: 
 **/
const LibfoVersionInfo *
fo_libfo_module_version_info_from_name (const gchar *name)
{
  g_return_val_if_fail (name != NULL, NULL);

  const LibfoVersionInfo *version_info = NULL;
  GType type = g_type_from_name (name);

  if (g_type_is_a (type, fo_libfo_module_get_type ()))
    {
      gpointer klass = g_type_class_ref (type);
      version_info =
	((FoLibfoModuleClass *) klass)->version_info ();
      g_type_class_unref (klass);
    }

  return version_info;
}