1
<html><head><meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1"><title>MgRefBase</title><meta name="generator" content="DocBook XSL Stylesheets V1.65.1"><link rel="home" href="index.html" title="Libmergeant Reference Manual"><link rel="up" href="ch10.html" title="Utility objects"><link rel="previous" href="ch10.html" title="Utility objects"><link rel="next" href="MgCustomLayout.html" title="MgCustomLayout"><meta name="generator" content="GTK-Doc V1.2 (XML mode)"><style type="text/css">
2
.synopsis, .classsynopsis {
4
border: solid 1px #aaaaaa;
9
border: solid 1px #aaaaff;
18
border: solid 1px #ffaaaa;
25
.navigation a:visited {
31
</style></head><body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF"><table class="navigation" width="100%" summary="Navigation header" cellpadding="2" cellspacing="2"><tr valign="middle"><td><a accesskey="p" href="ch10.html"><img src="left.png" width="24" height="24" border="0" alt="Prev"></a></td><td><a accesskey="u" href="ch10.html"><img src="up.png" width="24" height="24" border="0" alt="Up"></a></td><td><a accesskey="h" href="index.html"><img src="home.png" width="24" height="24" border="0" alt="Home"></a></td><th width="100%" align="center">Libmergeant Reference Manual</th><td><a accesskey="n" href="MgCustomLayout.html"><img src="right.png" width="24" height="24" border="0" alt="Next"></a></td></tr></table><div class="refentry" lang="en"><a name="MgRefBase"></a><div class="titlepage"><div></div><div></div></div><div class="refnamediv"><h2><span class="refentrytitle">MgRefBase</span></h2><p>MgRefBase — Used to reference other objects</p></div><div class="refsynopsisdiv"><h2>Synopsis</h2><pre class="synopsis">
35
enum <a href="MgRefBase.html#MgRefBaseType">MgRefBaseType</a>;
36
struct <a href="MgRefBase.html#MgRefBase-struct">MgRefBase</a>;
37
guint <a href="MgRefBase.html#mg-ref-base-get-type">mg_ref_base_get_type</a> (void);
38
GObject* <a href="MgRefBase.html#mg-ref-base-new">mg_ref_base_new</a> (<a href="MgConf.html" title="MgConf">MgConf</a> *conf);
39
GObject* <a href="MgRefBase.html#mg-ref-base-new-copy">mg_ref_base_new_copy</a> (<a href="MgRefBase.html" title="MgRefBase">MgRefBase</a> *orig);
40
void <a href="MgRefBase.html#mg-ref-base-set-ref-name">mg_ref_base_set_ref_name</a> (<a href="MgRefBase.html" title="MgRefBase">MgRefBase</a> *ref,
42
<a href="MgRefBase.html#MgRefBaseType">MgRefBaseType</a> type,
44
const gchar* <a href="MgRefBase.html#mg-ref-base-get-ref-name">mg_ref_base_get_ref_name</a> (<a href="MgRefBase.html" title="MgRefBase">MgRefBase</a> *ref,
46
<a href="MgRefBase.html#MgRefBaseType">MgRefBaseType</a> *type);
47
GType <a href="MgRefBase.html#mg-ref-base-get-ref-type">mg_ref_base_get_ref_type</a> (<a href="MgRefBase.html" title="MgRefBase">MgRefBase</a> *ref);
48
void <a href="MgRefBase.html#mg-ref-base-set-ref-object">mg_ref_base_set_ref_object</a> (<a href="MgRefBase.html" title="MgRefBase">MgRefBase</a> *ref,
49
<a href="MgBase.html" title="MgBase">MgBase</a> *object);
50
void <a href="MgRefBase.html#mg-ref-base-set-ref-object-type">mg_ref_base_set_ref_object_type</a> (<a href="MgRefBase.html" title="MgRefBase">MgRefBase</a> *ref,
51
<a href="MgBase.html" title="MgBase">MgBase</a> *object,
53
void <a href="MgRefBase.html#mg-ref-base-replace-ref-object">mg_ref_base_replace_ref_object</a> (<a href="MgRefBase.html" title="MgRefBase">MgRefBase</a> *ref,
54
GHashTable *replacements);
55
<a href="MgBase.html" title="MgBase">MgBase</a>* <a href="MgRefBase.html#mg-ref-base-get-ref-object">mg_ref_base_get_ref_object</a> (<a href="MgRefBase.html" title="MgRefBase">MgRefBase</a> *ref);
56
gboolean <a href="MgRefBase.html#mg-ref-base-activate">mg_ref_base_activate</a> (<a href="MgRefBase.html" title="MgRefBase">MgRefBase</a> *ref);
57
void <a href="MgRefBase.html#mg-ref-base-deactivate">mg_ref_base_deactivate</a> (<a href="MgRefBase.html" title="MgRefBase">MgRefBase</a> *ref);
58
gboolean <a href="MgRefBase.html#mg-ref-base-is-active">mg_ref_base_is_active</a> (<a href="MgRefBase.html" title="MgRefBase">MgRefBase</a> *ref);
59
</pre></div><div class="refsect1" lang="en"><a name="id3023245"></a><h2>Object Hierarchy</h2><pre class="synopsis">
62
+----<a href="MgBase.html" title="MgBase">MgBase</a>
64
</pre></div><div class="refsect1" lang="en"><a name="id3023271"></a><h2>Properties</h2><pre class="synopsis">
66
"<a href="MgRefBase.html#MgRefBase--prop">prop</a>" gpointer : Read / Write
67
</pre></div><div class="refsect1" lang="en"><a name="id3023300"></a><h2>Signal Prototypes</h2><pre class="synopsis">
69
"<a href="MgRefBase.html#MgRefBase-ref-found">ref-found</a>" void user_function (<a href="MgRefBase.html" title="MgRefBase">MgRefBase</a> *mgrefbase,
71
"<a href="MgRefBase.html#MgRefBase-ref-lost">ref-lost</a>" void user_function (<a href="MgRefBase.html" title="MgRefBase">MgRefBase</a> *mgrefbase,
73
</pre></div><div class="refsect1" lang="en"><a name="id3023375"></a><h2>Description</h2><p>
74
This object is a simple wrapper to reference other objects. It can be used in places where referenced objects
75
do not yet exist when they are needed, and their xml ID or their name is known. In this situation, create a
76
<a href="MgRefBase.html" title="MgRefBase"><span class="type">MgRefBase</span></a> object, give it the xml ID or name of the object which is to be referenced, and activate the
77
<a href="MgRefBase.html" title="MgRefBase"><span class="type">MgRefBase</span></a> object. If it is activated, then the real object can be fetched through the <a href="MgRefBase.html" title="MgRefBase"><span class="type">MgRefBase</span></a> object.
79
There are restrictions on the types of objects which can be handled:
80
</p><div class="itemizedlist"><ul type="disc"><li><p><a href="MgDbTable.html" title="MgDbTable"><span class="type">MgDbTable</span></a></p></li><li><p><a href="MgDbField.html" title="MgDbField"><span class="type">MgDbField</span></a></p></li><li><p><a href="MgQuery.html" title="MgQuery"><span class="type">MgQuery</span></a></p></li><li><p><a href="MgTarget.html" title="MgTarget"><span class="type">MgTarget</span></a></p></li><li><p><a href="MgField.html" title="MgField"><span class="type">MgField</span></a> (for any <a href="MgDbField.html" title="MgDbField"><span class="type">MgDbField</span></a> of <a href="MgQfield.html" title="MgQfield"><span class="type">MgQfield</span></a> object)</p></li></ul></div><p>
81
</p></div><div class="refsect1" lang="en"><a name="id3023500"></a><h2>Details</h2><div class="refsect2" lang="en"><a name="id3023506"></a><h3><a name="MgRefBaseType"></a>enum MgRefBaseType</h3><a class="indexterm" name="id3023517"></a><pre class="programlisting">typedef enum
88
</p></div><hr><div class="refsect2" lang="en"><a name="id3023533"></a><h3><a name="MgRefBase-struct"></a>struct MgRefBase</h3><a class="indexterm" name="id3023544"></a><pre class="programlisting">struct MgRefBase;</pre><p>
90
</p></div><hr><div class="refsect2" lang="en"><a name="id3023559"></a><h3><a name="mg-ref-base-get-type"></a>mg_ref_base_get_type ()</h3><a class="indexterm" name="id3023570"></a><pre class="programlisting">guint mg_ref_base_get_type (void);</pre><p>
92
</p><div class="variablelist"><table border="0"><col align="left" valign="top"><tbody><tr><td><span class="term"><span class="emphasis"><em>Returns</em></span> :</span></td><td>
95
</td></tr></tbody></table></div></div><hr><div class="refsect2" lang="en"><a name="id3023606"></a><h3><a name="mg-ref-base-new"></a>mg_ref_base_new ()</h3><a class="indexterm" name="id3023617"></a><pre class="programlisting">GObject* mg_ref_base_new (<a href="MgConf.html" title="MgConf">MgConf</a> *conf);</pre><p>
96
Creates a new MgRefBase object</p><p>
98
</p><div class="variablelist"><table border="0"><col align="left" valign="top"><tbody><tr><td><span class="term"><i class="parameter"><tt>conf</tt></i>�:</span></td><td> a <a href="MgConf.html" title="MgConf"><span class="type">MgConf</span></a> object
99
</td></tr><tr><td><span class="term"><span class="emphasis"><em>Returns</em></span> :</span></td><td> the new object
100
</td></tr></tbody></table></div></div><hr><div class="refsect2" lang="en"><a name="id3023685"></a><h3><a name="mg-ref-base-new-copy"></a>mg_ref_base_new_copy ()</h3><a class="indexterm" name="id3023697"></a><pre class="programlisting">GObject* mg_ref_base_new_copy (<a href="MgRefBase.html" title="MgRefBase">MgRefBase</a> *orig);</pre><p>
101
Creates a new MgRefBase object which is a copy of <i class="parameter"><tt>orig</tt></i>. This is a copy constructor.</p><p>
103
</p><div class="variablelist"><table border="0"><col align="left" valign="top"><tbody><tr><td><span class="term"><i class="parameter"><tt>orig</tt></i>�:</span></td><td> a <a href="MgRefBase.html" title="MgRefBase"><span class="type">MgRefBase</span></a> object
104
</td></tr><tr><td><span class="term"><span class="emphasis"><em>Returns</em></span> :</span></td><td> the new object
105
</td></tr></tbody></table></div></div><hr><div class="refsect2" lang="en"><a name="id3023771"></a><h3><a name="mg-ref-base-set-ref-name"></a>mg_ref_base_set_ref_name ()</h3><a class="indexterm" name="id3023783"></a><pre class="programlisting">void mg_ref_base_set_ref_name (<a href="MgRefBase.html" title="MgRefBase">MgRefBase</a> *ref,
107
<a href="MgRefBase.html#MgRefBaseType">MgRefBaseType</a> type,
108
const gchar *name);</pre><p>
109
Sets the type and XML Id of the object we want to reference. If any other object was already
110
referenced <i class="parameter"><tt>ref</tt></i> is first reinitialized
112
Rem: the name format is dependant on the type of object which is requested</p><p>
114
</p><div class="variablelist"><table border="0"><col align="left" valign="top"><tbody><tr><td><span class="term"><i class="parameter"><tt>ref</tt></i>�:</span></td><td> a <a href="MgRefBase.html" title="MgRefBase"><span class="type">MgRefBase</span></a> object
115
</td></tr><tr><td><span class="term"><i class="parameter"><tt>ref_type</tt></i>�:</span></td><td> the requested referenced object's data type, or 0 if not specified and <i class="parameter"><tt>type</tt></i> = REFERENCE_BY_XML_ID
116
</td></tr><tr><td><span class="term"><i class="parameter"><tt>type</tt></i>�:</span></td><td> how to interpret the <i class="parameter"><tt>name</tt></i> argument
117
</td></tr><tr><td><span class="term"><i class="parameter"><tt>name</tt></i>�:</span></td><td> the name of the requested object
118
</td></tr></tbody></table></div></div><hr><div class="refsect2" lang="en"><a name="id3023931"></a><h3><a name="mg-ref-base-get-ref-name"></a>mg_ref_base_get_ref_name ()</h3><a class="indexterm" name="id3023943"></a><pre class="programlisting">const gchar* mg_ref_base_get_ref_name (<a href="MgRefBase.html" title="MgRefBase">MgRefBase</a> *ref,
120
<a href="MgRefBase.html#MgRefBaseType">MgRefBaseType</a> *type);</pre><p>
121
Get the caracteristics of the requested object</p><p>
123
</p><div class="variablelist"><table border="0"><col align="left" valign="top"><tbody><tr><td><span class="term"><i class="parameter"><tt>ref</tt></i>�:</span></td><td> a <a href="MgRefBase.html" title="MgRefBase"><span class="type">MgRefBase</span></a> object
124
</td></tr><tr><td><span class="term"><i class="parameter"><tt>ref_type</tt></i>�:</span></td><td> where to store the requested referenced object's data type, or NULL
125
</td></tr><tr><td><span class="term"><i class="parameter"><tt>type</tt></i>�:</span></td><td> where to store how to interpret the returned name, or NULL
126
</td></tr><tr><td><span class="term"><span class="emphasis"><em>Returns</em></span> :</span></td><td> the name of the object (to be interpreted with <i class="parameter"><tt>type</tt></i>)
127
</td></tr></tbody></table></div></div><hr><div class="refsect2" lang="en"><a name="id3024064"></a><h3><a name="mg-ref-base-get-ref-type"></a>mg_ref_base_get_ref_type ()</h3><a class="indexterm" name="id3024075"></a><pre class="programlisting">GType mg_ref_base_get_ref_type (<a href="MgRefBase.html" title="MgRefBase">MgRefBase</a> *ref);</pre><p>
128
Get the type of the referenced object by <i class="parameter"><tt>ref</tt></i> (or the requested type if <i class="parameter"><tt>ref</tt></i> is not active)</p><p>
130
</p><div class="variablelist"><table border="0"><col align="left" valign="top"><tbody><tr><td><span class="term"><i class="parameter"><tt>ref</tt></i>�:</span></td><td> a <a href="MgRefBase.html" title="MgRefBase"><span class="type">MgRefBase</span></a> object
131
</td></tr><tr><td><span class="term"><span class="emphasis"><em>Returns</em></span> :</span></td><td> the type
132
</td></tr></tbody></table></div></div><hr><div class="refsect2" lang="en"><a name="id3024154"></a><h3><a name="mg-ref-base-set-ref-object"></a>mg_ref_base_set_ref_object ()</h3><a class="indexterm" name="id3024167"></a><pre class="programlisting">void mg_ref_base_set_ref_object (<a href="MgRefBase.html" title="MgRefBase">MgRefBase</a> *ref,
133
<a href="MgBase.html" title="MgBase">MgBase</a> *object);</pre><p>
134
Rather than to set the XML Id of the object <i class="parameter"><tt>ref</tt></i> has to reference, this function allows
135
to directly give the object, in case the object is known.</p><p>
137
</p><div class="variablelist"><table border="0"><col align="left" valign="top"><tbody><tr><td><span class="term"><i class="parameter"><tt>ref</tt></i>�:</span></td><td> a <a href="MgRefBase.html" title="MgRefBase"><span class="type">MgRefBase</span></a> object
138
</td></tr><tr><td><span class="term"><i class="parameter"><tt>object</tt></i>�:</span></td><td> the object to keep a reference to
139
</td></tr></tbody></table></div></div><hr><div class="refsect2" lang="en"><a name="id3024253"></a><h3><a name="mg-ref-base-set-ref-object-type"></a>mg_ref_base_set_ref_object_type ()</h3><a class="indexterm" name="id3024265"></a><pre class="programlisting">void mg_ref_base_set_ref_object_type (<a href="MgRefBase.html" title="MgRefBase">MgRefBase</a> *ref,
140
<a href="MgBase.html" title="MgBase">MgBase</a> *object,
141
GType type);</pre><p>
142
Rather than to set the XML Id of the object <i class="parameter"><tt>ref</tt></i> has to reference, this function allows
143
to directly give the object, and specify the requested type, in case the object is known.</p><p>
145
</p><div class="variablelist"><table border="0"><col align="left" valign="top"><tbody><tr><td><span class="term"><i class="parameter"><tt>ref</tt></i>�:</span></td><td> a <a href="MgRefBase.html" title="MgRefBase"><span class="type">MgRefBase</span></a> object
146
</td></tr><tr><td><span class="term"><i class="parameter"><tt>object</tt></i>�:</span></td><td> the object to keep a reference to
147
</td></tr><tr><td><span class="term"><i class="parameter"><tt>type</tt></i>�:</span></td><td> the type of object requested: it must be a type in the class hierarchy of <i class="parameter"><tt>object</tt></i>
148
</td></tr></tbody></table></div></div><hr><div class="refsect2" lang="en"><a name="id3024381"></a><h3><a name="mg-ref-base-replace-ref-object"></a>mg_ref_base_replace_ref_object ()</h3><a class="indexterm" name="id3024393"></a><pre class="programlisting">void mg_ref_base_replace_ref_object (<a href="MgRefBase.html" title="MgRefBase">MgRefBase</a> *ref,
149
GHashTable *replacements);</pre><p>
150
Changes the referenced object with a new one: it looks into <i class="parameter"><tt>replacements</tt></i> and if the
151
currently referenced object appears there as a key, then the reference is replaced with
152
the corresponding value.
154
Nothing happens if <i class="parameter"><tt>ref</tt></i> is not active, or if the referenced object is not found in <i class="parameter"><tt>replacaments</tt></i>.</p><p>
156
</p><div class="variablelist"><table border="0"><col align="left" valign="top"><tbody><tr><td><span class="term"><i class="parameter"><tt>ref</tt></i>�:</span></td><td> a <a href="MgRefBase.html" title="MgRefBase"><span class="type">MgRefBase</span></a> object
157
</td></tr><tr><td><span class="term"><i class="parameter"><tt>replacements</tt></i>�:</span></td><td> a <span class="type">GHashTable</span>
158
</td></tr></tbody></table></div></div><hr><div class="refsect2" lang="en"><a name="id3024505"></a><h3><a name="mg-ref-base-get-ref-object"></a>mg_ref_base_get_ref_object ()</h3><a class="indexterm" name="id3024517"></a><pre class="programlisting"><a href="MgBase.html" title="MgBase">MgBase</a>* mg_ref_base_get_ref_object (<a href="MgRefBase.html" title="MgRefBase">MgRefBase</a> *ref);</pre><p>
159
Get the referenced object by <i class="parameter"><tt>ref</tt></i></p><p>
161
</p><div class="variablelist"><table border="0"><col align="left" valign="top"><tbody><tr><td><span class="term"><i class="parameter"><tt>ref</tt></i>�:</span></td><td> a <a href="MgRefBase.html" title="MgRefBase"><span class="type">MgRefBase</span></a> object
162
</td></tr><tr><td><span class="term"><span class="emphasis"><em>Returns</em></span> :</span></td><td> a pointer to the object, or NULL if the reference is not active
163
</td></tr></tbody></table></div></div><hr><div class="refsect2" lang="en"><a name="id3024590"></a><h3><a name="mg-ref-base-activate"></a>mg_ref_base_activate ()</h3><a class="indexterm" name="id3024602"></a><pre class="programlisting">gboolean mg_ref_base_activate (<a href="MgRefBase.html" title="MgRefBase">MgRefBase</a> *ref);</pre><p>
164
Tries to "activate" a reference (to find the referenced object). Nothing happens if
165
the object is already activated</p><p>
167
</p><div class="variablelist"><table border="0"><col align="left" valign="top"><tbody><tr><td><span class="term"><i class="parameter"><tt>ref</tt></i>�:</span></td><td> a <a href="MgRefBase.html" title="MgRefBase"><span class="type">MgRefBase</span></a> object
168
</td></tr><tr><td><span class="term"><span class="emphasis"><em>Returns</em></span> :</span></td><td> TRUE on success
169
</td></tr></tbody></table></div></div><hr><div class="refsect2" lang="en"><a name="id3024671"></a><h3><a name="mg-ref-base-deactivate"></a>mg_ref_base_deactivate ()</h3><a class="indexterm" name="id3024682"></a><pre class="programlisting">void mg_ref_base_deactivate (<a href="MgRefBase.html" title="MgRefBase">MgRefBase</a> *ref);</pre><p>
170
Desctivates the object (loses the reference to the object)</p><p>
172
</p><div class="variablelist"><table border="0"><col align="left" valign="top"><tbody><tr><td><span class="term"><i class="parameter"><tt>ref</tt></i>�:</span></td><td> a <a href="MgRefBase.html" title="MgRefBase"><span class="type">MgRefBase</span></a> object
173
</td></tr></tbody></table></div></div><hr><div class="refsect2" lang="en"><a name="id3024740"></a><h3><a name="mg-ref-base-is-active"></a>mg_ref_base_is_active ()</h3><a class="indexterm" name="id3024752"></a><pre class="programlisting">gboolean mg_ref_base_is_active (<a href="MgRefBase.html" title="MgRefBase">MgRefBase</a> *ref);</pre><p>
174
Find wether <i class="parameter"><tt>ref</tt></i> is active</p><p>
176
</p><div class="variablelist"><table border="0"><col align="left" valign="top"><tbody><tr><td><span class="term"><i class="parameter"><tt>ref</tt></i>�:</span></td><td> a <a href="MgRefBase.html" title="MgRefBase"><span class="type">MgRefBase</span></a> object
177
</td></tr><tr><td><span class="term"><span class="emphasis"><em>Returns</em></span> :</span></td><td> TRUE if <i class="parameter"><tt>ref</tt></i> is active
178
</td></tr></tbody></table></div></div></div><div class="refsect1" lang="en"><a name="id3024832"></a><h2>Properties</h2><div class="variablelist"><table border="0"><col align="left" valign="top"><tbody><tr><td><span class="term"><a name="MgRefBase--prop"></a>"<tt class="literal">prop</tt>" (gpointer : Read / Write)</span></td><td><p></p></td></tr></tbody></table></div></div><div class="refsect1" lang="en"><a name="id3024870"></a><h2>Signals</h2><div class="refsect2" lang="en"><a name="id3024876"></a><h3><a name="MgRefBase-ref-found"></a>The "ref-found" signal</h3><pre class="programlisting">void user_function (<a href="MgRefBase.html" title="MgRefBase">MgRefBase</a> *mgrefbase,
179
gpointer user_data);</pre><p>
181
</p><div class="variablelist"><table border="0"><col align="left" valign="top"><tbody><tr><td><span class="term"><i class="parameter"><tt>mgrefbase</tt></i>�:</span></td><td>the object which received the signal.
183
</td></tr><tr><td><span class="term"><i class="parameter"><tt>user_data</tt></i>�:</span></td><td>user data set when the signal handler was connected.</td></tr></tbody></table></div></div><hr><div class="refsect2" lang="en"><a name="id3024948"></a><h3><a name="MgRefBase-ref-lost"></a>The "ref-lost" signal</h3><pre class="programlisting">void user_function (<a href="MgRefBase.html" title="MgRefBase">MgRefBase</a> *mgrefbase,
184
gpointer user_data);</pre><p>
186
</p><div class="variablelist"><table border="0"><col align="left" valign="top"><tbody><tr><td><span class="term"><i class="parameter"><tt>mgrefbase</tt></i>�:</span></td><td>the object which received the signal.
188
</td></tr><tr><td><span class="term"><i class="parameter"><tt>user_data</tt></i>�:</span></td><td>user data set when the signal handler was connected.</td></tr></tbody></table></div></div></div></div><table class="navigation" width="100%" summary="Navigation footer" cellpadding="2" cellspacing="0"><tr valign="middle"><td align="left"><a accesskey="p" href="ch10.html"><b><<�Utility objects</b></a></td><td align="right"><a accesskey="n" href="MgCustomLayout.html"><b>MgCustomLayout�>></b></a></td></tr></table></body></html>