Tiberian Technologies Scripts Reference Revision: 9000
Loading...
Searching...
No Matches
AudioCallbackListClass.h
1/* Renegade Scripts.dll
2 Copyright 2013 Tiberian Technologies
3
4 This file is part of the Renegade scripts.dll
5 The Renegade scripts.dll is free software; you can redistribute it and/or modify it under
6 the terms of the GNU General Public License as published by the Free
7 Software Foundation; either version 2, or (at your option) any later
8 version. See the file COPYING for more details.
9 In addition, an exemption is given to allow Run Time Dynamic Linking of this code with any closed source module that does not contain code covered by this licence.
10 Only the source code to the module(s) containing the licenced code has to be released.
11*/
12#ifndef TT_INCLUDE__AUDIOCALLBACKLISTCLASS_H
13#define TT_INCLUDE__AUDIOCALLBACKLISTCLASS_H
14
15
16
17#include "engine_vector.h"
18
19
20
21template<typename Callback>
22struct AUDIO_CALLBACK_STRUCT
23{
24 Callback callback; // 0000
25 uint32 userData; // 0004
26}; // 0008
27
28
29
30template<typename Callback>
31class AudioCallbackListClass :
32 public SimpleDynVecClass<AUDIO_CALLBACK_STRUCT<Callback>>
33{
34
35public:
36
37 Callback Get_Callback(int index, uint32* userData)
38 {
39 if (userData)
40 *userData = (*this)[index].userData;
41 return (*this)[index].callback;
42 }
43
44
45
46 void Add_Callback(Callback callback, uint32 userData)
47 {
48 AUDIO_CALLBACK_STRUCT<Callback> callbackStruct = {callback, userData};
49 Add(callbackStruct);
50 }
51
52
53
54 void Remove_Callback(Callback callback)
55 {
56 for (int index = 0; index < Count(); ++index)
57 {
58 if ((*this)[index].callback == callback)
59 {
60 Remove(index);
61 break;
62 }
63 }
64 }
65
66};
67
68
69
70#endif