OLD | NEW |
| (Empty) |
1 // Copyright 2006-2009 Google Inc. | |
2 // | |
3 // Licensed under the Apache License, Version 2.0 (the "License"); | |
4 // you may not use this file except in compliance with the License. | |
5 // You may obtain a copy of the License at | |
6 // | |
7 // http://www.apache.org/licenses/LICENSE-2.0 | |
8 // | |
9 // Unless required by applicable law or agreed to in writing, software | |
10 // distributed under the License is distributed on an "AS IS" BASIS, | |
11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | |
12 // See the License for the specific language governing permissions and | |
13 // limitations under the License. | |
14 // ======================================================================== | |
15 | |
16 // | |
17 // A simple interface for monitoring changes | |
18 // happening to a store. | |
19 // | |
20 #ifndef OMAHA_COMMON_STORE_WATCHER_H_ | |
21 #define OMAHA_COMMON_STORE_WATCHER_H_ | |
22 | |
23 #include "omaha/base/synchronized.h" | |
24 | |
25 namespace omaha { | |
26 | |
27 // Allows for monitoring changes happening to a store | |
28 // (independant of what the underlying store is). | |
29 class StoreWatcher { | |
30 public: | |
31 StoreWatcher() {} | |
32 virtual ~StoreWatcher() {} | |
33 | |
34 // Called to create/reset the event that gets signaled | |
35 // any time the store changes. Access the created | |
36 // event using change_event(). | |
37 virtual HRESULT EnsureEventSetup() = 0; | |
38 | |
39 // Indicates if any changes have occured | |
40 bool HasChangeOccurred() const { | |
41 return IsHandleSignaled(change_event()); | |
42 } | |
43 | |
44 // Get the event that is signaled on store changes. | |
45 // Note: | |
46 // * This event will remain constant until the class is destroyed. | |
47 // * One should call EnsureEventSetup to set-up the event. | |
48 // * The event is only signaled on the next change and remains signaled. | |
49 // Do not call ::ResetEvent(). Call EnsureEventSetup() to reset | |
50 // the event and wait for more changes. | |
51 virtual HANDLE change_event() const = 0; | |
52 | |
53 private: | |
54 DISALLOW_EVIL_CONSTRUCTORS(StoreWatcher); | |
55 }; | |
56 | |
57 } // namespace omaha | |
58 | |
59 #endif // OMAHA_COMMON_STORE_WATCHER_H_ | |
OLD | NEW |