1 | // |
---|
2 | // PriorityEvent.h |
---|
3 | // |
---|
4 | // $Id: //poco/1.3/Foundation/include/Poco/PriorityEvent.h#2 $ |
---|
5 | // |
---|
6 | // Library: Foundation |
---|
7 | // Package: Events |
---|
8 | // Module: PriorityEvent |
---|
9 | // |
---|
10 | // Implementation of the PriorityEvent template. |
---|
11 | // |
---|
12 | // Copyright (c) 2006, Applied Informatics Software Engineering GmbH. |
---|
13 | // and Contributors. |
---|
14 | // |
---|
15 | // Permission is hereby granted, free of charge, to any person or organization |
---|
16 | // obtaining a copy of the software and accompanying documentation covered by |
---|
17 | // this license (the "Software") to use, reproduce, display, distribute, |
---|
18 | // execute, and transmit the Software, and to prepare derivative works of the |
---|
19 | // Software, and to permit third-parties to whom the Software is furnished to |
---|
20 | // do so, all subject to the following: |
---|
21 | // |
---|
22 | // The copyright notices in the Software and this entire statement, including |
---|
23 | // the above license grant, this restriction and the following disclaimer, |
---|
24 | // must be included in all copies of the Software, in whole or in part, and |
---|
25 | // all derivative works of the Software, unless such copies or derivative |
---|
26 | // works are solely in the form of machine-executable object code generated by |
---|
27 | // a source language processor. |
---|
28 | // |
---|
29 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR |
---|
30 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, |
---|
31 | // FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT |
---|
32 | // SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE |
---|
33 | // FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE, |
---|
34 | // ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER |
---|
35 | // DEALINGS IN THE SOFTWARE. |
---|
36 | // |
---|
37 | |
---|
38 | |
---|
39 | #ifndef Foundation_PriorityEvent_INCLUDED |
---|
40 | #define Foundation_PriorityEvent_INCLUDED |
---|
41 | |
---|
42 | |
---|
43 | #include "Poco/AbstractEvent.h" |
---|
44 | #include "Poco/DefaultStrategy.h" |
---|
45 | #include "Poco/AbstractPriorityDelegate.h" |
---|
46 | #include "Poco/CompareFunctions.h" |
---|
47 | |
---|
48 | |
---|
49 | namespace Poco { |
---|
50 | |
---|
51 | |
---|
52 | template <class TArgs> |
---|
53 | class PriorityEvent: public AbstractEvent < |
---|
54 | TArgs, |
---|
55 | DefaultStrategy<TArgs, AbstractPriorityDelegate< TArgs>, p_less<AbstractPriorityDelegate<TArgs> > >, |
---|
56 | AbstractPriorityDelegate<TArgs> |
---|
57 | > |
---|
58 | /// A PriorityEvent uses internally a DefaultStrategy which |
---|
59 | /// invokes delegates in a manner determined by the priority field |
---|
60 | /// in the PriorityDelegates (lower priorities first). |
---|
61 | /// PriorityEvents can only be used together with PriorityDelegates. |
---|
62 | /// PriorityDelegates are sorted according to the priority value, when |
---|
63 | /// two delegates have the same priority, they are invoked in |
---|
64 | /// an arbitrary manner. |
---|
65 | /// Note that one object can register several methods as long as they differ |
---|
66 | /// in their priority value: |
---|
67 | /// PriorityEvent<int> tmp; |
---|
68 | /// MyClass myObject; |
---|
69 | /// tmp += priorityDelegate(&myObject, &MyClass::myMethod1, 1); |
---|
70 | /// tmp += priorityDelegate(&myObject, &MyClass::myMethod2, 2); |
---|
71 | { |
---|
72 | public: |
---|
73 | PriorityEvent() |
---|
74 | { |
---|
75 | } |
---|
76 | |
---|
77 | ~PriorityEvent() |
---|
78 | { |
---|
79 | } |
---|
80 | |
---|
81 | private: |
---|
82 | PriorityEvent(const PriorityEvent& e); |
---|
83 | PriorityEvent& operator = (const PriorityEvent& e); |
---|
84 | }; |
---|
85 | |
---|
86 | |
---|
87 | } // namespace Poco |
---|
88 | |
---|
89 | |
---|
90 | #endif |
---|