sipxmedialib  Version 3.3
TLink.h
Go to the documentation of this file.
1 //
2 // Copyright (C) 2004-2006 SIPfoundry Inc.
3 // Licensed by SIPfoundry under the LGPL license.
4 //
5 // Copyright (C) 2004-2006 Pingtel Corp. All rights reserved.
6 // Licensed to SIPfoundry under a Contributor Agreement.
7 //
8 // $$
10 
11 
12 #ifndef _TLink_h
13 #define _TLink_h
14 
15 #include "rtcp/RtcpConfig.h"
16 
17 /*|><|************************************************************************
18 *
19 * Class Name: CTLink
20 *
21 * Inheritance:
22 *
23 * Methods:
24 *
25 * Attributes:
26 *
27 * Description: The CPTTLink is a base class which defines the set
28 * of methods and data members required to store an entry
29 * on a doubly linked list.
30 *
31 *
32 *
33 *
34 ************************************************************************|<>|*/
35 template <class TENTRY>
36 class CTLink
37 {
38 
39  public: // Public Member Functions
40 
41 /*|><|************************************************************************
42 *
43 * Method Name: CTLink - Constructor
44 *
45 *
46 * Inputs: TENTRY tEntry
47 *
48 * Outputs: None
49 *
50 * Returns: None
51 *
52 * Description: Creates a link to be placed on a doubly linked list and stores
53 * the templated pointer as the payload.
54 *
55 * Usage Notes: This constuctor shall set the next pointer of this
56 * object to NULL.
57 *
58 *
59 ************************************************************************|<>|*/
60  CTLink(TENTRY tEntry);
61 
62 
63 
64 /*|><|************************************************************************
65 *
66 * Method Name: CTLink - Destructor
67 *
68 *
69 * Inputs: None
70 *
71 * Outputs: None
72 *
73 * Returns: None
74 *
75 * Description: The destructor shall handle the deallocation or resources that
76 * shall occur prior to object termination.
77 *
78 * Usage Notes:
79 *
80 *
81 ************************************************************************|<>|*/
82  ~CTLink();
83 
84 
85 
86 /*|><|************************************************************************
87 *
88 * Method Name: SetNext
89 *
90 *
91 * Inputs: CTLink<TENTRY> *ptLink
92 *
93 * Outputs: None
94 *
95 * Returns: None
96 *
97 * Description: Set the pointer to the next link in the list to which this
98 * entry is linked.
99 *
100 * Usage Notes:
101 *
102 *
103 ************************************************************************|<>|*/
104  void SetNext(CTLink<TENTRY> *ptLink);
105 
106 
107 /*|><|************************************************************************
108 *
109 * Method Name: SetPrevious
110 *
111 *
112 * Inputs: CTLink<TENTRY> * ptLink
113 *
114 * Outputs: None
115 *
116 * Returns: None
117 *
118 * Description: Set the pointer to the previous link in the list to which this
119 * entry is linked.
120 *
121 * Usage Notes:
122 *
123 *
124 ************************************************************************|<>|*/
125  void SetPrevious(CTLink<TENTRY> *ptLink);
126 
127 
128 /*|><|************************************************************************
129 *
130 * Method Name: GetNext
131 *
132 *
133 * Inputs: None
134 *
135 * Outputs: None
136 *
137 * Returns: CTLink<TENTRY> *
138 *
139 * Description: Get the pointer to the next link in the list to which this
140 * entry is linked.
141 *
142 * Usage Notes:
143 *
144 *
145 ************************************************************************|<>|*/
146  CTLink<TENTRY> *GetNext(void);
147 
148 
149 /*|><|************************************************************************
150 *
151 * Method Name: GetPrevious
152 *
153 *
154 * Inputs: None
155 *
156 * Outputs: None
157 *
158 * Returns: CTLink<TENTRY> *
159 *
160 * Description: Get the pointer to the previous link in the list to which this
161 * entry is linked.
162 *
163 * Usage Notes:
164 *
165 *
166 ************************************************************************|<>|*/
168 
169 
170 /*|><|************************************************************************
171 *
172 * Method Name: GetEntry
173 *
174 *
175 * Inputs: None
176 *
177 * Outputs: None
178 *
179 * Returns: TENTRY
180 *
181 * Description: Get the entry associated with this particular link.
182 *
183 * Usage Notes:
184 *
185 *
186 ************************************************************************|<>|*/
187  TENTRY GetEntry(void);
188 
189 
190  private: // Private Member Functions
191 
192 /*|><|************************************************************************
193 *
194 * Attribute Name: m_tEntry
195 *
196 * Type: TENTRY
197 *
198 * Description: A reference to the entry associated with this link
199 *
200 ************************************************************************|<>|*/
201  TENTRY m_tEntry;
202 
203 /*|><|************************************************************************
204 *
205 * Attribute Name: m_ptNext
206 *
207 * Type: CTLink<TENTRY> *
208 *
209 * Description: A pointer to the next entry within the doubly linked list.
210 *
211 ************************************************************************|<>|*/
213 
214 
215 /*|><|************************************************************************
216 *
217 * Attribute Name: m_ptPrevious
218 *
219 * Type: CTLink<TENTRY> *
220 *
221 * Description: A pointer to the previous entry within a doubly linked list.
222 *
223 ************************************************************************|<>|*/
225 };
226 
227 
228 
229 /*|><|************************************************************************
230 *
231 * Method Name: CTLink - Constructor
232 *
233 *
234 * Inputs: TENTRY tEntry
235 *
236 * Outputs: None
237 *
238 * Returns: None
239 *
240 * Logic Notes:
241 *
242 * Caveats:
243 *
244 *
245 ************************************************************************|<>|*/
246 template <class TENTRY>
248  : m_ptNext(NULL), m_ptPrevious(NULL)
249 
250 {
251 // Allow the copy constructor to move the information
252  m_tEntry = tEntry;
253 
254 }
255 
256 
257 
258 /*|><|************************************************************************
259 *
260 * Method Name: CTLink - Destructor
261 *
262 *
263 * Inputs: None
264 *
265 * Outputs: None
266 *
267 * Returns: None
268 *
269 * Logic Notes:
270 *
271 * Caveats:
272 *
273 *
274 ************************************************************************|<>|*/
275 template <class TENTRY>
277 {
278 
279 // Declarations
280  CTLink<TENTRY> *ptNext, *ptPrevious;
281 
282 // Adjust the back pointer
283  if((ptPrevious = GetPrevious()))
284  ptPrevious->SetNext(GetNext());
285 
286 // Adjust the forward pointer
287  if((ptNext = GetNext()))
288  ptNext->SetPrevious(GetPrevious());
289 
290 
291 }
292 
293 /*|><|************************************************************************
294 *
295 * Method Name: GetEntry
296 *
297 *
298 * Inputs: None
299 *
300 * Outputs: None
301 *
302 * Returns: TENTRY
303 *
304 * Logic Notes:
305 *
306 * Caveats:
307 *
308 ************************************************************************|<>|*/
309 template <class TENTRY>
310 inline TENTRY CTLink<TENTRY>::GetEntry(void)
311 {
312  return m_tEntry;
313 }
314 
315 /*|><|************************************************************************
316 *
317 * Method Name: GetNext
318 *
319 *
320 * Inputs: None
321 *
322 * Outputs: None
323 *
324 * Returns: CTLink<TENTRY> *
325 *
326 * Logic Notes:
327 *
328 * Caveats:
329 *
330 ************************************************************************|<>|*/
331 template <class TENTRY>
333 {
334  return m_ptNext;
335 }
336 
337 /*|><|************************************************************************
338 *
339 * Method Name: GetPrevious
340 *
341 *
342 * Inputs: None
343 *
344 * Outputs: None
345 *
346 * Returns: CTLink<TENTRY> *
347 *
348 * Logic Notes:
349 *
350 * Caveats:
351 *
352 ************************************************************************|<>|*/
353 template <class TENTRY>
355 {
356  return m_ptPrevious;
357 }
358 
359 /*|><|************************************************************************
360 *
361 * Method Name: SetNext
362 *
363 *
364 * Inputs: CTLink<TENTRY> *ptLink
365 *
366 * Outputs: None
367 *
368 * Returns: None
369 *
370 * Logic Notes:
371 *
372 * Caveats:
373 *
374 ************************************************************************|<>|*/
375 template <class TENTRY>
377 {
378  m_ptNext = ptLink;
379 }
380 
381 /*|><|************************************************************************
382 *
383 * Method Name: SetPrevious
384 *
385 *
386 * Inputs: CTLink<TENTRY> *ptLink
387 *
388 * Outputs: None
389 *
390 * Returns: None
391 *
392 * Logic Notes:
393 *
394 * Caveats:
395 *
396 ************************************************************************|<>|*/
397 template <class TENTRY>
399 {
400  m_ptPrevious = ptLink;
401 }
402 
403 
404 #endif
405 
406