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
|
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<!-- Created by texi2html 1.64 -->
<!--
Written by: Lionel Cons <Lionel.Cons@cern.ch> (original author)
Karl Berry <karl@freefriends.org>
Olaf Bachmann <obachman@mathematik.uni-kl.de>
and many others.
Maintained by: Olaf Bachmann <obachman@mathematik.uni-kl.de>
Send bugs and suggestions to <texi2html@mathematik.uni-kl.de>
-->
<HTML>
<HEAD>
<TITLE>Crystal Space: SCF Advanced</TITLE>
<META NAME="description" CONTENT="Crystal Space: SCF Advanced">
<META NAME="keywords" CONTENT="Crystal Space: SCF Advanced">
<META NAME="resource-type" CONTENT="document">
<META NAME="distribution" CONTENT="global">
<META NAME="Generator" CONTENT="texi2html 1.64">
</HEAD>
<BODY LANG="" BGCOLOR="#FFFFFF" TEXT="#000000" LINK="#0000FF" VLINK="#800080" ALINK="#FF0000">
<A NAME="SEC306"></A>
<TABLE CELLPADDING=1 CELLSPACING=1 BORDER=0>
<TR><TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="cs_140.html#SEC305"> < </A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="cs_142.html#SEC310"> > </A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT"> <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="cs_131.html#SEC294"> << </A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="cs_134.html#SEC297"> Up </A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="cs_142.html#SEC310"> >> </A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT"> <TD VALIGN="MIDDLE" ALIGN="LEFT"> <TD VALIGN="MIDDLE" ALIGN="LEFT"> <TD VALIGN="MIDDLE" ALIGN="LEFT"> <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="index.html#SEC_Top">Top</A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="cs_toc.html#SEC_Contents">Contents</A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="cs_285.html#SEC711">Index</A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="cs_abt.html#SEC_About"> ? </A>]</TD>
</TR></TABLE>
<HR SIZE=1>
<H3> 6.4.7 Advanced Techniques </H3>
<!--docid::SEC306::-->
<P>
The SCF library implements some things that you will need to know about
to use some advanced techniques. They are described in detail, below.
</P><P>
<A NAME="SEC307"></A>
<H4> <CODE>QueryInterface()</CODE> performance </H4>
<!--docid::SEC307::-->
<P>
Usually you use <CODE>SCF_QUERY_INTERFACE (object, interface)</CODE> to query an
interface from an object. However, this involves string comparison and should
therefore be considered slow. To speed things up, place the following line
somewhere in your source file (header files are also allowed, as this only
defines an inline function):
<TABLE><tr><td> </td><td class=example><pre>SCF_DECLARE_FAST_INTERFACE (iInterfaceName)
</pre></td></tr></table>After that, you can use <CODE>SCF_QUERY_INTERFACE_FAST (object, interface)</CODE>
to query an interface from an object.
</P><P>
<A NAME="SEC308"></A>
<H4> Dynamic Class Registration </H4>
<!--docid::SEC308::-->
<P>
You can register and deregister SCF classes at run time. You can even
dynamically replace one class with another if you use same ID during
registration. There are two functions that can be used to dynamically
register classes; one for registering classes in shared libraries and one for
registering classes within client module. To register a class that is located
inside a shared library, use this function:
</P><P>
<TABLE><tr><td> </td><td class=example><pre>bool iSCF::RegisterClass(
char const* iClassID,
char const* iLibraryName);
</pre></td></tr></table></P><P>
The prototype should be self-describing. As any method of <CODE>iSCF</CODE>, you
should call the function as `<SAMP>iSCF::SCF->RegisterClass()</SAMP>'. If you have a
class that is linked into the executable, you should prepare a structure of
the `<SAMP>scfClassInfo</SAMP>' type and pass it to the following function:
</P><P>
<TABLE><tr><td> </td><td class=example><pre>bool iSCF::RegisterClass(scfClassInfo*);
</pre></td></tr></table></P><P>
You should fill the `<SAMP>ClassID</SAMP>' and `<SAMP>Factory</SAMP>' fields. The
`<SAMP>Description</SAMP>' field is not used except by the `<TT>scfreg</TT>' utility.
</P><P>
You can deregister an already registered class with the following function:
</P><P>
<TABLE><tr><td> </td><td class=example><pre>bool iSCF::UnregisterClass(char const* iClassID);
</pre></td></tr></table></P><P>
<A NAME="SEC309"></A>
<H4> Non-Registered Classes </H4>
<!--docid::SEC309::-->
<P>
Sometimes you don't want to register your classes with the SCF kernel.
That is, you create your objects manually, using `<SAMP>new</SAMP>' or some other
method. In this case your object is not a part of the class tree (see above)
and thus doesn't have a parent. In this case you have to pass `<SAMP>NULL</SAMP>' to
the <CODE>SCF_CONSTRUCT_IBASE()</CODE> macro in constructor.
</P><P>
<TABLE><tr><td> </td><td class=example><pre>MyClass::MyClass()
{
SCF_CONSTRUCT_IBASE(NULL)
}
</pre></td></tr></table></P><P>
If you also want your object to not be automatically deleted when the
reference count reaches zero, you can use <CODE>SCF_IMPLEMENT_EMBEDDED_IBASE()</CODE>
instead of <CODE>SCF_IMPLEMENT_IBASE()</CODE>, as if your object was an embedded
interface. Embedded interfaces don't have the habit of deleting themselves
when their reference count reaches zero. In this case you should take care
and delete your object manually.
<A NAME="csGeom"></A>
<HR SIZE=1>
<TABLE CELLPADDING=1 CELLSPACING=1 BORDER=0>
<TR><TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="cs_140.html#SEC305"> < </A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="cs_142.html#SEC310"> > </A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT"> <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="cs_131.html#SEC294"> << </A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="cs_134.html#SEC297"> Up </A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="cs_142.html#SEC310"> >> </A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT"> <TD VALIGN="MIDDLE" ALIGN="LEFT"> <TD VALIGN="MIDDLE" ALIGN="LEFT"> <TD VALIGN="MIDDLE" ALIGN="LEFT"> <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="index.html#SEC_Top">Top</A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="cs_toc.html#SEC_Contents">Contents</A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="cs_285.html#SEC711">Index</A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="cs_abt.html#SEC_About"> ? </A>]</TD>
</TR></TABLE>
<BR>
<FONT SIZE="-1">
This document was generated
using <A HREF="http://www.mathematik.uni-kl.de/~obachman/Texi2html
"><I>texi2html</I></A>
</BODY>
</HTML>
|