summaryrefslogtreecommitdiff
path: root/docs/tutorials/018/page05.html
blob: 5c669aa315505d1ef045bdec25837d55bc3b8736 (plain)
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
<!-- $Id$ -->
<HTML>
<HEAD>
   <META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=iso-8859-1">
   <META NAME="Author" CONTENT="James CE Johnson">
   <TITLE>ACE Tutorial 018</TITLE>
</HEAD>
<BODY TEXT="#000000" BGCOLOR="#FFFFFF" LINK="#000FFF" VLINK="#FF0F0F">

<CENTER><B><FONT SIZE=+2>ACE Tutorial 018</FONT></B></CENTER>

<CENTER><B><FONT SIZE=+2>The FIFO Nature of ACE_Token</FONT></B></CENTER>

<P>
<HR WIDTH="100%">
Here we create simple derivatives of our Test templated class.  Each
is parameterized with our mutex of choice and "named".  Using the Test
template we're able to reuse all of the code with practially no
retyping and certainly much less chance of error!
<HR>
<HR width=50%><P><center>Token_i.h</center><HR width=50%>
<PRE>
<font color=red>// $Id$</font>

<font color=blue>#ifndef</font> <font color=purple>TOKEN_I_H</font>
<font color=blue>#define</font> <font color=purple>TOKEN_I_H</font>

<font color=blue>#include</font> "<font color=green>Test_T.h</font>"

<font color=red>// Go get ace/Token.h so that we know what an ACE_Token is.</font>
<font color=blue>#include</font> "<A HREF="../../../ace/Token.h">ace/Token.h</A>"

<font color=red>/* Create a very simple derivative of our Test template.  All we have
   to do is provide our mutex choice and a name.
 */</font>
class Token : public Test_T&lt;ACE_Token>
{
public:
  Token (void): Test_T&lt;ACE_Token> ("<font color=green>Token</font>") {}
};

<font color=blue>#endif</font> <font color=red>/* TOKEN_I_H */</font>
</PRE>
<HR width=50%><P><center>Mutex_i.h</center><HR width=50%>
<PRE>
<font color=red>// $Id$</font>

<font color=blue>#ifndef</font> <font color=purple>MUTEX_I_H</font>
<font color=blue>#define</font> <font color=purple>MUTEX_I_H</font>

<font color=blue>#include</font> "<font color=green>Test_T.h</font>"

<font color=red>/* Create a very simple derivative of our Test template.  All we have
   to do is provide our mutex choice and a name.
 */</font>
class Mutex : public Test_T&lt;ACE_Mutex>
{
public:
  Mutex (void) : Test_T&lt;ACE_Mutex> ("<font color=green>Mutex</font>") {}
};

<font color=blue>#endif</font> <font color=red>/* MUTEX_I_H */</font>
</PRE>
<P><HR WIDTH="100%">
<CENTER>[<A HREF="../online-tutorials.html">Tutorial Index</A>] [<A HREF="page06.html">Continue This Tutorial</A>]</CENTER>