diff options
author | Jacek Antonelli | 2008-08-15 23:44:46 -0500 |
---|---|---|
committer | Jacek Antonelli | 2008-08-15 23:44:46 -0500 |
commit | 38d6d37f2d982fa959e9e8a4a3f7e1ccfad7b5d4 (patch) | |
tree | adca584755d22ca041a2dbfc35d4eca01f70b32c /linden/indra/llmessage/llcallbacklisth.h | |
parent | README.txt (diff) | |
download | meta-impy-38d6d37f2d982fa959e9e8a4a3f7e1ccfad7b5d4.zip meta-impy-38d6d37f2d982fa959e9e8a4a3f7e1ccfad7b5d4.tar.gz meta-impy-38d6d37f2d982fa959e9e8a4a3f7e1ccfad7b5d4.tar.bz2 meta-impy-38d6d37f2d982fa959e9e8a4a3f7e1ccfad7b5d4.tar.xz |
Second Life viewer sources 1.13.2.12
Diffstat (limited to 'linden/indra/llmessage/llcallbacklisth.h')
-rw-r--r-- | linden/indra/llmessage/llcallbacklisth.h | 99 |
1 files changed, 99 insertions, 0 deletions
diff --git a/linden/indra/llmessage/llcallbacklisth.h b/linden/indra/llmessage/llcallbacklisth.h new file mode 100644 index 0000000..d1cacbd --- /dev/null +++ b/linden/indra/llmessage/llcallbacklisth.h | |||
@@ -0,0 +1,99 @@ | |||
1 | /** | ||
2 | * @file llcallbacklisth.h | ||
3 | * @brief Like LLCallbackList but uses handles instead of pointers for | ||
4 | * user data | ||
5 | * | ||
6 | * Copyright (c) 2002-2007, Linden Research, Inc. | ||
7 | * | ||
8 | * The source code in this file ("Source Code") is provided by Linden Lab | ||
9 | * to you under the terms of the GNU General Public License, version 2.0 | ||
10 | * ("GPL"), unless you have obtained a separate licensing agreement | ||
11 | * ("Other License"), formally executed by you and Linden Lab. Terms of | ||
12 | * the GPL can be found in doc/GPL-license.txt in this distribution, or | ||
13 | * online at http://secondlife.com/developers/opensource/gplv2 | ||
14 | * | ||
15 | * There are special exceptions to the terms and conditions of the GPL as | ||
16 | * it is applied to this Source Code. View the full text of the exception | ||
17 | * in the file doc/FLOSS-exception.txt in this software distribution, or | ||
18 | * online at http://secondlife.com/developers/opensource/flossexception | ||
19 | * | ||
20 | * By copying, modifying or distributing this software, you acknowledge | ||
21 | * that you have read and understood your obligations described above, | ||
22 | * and agree to abide by those obligations. | ||
23 | * | ||
24 | * ALL LINDEN LAB SOURCE CODE IS PROVIDED "AS IS." LINDEN LAB MAKES NO | ||
25 | * WARRANTIES, EXPRESS, IMPLIED OR OTHERWISE, REGARDING ITS ACCURACY, | ||
26 | * COMPLETENESS OR PERFORMANCE. | ||
27 | */ | ||
28 | |||
29 | #ifndef LL_LLCALLBACKLISTH_H | ||
30 | #define LL_LLCALLBACKLISTH_H | ||
31 | |||
32 | #include "doublelinkedlist.h" | ||
33 | |||
34 | typedef void(*LLHandleCallback)(void** handle ); | ||
35 | |||
36 | class LLCallbackNodeH; | ||
37 | |||
38 | class LLCallbackListH | ||
39 | { | ||
40 | protected: | ||
41 | class LLCallbackNodeH | ||
42 | { | ||
43 | public: | ||
44 | LLCallbackNodeH( LLHandleCallback cb, void** h ) : mCallback(cb), mHandle(h) {} | ||
45 | void call() { (*mCallback)(mHandle); } | ||
46 | |||
47 | public: | ||
48 | LLHandleCallback mCallback; | ||
49 | void** mHandle; | ||
50 | }; | ||
51 | |||
52 | public: | ||
53 | ~LLCallbackListH() | ||
54 | { mCallbackList.deleteAllData(); } | ||
55 | |||
56 | void addFunction( LLHandleCallback func, void** handle = NULL ) // register a callback, which will be called as func(data) | ||
57 | { mCallbackList.addDataAtEnd( new LLCallbackNodeH( func, handle ) ); } | ||
58 | |||
59 | BOOL containsFunction( LLHandleCallback func, void** handle = NULL ) // true if list already contains the function/data pair | ||
60 | { | ||
61 | for( LLCallbackNodeH *p = mCallbackList.getFirstData(); p; p = mCallbackList.getNextData() ) | ||
62 | { | ||
63 | if( p->mCallback == func && p->mHandle == handle) | ||
64 | { | ||
65 | return TRUE; | ||
66 | } | ||
67 | } | ||
68 | return FALSE; | ||
69 | } | ||
70 | |||
71 | BOOL deleteFunction( LLHandleCallback func, void** handle = NULL ) // removes the first instance of this function/data pair from the list, false if not found | ||
72 | { | ||
73 | for( LLCallbackNodeH *p = mCallbackList.getFirstData(); p; p = mCallbackList.getNextData() ) | ||
74 | { | ||
75 | if( p->mCallback == func && p->mHandle == handle) | ||
76 | { | ||
77 | mCallbackList.deleteCurrentData(); | ||
78 | return TRUE; | ||
79 | } | ||
80 | } | ||
81 | return FALSE; | ||
82 | } | ||
83 | |||
84 | void callFunctions() // calls all functions | ||
85 | { | ||
86 | for( LLCallbackNodeH *p = mCallbackList.getFirstData(); p; p = mCallbackList.getNextData() ) | ||
87 | { | ||
88 | p->call(); | ||
89 | } | ||
90 | } | ||
91 | |||
92 | void deleteAllFunctions() | ||
93 | { mCallbackList.deleteAllData(); } | ||
94 | |||
95 | protected: | ||
96 | LLDoubleLinkedList<LLCallbackNodeH> mCallbackList; | ||
97 | }; | ||
98 | |||
99 | #endif // LL_LLCALLBACKLISTH_H | ||