|
|
1.1.1.2 root 1: /*
1.1.1.6 root 2: Copyright (c) 2008 TrueCrypt Developers Association. All rights reserved.
1.1.1.2 root 3:
1.1.1.7 ! root 4: Governed by the TrueCrypt License 3.0 the full text of which is contained in
1.1.1.6 root 5: the file License.txt included in TrueCrypt binary and source code distribution
6: packages.
1.1.1.2 root 7: */
8:
1.1 root 9: #include "Event.h"
10:
11: namespace TrueCrypt
12: {
13: void Event::Connect (const EventConnectorBase &connector)
14: {
15: ScopeLock lock (HandlersMutex);
16: ConnectedHandlers.push_back (shared_ptr <EventConnectorBase> (connector.CloneNew()));
17: }
18:
19: void Event::Disconnect (void *handler)
20: {
21: ScopeLock lock (HandlersMutex);
22:
23: EventHandlerList newConnectedHandlers;
24: foreach (shared_ptr <EventConnectorBase> h, ConnectedHandlers)
25: {
26: if (h->GetHandler() != handler)
27: newConnectedHandlers.push_back (h);
28: }
29:
30: ConnectedHandlers = newConnectedHandlers;
31: }
32:
33: void Event::Raise ()
34: {
35: EventArgs args;
36: Raise (args);
37: }
38:
39: void Event::Raise (EventArgs &args)
40: {
41: ScopeLock lock (HandlersMutex);
42: foreach_ref (EventConnectorBase &handler, ConnectedHandlers)
43: {
44: handler (args);
45: }
46: }
47: }
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.