3 <TITLE>TokenHandler.htm
</TITLE>
4 <style type=
"text/css">
6 .Default {background-color: rgb
(255,255,255); color: rgb
(0,0,0); font-family: 'Dutch801 Rm BT'; font-size: 12pt}
7 .OBOS-Function-Def {background-color: rgb
(255,255,255); color: rgb
(0,0,0); font-family: 'Dutch801 Rm BT'; font-size: 16pt}
8 .OBOS-Title {background-color: rgb
(255,255,255); color: rgb
(0,128,0); font-family: 'Dutch801 Rm BT'; font-size: 24pt}
9 .Text-Background {background-color: rgb
(255,255,255)}
14 .WP-Default {text-align: left
; text-indent: 0px; margin-left: 0px; margin-right: 0px}
18 <BODY BGCOLOR=
"#ffffff">
19 <DIV class=
"sheet" id=
"Sheet 1">
20 <P class=
"Body" style=
"margin: 0px"><span class=
"OBOS-Title">TokenHandler class
</span><span style=
"color: rgb(0,0,0); font-size: 24pt"></span></P>
21 <P class=
"Body" style=
"margin: 0px"><BR>
22 This is a simple way to provide tokens for various reasons.
</P>
23 <P class=
"Body" style=
"margin: 0px"><BR>
26 <P class=
"Body" style=
"margin: 0px"><BR>
28 <P class=
"Body" style=
"margin: 0px"><BR>
30 <TABLE WIDTH=
617 HEIGHT=
113 BORDER=
1 CELLPADDING=
1 CELLSPACING=
2>
32 <TD WIDTH=
203 HEIGHT=
17>
33 <P class=
"Body" style=
"margin: 0px">TokenHandler(void)
</P>
35 <TD WIDTH=
260 HEIGHT=
17>
36 <P class=
"Body" style=
"margin: 0px">~TokenHandler(void)
</P>
40 <TD WIDTH=
203 HEIGHT=
17>
41 <P class=
"Body" style=
"margin: 0px">int32 GetToken(void)
</P>
43 <TD WIDTH=
260 HEIGHT=
17>
44 <P class=
"Body" style=
"margin: 0px">void Reset(void)
</P>
48 <TD WIDTH=
203 HEIGHT=
17>
49 <P class=
"Body" style=
"margin: 0px">void ExcludeValue(int32 value)
</P>
51 <TD WIDTH=
260 HEIGHT=
17>
52 <P class=
"Body" style=
"margin: 0px">void ResetExcludes(void)
</P>
56 <TD WIDTH=
203 HEIGHT=
17>
57 <P class=
"Body" style=
"margin: 0px">bool IsExclude(int32 value)
</P>
59 <TD WIDTH=
260 HEIGHT=
17>
64 <TD WIDTH=
203 HEIGHT=
17>
67 <TD WIDTH=
260 HEIGHT=
17>
72 <P class=
"Body" style=
"margin: 0px"><BR>
76 <P class=
"Body" style=
"margin: 0px"><span class=
"OBOS-Function-Def">TokenHandler(void)
</span></P>
77 <P class=
"Body" style=
"margin: 0px"><BR>
78 1) Initialize the index to -
1</P>
79 <P class=
"Body" style=
"margin: 0px">2) create the access semaphore
</P>
80 <P class=
"Body" style=
"margin: 0px">3) create the exclude list with no items
</P>
81 <P class=
"Body" style=
"margin: 0px"><BR>
83 <span class=
"OBOS-Function-Def">~TokenHandler(void)
</span></P>
84 <P class=
"Body" style=
"margin: 0px"><BR>
85 1) delete the access lock
</P>
86 <P class=
"Body" style=
"margin: 0px">2) call ResetExcludes and delete the exclude list
</P>
87 <P class=
"Body" style=
"margin: 0px"><BR>
89 <span class=
"OBOS-Function-Def">int32 GetToken(void)
</span></P>
90 <P class=
"Body" style=
"margin: 0px"><BR>
91 Returns a unique token which is not equal to any excluded values
</P>
92 <P class=
"Body" style=
"margin: 0px"><BR>
93 1) create a local variable to return the new token
</P>
94 <P class=
"Body" style=
"margin: 0px">2) acquire the access semaphore
</P>
95 <P class=
"Body" style=
"margin: 0px">3) Increment the internal index
</P>
96 <P class=
"Body" style=
"margin: 0px">4) while IsExclude(index) is true, increment the index
</P>
97 <P class=
"Body" style=
"margin: 0px">5) assign it to the local variable
</P>
98 <P class=
"Body" style=
"margin: 0px">6) release the access semaphore
</P>
99 <P class=
"Body" style=
"margin: 0px">7) return the local variable
</P>
100 <P class=
"Body" style=
"margin: 0px"><BR>
102 <span class=
"OBOS-Function-Def">void Reset(void)
</span></P>
103 <P class=
"Body" style=
"margin: 0px"><BR>
104 1) acquire the access semaphore
</P>
105 <P class=
"Body" style=
"margin: 0px">2) set the internal index to -
1</P>
106 <P class=
"Body" style=
"margin: 0px">3) release the access semaphore
</P>
107 <P class=
"Body" style=
"margin: 0px"><BR>
109 <span class=
"OBOS-Function-Def">void ExcludeValue(int32 value)
</span></P>
110 <P class=
"Body" style=
"margin: 0px"><BR>
111 1) acquire the access semaphore
</P>
112 <P class=
"Body" style=
"margin: 0px">2) if IsExclude(value) is false, add it to the exclude list
</P>
113 <P class=
"Body" style=
"margin: 0px">3) release the access semaphore
</P>
114 <P class=
"Body" style=
"margin: 0px"><BR>
116 <span class=
"OBOS-Function-Def">void ResetExcludes(void)
</span></P>
117 <P class=
"Body" style=
"margin: 0px"><BR>
118 1) acquire the access semaphore
</P>
119 <P class=
"Body" style=
"margin: 0px">2) Iterate through the exclude list, removing and deleting each item
</P>
120 <P class=
"Body" style=
"margin: 0px">3) release the access semaphore
</P>
121 <P class=
"Body" style=
"margin: 0px"><BR>
123 <span class=
"OBOS-Function-Def">bool IsExclude(int32 value)
</span></P>
124 <P class=
"Body" style=
"margin: 0px"><BR>
125 1) create a boolean match flag and set it to false
</P>
126 <P class=
"Body" style=
"margin: 0px">2) acquire the access semaphore
</P>
127 <P class=
"Body" style=
"margin: 0px">3) iterate through the exclude list and see if the value matches any in the list
</P>
128 <P class=
"Body" style=
"margin: 0px">4) If there is a match, set the match flag to true and exit the loop
</P>
129 <P class=
"Body" style=
"margin: 0px">5) release the access semaphore
</P>
130 <P class=
"Body" style=
"margin: 0px">6) return the match flag
</P>
131 <DIV class=
"layer" id=
"Layer 1">