<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"> <html><head><meta http-equiv="Content-Type" content="text/html;charset=iso-8859-1"> <title>Crystal Space 1.2.1: iutil/objreg.h Source File (Crystal Space 1.2.1 Public API Reference)</title> <link href="tabs.css" rel="stylesheet" type="text/css"> <link href="doxygen.css" rel="stylesheet" type="text/css"> </head><body> <table border="0" cellpadding="0" cellspacing="0" width="100%" class="head"> <tr height="59"> <td class="head" width="202" valign="bottom" style="padding-left:0;"><a href="http://www.crystalspace3d.org/"><img src="csblur.png" width="236" height="59" alt="CrystalSpace" border="0"></a></td> <td class="head"><h2>Public API Reference</h2></td> </tr> <tr height="11"> <td colspan="2" class="headshadow" valign="top" style="padding-left:0;"><img src="csblurb.png" width="236" height="11" alt="" border="0"></td> </tr> </table> <div class="content"> <!-- Generated by Doxygen 1.5.3 --> <div class="tabs"> <ul> <li><a href="index.html"><span>Main Page</span></a></li> <li><a href="modules.html"><span>Modules</span></a></li> <li><a href="namespaces.html"><span>Namespaces</span></a></li> <li><a href="classes.html"><span>Classes</span></a></li> <li class="current"><a href="files.html"><span>Files</span></a></li> <li><a href="pages.html"><span>Related Pages</span></a></li> </ul> </div> <h1>iutil/objreg.h</h1><a href="iutil_2objreg_8h.html">Go to the documentation of this file.</a><div class="fragment"><pre class="fragment"><a name="l00001"></a>00001 <span class="comment">/*</span> <a name="l00002"></a>00002 <span class="comment"> Copyright (C) 2001 by Jorrit Tyberghein</span> <a name="l00003"></a>00003 <span class="comment"></span> <a name="l00004"></a>00004 <span class="comment"> This library is free software; you can redistribute it and/or</span> <a name="l00005"></a>00005 <span class="comment"> modify it under the terms of the GNU Library General Public</span> <a name="l00006"></a>00006 <span class="comment"> License as published by the Free Software Foundation; either</span> <a name="l00007"></a>00007 <span class="comment"> version 2 of the License, or (at your option) any later version.</span> <a name="l00008"></a>00008 <span class="comment"></span> <a name="l00009"></a>00009 <span class="comment"> This library is distributed in the hope that it will be useful,</span> <a name="l00010"></a>00010 <span class="comment"> but WITHOUT ANY WARRANTY; without even the implied warranty of</span> <a name="l00011"></a>00011 <span class="comment"> MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU</span> <a name="l00012"></a>00012 <span class="comment"> Library General Public License for more details.</span> <a name="l00013"></a>00013 <span class="comment"></span> <a name="l00014"></a>00014 <span class="comment"> You should have received a copy of the GNU Library General Public</span> <a name="l00015"></a>00015 <span class="comment"> License along with this library; if not, write to the Free</span> <a name="l00016"></a>00016 <span class="comment"> Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.</span> <a name="l00017"></a>00017 <span class="comment">*/</span> <a name="l00018"></a>00018 <a name="l00019"></a>00019 <span class="preprocessor">#ifndef __CS_IUTIL_OBJREG_H__</span> <a name="l00020"></a>00020 <span class="preprocessor"></span><span class="preprocessor">#define __CS_IUTIL_OBJREG_H__</span> <a name="l00021"></a>00021 <span class="preprocessor"></span> <a name="l00030"></a>00030 <span class="preprocessor">#include "<a class="code" href="ref_8h.html" title="Smart Pointers.">csutil/ref.h</a>"</span> <a name="l00031"></a>00031 <span class="preprocessor">#include "<a class="code" href="scf__interface_8h.html" title="Crystal Space Shared Class Facility (SCF) - interface creation support.">csutil/scf_interface.h</a>"</span> <a name="l00032"></a>00032 <a name="l00033"></a>00033 <span class="keyword">struct </span><a class="code" href="structiObjectRegistryIterator.html" title="Use an instance of this class to iterate over objects in the object registry.">iObjectRegistryIterator</a>; <a name="l00034"></a>00034 <a name="l00048"></a><a class="code" href="structiObjectRegistry.html">00048</a> <span class="keyword">struct </span><a class="code" href="structiObjectRegistry.html" title="This interface serves as a registry of other objects.">iObjectRegistry</a> : <span class="keyword">public</span> <span class="keyword">virtual</span> <a class="code" href="structiBase.html" title="This is the basic interface: all other interfaces should be derived from this one...">iBase</a> <a name="l00049"></a>00049 { <a name="l00050"></a>00050 SCF_INTERFACE(<a class="code" href="structiObjectRegistry.html" title="This interface serves as a registry of other objects.">iObjectRegistry</a>, 2,0,0); <a name="l00051"></a>00051 <span class="comment">// Allow implicit casts through static function.</span> <a name="l00052"></a>00052 CS_IMPLEMENT_IMPLICIT_PTR_CAST (<a class="code" href="structiObjectRegistry.html" title="This interface serves as a registry of other objects.">iObjectRegistry</a>); <a name="l00053"></a>00053 <a name="l00057"></a>00057 <span class="keyword">virtual</span> <span class="keywordtype">void</span> <a class="code" href="structiObjectRegistry.html#41cbf0c1bba0b09fe138558796fd07d1" title="Clear the object registry and release all references.">Clear</a> () = 0; <a name="l00058"></a>00058 <a name="l00075"></a>00075 <span class="keyword">virtual</span> <span class="keywordtype">bool</span> <a class="code" href="structiObjectRegistry.html#95698fc00d47a53d011c10c75fefce2e" title="Register an object with this registry.">Register</a> (<a class="code" href="structiBase.html" title="This is the basic interface: all other interfaces should be derived from this one...">iBase</a>* obj, <span class="keywordtype">char</span> <span class="keyword">const</span>* tag = 0) = 0; <a name="l00076"></a>00076 <a name="l00088"></a>00088 <span class="keyword">virtual</span> <span class="keywordtype">void</span> <a class="code" href="structiObjectRegistry.html#071a311e10733e187f4e77b1042a0fde" title="Unregister an object with this registry.">Unregister</a> (<a class="code" href="structiBase.html" title="This is the basic interface: all other interfaces should be derived from this one...">iBase</a>* obj, <span class="keywordtype">char</span> <span class="keyword">const</span>* tag = 0) = 0; <a name="l00089"></a>00089 <a name="l00096"></a>00096 <span class="keyword">virtual</span> <a class="code" href="structiBase.html" title="This is the basic interface: all other interfaces should be derived from this one...">iBase</a>* <a class="code" href="structiObjectRegistry.html#159572bd26f6107918820b7eec8090e6" title="Get an iterator with all objects in this object registry.">Get</a> (<span class="keywordtype">char</span> <span class="keyword">const</span>* tag) = 0; <a name="l00097"></a>00097 <a name="l00105"></a>00105 <span class="keyword">virtual</span> <a class="code" href="structiBase.html" title="This is the basic interface: all other interfaces should be derived from this one...">iBase</a>* <a class="code" href="structiObjectRegistry.html#159572bd26f6107918820b7eec8090e6" title="Get an iterator with all objects in this object registry.">Get</a> (<span class="keywordtype">char</span> <span class="keyword">const</span>* tag, <a class="code" href="group__scf.html#ge3095ac94f71a5ff42374271c90222cd" title="Type of registered interface handle used by iBase::QueryInterface().">scfInterfaceID</a> <span class="keywordtype">id</span>, <span class="keywordtype">int</span> version) = 0; <a name="l00106"></a>00106 <a name="l00113"></a>00113 <span class="keyword">virtual</span> <a class="code" href="classcsPtr.html" title="A pointer encapsulator.">csPtr<iObjectRegistryIterator></a> <a class="code" href="structiObjectRegistry.html#159572bd26f6107918820b7eec8090e6" title="Get an iterator with all objects in this object registry.">Get</a> ( <a name="l00114"></a>00114 <a class="code" href="group__scf.html#ge3095ac94f71a5ff42374271c90222cd" title="Type of registered interface handle used by iBase::QueryInterface().">scfInterfaceID</a> <span class="keywordtype">id</span>, <span class="keywordtype">int</span> version) = 0; <a name="l00115"></a>00115 <a name="l00122"></a>00122 <span class="keyword">virtual</span> <a class="code" href="classcsPtr.html" title="A pointer encapsulator.">csPtr<iObjectRegistryIterator></a> <a class="code" href="structiObjectRegistry.html#159572bd26f6107918820b7eec8090e6" title="Get an iterator with all objects in this object registry.">Get</a> () = 0; <a name="l00123"></a>00123 }; <a name="l00124"></a>00124 <a name="l00125"></a>00125 <a name="l00130"></a><a class="code" href="structiObjectRegistryIterator.html">00130</a> <span class="keyword">struct </span><a class="code" href="structiObjectRegistryIterator.html" title="Use an instance of this class to iterate over objects in the object registry.">iObjectRegistryIterator</a> : <span class="keyword">public</span> <span class="keyword">virtual</span> <a class="code" href="structiBase.html" title="This is the basic interface: all other interfaces should be derived from this one...">iBase</a> <a name="l00131"></a>00131 { <a name="l00132"></a>00132 SCF_INTERFACE(<a class="code" href="structiObjectRegistryIterator.html" title="Use an instance of this class to iterate over objects in the object registry.">iObjectRegistryIterator</a>, 2,0,0); <a name="l00137"></a>00137 <span class="keyword">virtual</span> <span class="keywordtype">bool</span> <a class="code" href="structiObjectRegistryIterator.html#57127ff37041d759b2b49db7ce13885c" title="Restart the iterator.">Reset</a> () = 0; <a name="l00138"></a>00138 <a name="l00142"></a>00142 <span class="keyword">virtual</span> <span class="keyword">const</span> <span class="keywordtype">char</span>* <a class="code" href="structiObjectRegistryIterator.html#ca4ade9ad4e0ec2709a24d19403edfb4" title="Return the current tag.">GetCurrentTag</a> () = 0; <a name="l00143"></a>00143 <a name="l00147"></a>00147 <span class="keyword">virtual</span> <span class="keywordtype">bool</span> <a class="code" href="structiObjectRegistryIterator.html#35b92e3e8615bb700e334940eb36ec01" title="Return true if there are more elements.">HasNext</a> () = 0; <a name="l00148"></a>00148 <a name="l00152"></a>00152 <span class="keyword">virtual</span> <a class="code" href="structiBase.html" title="This is the basic interface: all other interfaces should be derived from this one...">iBase</a>* <a class="code" href="structiObjectRegistryIterator.html#be23185d36ea130312f095e86fe7ab00" title="Proceed with next element.">Next</a> () = 0; <a name="l00153"></a>00153 }; <a name="l00154"></a>00154 <a name="l00160"></a>00160 <span class="keyword">template</span><<span class="keyword">class</span> Interface> <a name="l00161"></a><a class="code" href="iutil_2objreg_8h.html#ee5a756951eeb09857882b549a563261">00161</a> <span class="keyword">inline</span> <a class="code" href="classcsPtr.html" title="A pointer encapsulator.">csPtr<Interface></a> <a class="code" href="iutil_2objreg_8h.html#ee5a756951eeb09857882b549a563261" title="Query an interface from the registry.">csQueryRegistry</a> (<a class="code" href="structiObjectRegistry.html" title="This interface serves as a registry of other objects.">iObjectRegistry</a> *Reg) <a name="l00162"></a>00162 { <a name="l00163"></a>00163 <a class="code" href="structiBase.html" title="This is the basic interface: all other interfaces should be derived from this one...">iBase</a> *base = Reg-><a class="code" href="structiObjectRegistry.html#ba569f17b4f8b4a5201fa36e0793e77e" title="Get the registered object corresponding with the given tag.">Get</a> (<a class="code" href="classscfInterfaceTraits.html" title="Interface information query class.">scfInterfaceTraits<Interface>::GetName</a> (), <a name="l00164"></a>00164 <a class="code" href="classscfInterfaceTraits.html" title="Interface information query class.">scfInterfaceTraits<Interface>::GetID</a> (), <a name="l00165"></a>00165 <a class="code" href="classscfInterfaceTraits.html" title="Interface information query class.">scfInterfaceTraits<Interface>::GetVersion</a> ()); <a name="l00166"></a>00166 <a name="l00167"></a>00167 <span class="keywordflow">if</span> (base == 0) <span class="keywordflow">return</span> <a class="code" href="classcsPtr.html" title="A pointer encapsulator.">csPtr<Interface></a> (0); <a name="l00168"></a>00168 <a name="l00169"></a>00169 Interface *x = (Interface*)base-><a class="code" href="structiBase.html#2adc74eb0286a65f2310f221be4ddded" title="Query a particular interface implemented by this object.">QueryInterface</a> ( <a name="l00170"></a>00170 <a class="code" href="classscfInterfaceTraits.html" title="Interface information query class.">scfInterfaceTraits<Interface>::GetID</a> (), <a name="l00171"></a>00171 <a class="code" href="classscfInterfaceTraits.html" title="Interface information query class.">scfInterfaceTraits<Interface>::GetVersion</a> ()); <a name="l00172"></a>00172 <a name="l00173"></a>00173 <span class="keywordflow">if</span> (x) base-><a class="code" href="structiBase.html#3a44d46ca155e6ab0c0179db01011bb0" title="Decrement the reference count.">DecRef</a> (); <span class="comment">//release our base interface</span> <a name="l00174"></a>00174 <span class="keywordflow">return</span> <a class="code" href="classcsPtr.html" title="A pointer encapsulator.">csPtr<Interface></a> (x); <a name="l00175"></a>00175 } <a name="l00176"></a>00176 <a name="l00180"></a><a class="code" href="iutil_2objreg_8h.html#3c9f411e74add910423f848756ad9daf">00180</a> <span class="keyword">inline</span> <a class="code" href="classcsPtr.html" title="A pointer encapsulator.">csPtr<iBase></a> <a class="code" href="iutil_2objreg_8h.html#3c9f411e74add910423f848756ad9daf" title="Query an object from the registry, with a tag specified by the user.">csQueryRegistryTag</a> (<a class="code" href="structiObjectRegistry.html" title="This interface serves as a registry of other objects.">iObjectRegistry</a> *Reg, <span class="keyword">const</span> <span class="keywordtype">char</span>* Tag) <a name="l00181"></a>00181 { <a name="l00182"></a>00182 <span class="keywordflow">return</span> <a class="code" href="classcsPtr.html" title="A pointer encapsulator.">csPtr<iBase></a> (Reg-><a class="code" href="structiObjectRegistry.html#ba569f17b4f8b4a5201fa36e0793e77e" title="Get the registered object corresponding with the given tag.">Get</a> (Tag)); <a name="l00183"></a>00183 } <a name="l00184"></a>00184 <a name="l00188"></a>00188 <span class="keyword">template</span><<span class="keyword">class</span> Interface> <a name="l00189"></a><a class="code" href="iutil_2objreg_8h.html#67a78cae0a3099ef84dd96f6f5cd5d45">00189</a> <span class="keyword">inline</span> <a class="code" href="classcsPtr.html" title="A pointer encapsulator.">csPtr<Interface></a> <a class="code" href="iutil_2objreg_8h.html#67a78cae0a3099ef84dd96f6f5cd5d45" title="Query an interface from the registry, with a tag specified by the user.">csQueryRegistryTagInterface</a> ( <a name="l00190"></a>00190 <a class="code" href="structiObjectRegistry.html" title="This interface serves as a registry of other objects.">iObjectRegistry</a> *Reg, <span class="keyword">const</span> <span class="keywordtype">char</span>* Tag) <a name="l00191"></a>00191 { <a name="l00192"></a>00192 <a class="code" href="structiBase.html" title="This is the basic interface: all other interfaces should be derived from this one...">iBase</a> *base = Reg-><a class="code" href="structiObjectRegistry.html#ba569f17b4f8b4a5201fa36e0793e77e" title="Get the registered object corresponding with the given tag.">Get</a> (Tag, <a name="l00193"></a>00193 <a class="code" href="classscfInterfaceTraits.html" title="Interface information query class.">scfInterfaceTraits<Interface>::GetID</a> (), <a name="l00194"></a>00194 <a class="code" href="classscfInterfaceTraits.html" title="Interface information query class.">scfInterfaceTraits<Interface>::GetVersion</a> ()); <a name="l00195"></a>00195 <a name="l00196"></a>00196 <span class="keywordflow">if</span> (base == 0) <span class="keywordflow">return</span> <a class="code" href="classcsPtr.html" title="A pointer encapsulator.">csPtr<Interface></a> (0); <a name="l00197"></a>00197 <a name="l00198"></a>00198 Interface *x = (Interface*)base-><a class="code" href="structiBase.html#2adc74eb0286a65f2310f221be4ddded" title="Query a particular interface implemented by this object.">QueryInterface</a> ( <a name="l00199"></a>00199 <a class="code" href="classscfInterfaceTraits.html" title="Interface information query class.">scfInterfaceTraits<Interface>::GetID</a> (), <a name="l00200"></a>00200 <a class="code" href="classscfInterfaceTraits.html" title="Interface information query class.">scfInterfaceTraits<Interface>::GetVersion</a> ()); <a name="l00201"></a>00201 <a name="l00202"></a>00202 <span class="keywordflow">if</span> (x) base-><a class="code" href="structiBase.html#3a44d46ca155e6ab0c0179db01011bb0" title="Decrement the reference count.">DecRef</a> (); <span class="comment">//release our base interface</span> <a name="l00203"></a>00203 <span class="keywordflow">return</span> <a class="code" href="classcsPtr.html" title="A pointer encapsulator.">csPtr<Interface></a> (x); <a name="l00204"></a>00204 } <a name="l00205"></a>00205 <a name="l00206"></a>00206 <span class="keyword">inline</span> <a class="code" href="cssysdef_8h.html#69b27a22db26f4a2bb7a26a85d2ab06b" title="A variant of CS_DEPRECATED_METHOD that also emits the message msg on compilers that...">CS_DEPRECATED_METHOD_MSG</a> (<span class="stringliteral">"CS_QUERY_REGISTRY_TAG macro is deprecated"</span>) <a name="l00207"></a><a class="code" href="iutil_2objreg_8h.html#ce0ad9c893013bdd8de242426126a55f">00207</a> <a class="code" href="classcsPtr.html" title="A pointer encapsulator.">csPtr</a><<a class="code" href="structiBase.html" title="This is the basic interface: all other interfaces should be derived from this one...">iBase</a>> <a class="code" href="iutil_2objreg_8h.html#ce0ad9c893013bdd8de242426126a55f">CS_QUERY_REGISTRY_TAG_is_deprecated</a> (<a class="code" href="structiObjectRegistry.html" title="This interface serves as a registry of other objects.">iObjectRegistry</a> *Reg, <a name="l00208"></a>00208 const <span class="keywordtype">char</span>* Tag) <a name="l00209"></a>00209 { <a name="l00210"></a>00210 <span class="keywordflow">return</span> <a class="code" href="iutil_2objreg_8h.html#3c9f411e74add910423f848756ad9daf" title="Query an object from the registry, with a tag specified by the user.">csQueryRegistryTag</a>(Reg, Tag); <a name="l00211"></a>00211 } <a name="l00216"></a><a class="code" href="iutil_2objreg_8h.html#5ddc56f0b566d5bb87785a16c20e8e8c">00216</a> <span class="preprocessor">#define CS_QUERY_REGISTRY_TAG(Reg, Tag) \</span> <a name="l00217"></a>00217 <span class="preprocessor"> (CS_QUERY_REGISTRY_TAG_is_deprecated (Reg, Tag))</span> <a name="l00218"></a>00218 <span class="preprocessor"></span> <a name="l00219"></a>00219 <span class="keyword">template</span><<span class="keyword">class</span> Interface> <a name="l00220"></a>00220 <span class="keyword">inline</span> <a class="code" href="cssysdef_8h.html#69b27a22db26f4a2bb7a26a85d2ab06b" title="A variant of CS_DEPRECATED_METHOD that also emits the message msg on compilers that...">CS_DEPRECATED_METHOD_MSG</a> (<span class="stringliteral">"CS_QUERY_REGISTRY macro is deprecated"</span>) <a name="l00221"></a><a class="code" href="iutil_2objreg_8h.html#2ba6c9135bde1b2d7c23ba3526f122ee">00221</a> <a class="code" href="classcsPtr.html" title="A pointer encapsulator.">csPtr</a><Interface> <a class="code" href="iutil_2objreg_8h.html#2ba6c9135bde1b2d7c23ba3526f122ee">CS_QUERY_REGISTRY_is_deprecated</a> (<a class="code" href="structiObjectRegistry.html" title="This interface serves as a registry of other objects.">iObjectRegistry</a> *Reg) <a name="l00222"></a>00222 { <a name="l00223"></a>00223 <span class="keywordflow">return</span> csQueryRegistry<Interface> (Reg); <a name="l00224"></a>00224 } <a name="l00229"></a><a class="code" href="iutil_2objreg_8h.html#2a09063f1dabdde133a6269016f6a3da">00229</a> <span class="preprocessor">#define CS_QUERY_REGISTRY(Reg,Interface) \</span> <a name="l00230"></a>00230 <span class="preprocessor"> (CS_QUERY_REGISTRY_is_deprecated<Interface> (Reg))</span> <a name="l00231"></a>00231 <span class="preprocessor"></span> <a name="l00232"></a>00232 <span class="keyword">template</span><<span class="keyword">class</span> Interface> <a name="l00233"></a>00233 <span class="keyword">inline</span> <a class="code" href="cssysdef_8h.html#69b27a22db26f4a2bb7a26a85d2ab06b" title="A variant of CS_DEPRECATED_METHOD that also emits the message msg on compilers that...">CS_DEPRECATED_METHOD_MSG</a> ( <a name="l00234"></a>00234 <span class="stringliteral">"CS_QUERY_REGISTRY_TAG_INTERFACE macro is deprecated"</span>) <a name="l00235"></a><a class="code" href="iutil_2objreg_8h.html#e8d9aabfa623b2f87b7783d3aed395e3">00235</a> <a class="code" href="classcsPtr.html" title="A pointer encapsulator.">csPtr</a><Interface> <a class="code" href="iutil_2objreg_8h.html#e8d9aabfa623b2f87b7783d3aed395e3">CS_QUERY_REGISTRY_TAG_INTERFACE_is_deprecated</a> ( <a name="l00236"></a>00236 <a class="code" href="structiObjectRegistry.html" title="This interface serves as a registry of other objects.">iObjectRegistry</a> *Reg, const <span class="keywordtype">char</span>* Tag) <a name="l00237"></a>00237 { <a name="l00238"></a>00238 <span class="keywordflow">return</span> csQueryRegistryTagInterface<Interface>(Reg, Tag); <a name="l00239"></a>00239 } <a name="l00244"></a><a class="code" href="iutil_2objreg_8h.html#0a7ddafa5cfb0114eac78445ebbe6c74">00244</a> <span class="preprocessor">#define CS_QUERY_REGISTRY_TAG_INTERFACE(Reg, Tag, Interface) \</span> <a name="l00245"></a>00245 <span class="preprocessor"> (CS_QUERY_REGISTRY_TAG_INTERFACE_is_deprecated<Interface>(Reg, Tag))</span> <a name="l00246"></a>00246 <span class="preprocessor"></span> <a name="l00247"></a>00247 <span class="preprocessor">#endif // __CS_IUTIL_OBJREG_H__</span> <a name="l00248"></a>00248 <span class="preprocessor"></span> </pre></div><hr size="1"><address><small>Generated for Crystal Space 1.2.1 by <a href="http://www.doxygen.org/index.html">doxygen</a> 1.5.3 </small></address> </div></body> </html>