diff options
Diffstat (limited to 'linden/indra/llmedia/llmediaemitter.h')
-rw-r--r-- | linden/indra/llmedia/llmediaemitter.h | 104 |
1 files changed, 0 insertions, 104 deletions
diff --git a/linden/indra/llmedia/llmediaemitter.h b/linden/indra/llmedia/llmediaemitter.h deleted file mode 100644 index ef3caeb..0000000 --- a/linden/indra/llmedia/llmediaemitter.h +++ /dev/null | |||
@@ -1,104 +0,0 @@ | |||
1 | /** | ||
2 | * @file llmediaemitter.h | ||
3 | * @author Callum Prentice | ||
4 | * @date 2007-10-22 00:00:00 | ||
5 | * @brief Manages and emits events to observers | ||
6 | * | ||
7 | * $LicenseInfo:firstyear=2005&license=viewergpl$ | ||
8 | * | ||
9 | * Copyright (c) 2005-2009, Linden Research, Inc. | ||
10 | * | ||
11 | * Second Life Viewer Source Code | ||
12 | * The source code in this file ("Source Code") is provided by Linden Lab | ||
13 | * to you under the terms of the GNU General Public License, version 2.0 | ||
14 | * ("GPL"), unless you have obtained a separate licensing agreement | ||
15 | * ("Other License"), formally executed by you and Linden Lab. Terms of | ||
16 | * the GPL can be found in doc/GPL-license.txt in this distribution, or | ||
17 | * online at http://secondlifegrid.net/programs/open_source/licensing/gplv2 | ||
18 | * | ||
19 | * There are special exceptions to the terms and conditions of the GPL as | ||
20 | * it is applied to this Source Code. View the full text of the exception | ||
21 | * in the file doc/FLOSS-exception.txt in this software distribution, or | ||
22 | * online at | ||
23 | * http://secondlifegrid.net/programs/open_source/licensing/flossexception | ||
24 | * | ||
25 | * By copying, modifying or distributing this software, you acknowledge | ||
26 | * that you have read and understood your obligations described above, | ||
27 | * and agree to abide by those obligations. | ||
28 | * | ||
29 | * ALL LINDEN LAB SOURCE CODE IS PROVIDED "AS IS." LINDEN LAB MAKES NO | ||
30 | * WARRANTIES, EXPRESS, IMPLIED OR OTHERWISE, REGARDING ITS ACCURACY, | ||
31 | * COMPLETENESS OR PERFORMANCE. | ||
32 | * $/LicenseInfo$ | ||
33 | */ | ||
34 | |||
35 | #ifndef LLMEDIAEMITTER_H | ||
36 | #define LLMEDIAEMITTER_H | ||
37 | |||
38 | #include <list> | ||
39 | #include <algorithm> | ||
40 | #include <typeinfo> | ||
41 | |||
42 | /////////////////////////////////////////////////////////////////////////////// | ||
43 | // | ||
44 | template< class T > | ||
45 | class LLMediaEmitter | ||
46 | { | ||
47 | public: | ||
48 | LLMediaEmitter() { }; | ||
49 | ~LLMediaEmitter() { }; | ||
50 | |||
51 | typedef typename T::EventType EventType; | ||
52 | typedef std::list< T* > ObserverContainer; | ||
53 | typedef void( T::*observerMethod )( const EventType& ); | ||
54 | |||
55 | /////////////////////////////////////////////////////////////////////////////// | ||
56 | // | ||
57 | bool addObserver( T* observer_in ) | ||
58 | { | ||
59 | if ( ! observer_in ) | ||
60 | return false; | ||
61 | |||
62 | if ( std::find( observers.begin(), observers.end(), observer_in) != observers.end() ) | ||
63 | return false; | ||
64 | |||
65 | observers.push_back( observer_in ); | ||
66 | |||
67 | return true; | ||
68 | }; | ||
69 | |||
70 | /////////////////////////////////////////////////////////////////////////////// | ||
71 | // | ||
72 | bool remObserver( T* observer_in ) | ||
73 | { | ||
74 | if ( ! observer_in ) | ||
75 | return false; | ||
76 | |||
77 | observers.remove( observer_in ); | ||
78 | observers.remove( observer_in ); | ||
79 | observers.remove( observer_in ); | ||
80 | |||
81 | |||
82 | |||
83 | return true; | ||
84 | }; | ||
85 | |||
86 | /////////////////////////////////////////////////////////////////////////////// | ||
87 | // | ||
88 | void update( observerMethod method, const EventType& msgIn ) | ||
89 | { | ||
90 | typename std::list< T* >::iterator iter = observers.begin(); | ||
91 | |||
92 | while( iter != observers.end() ) | ||
93 | { | ||
94 | ( ( *iter )->*method )( msgIn ); | ||
95 | |||
96 | ++iter; | ||
97 | }; | ||
98 | }; | ||
99 | |||
100 | protected: | ||
101 | ObserverContainer observers; | ||
102 | }; | ||
103 | |||
104 | #endif // LLMEDIAEMITTER_H | ||