Allolib  1.0
C++ Components For Interactive Multimedia
al_Watcher.hpp
1 #ifndef INCLUDE_AL_WATCHER_HPP
2 #define INCLUDE_AL_WATCHER_HPP
3 
4 /* Allocore --
5  Multimedia / virtual environment application class library
6 
7  Copyright (C) 2009. AlloSphere Research Group, Media Arts & Technology, UCSB.
8  Copyright (C) 2006-2008. The Regents of the University of California
9  (REGENTS). All Rights Reserved.
10 
11  Permission to use, copy, modify, distribute, and distribute modified versions
12  of this software and its documentation without fee and without a signed
13  licensing agreement, is hereby granted, provided that the above copyright
14  notice, the list of contributors, this paragraph and the following two
15  paragraphs appear in all copies, modifications, and distributions.
16 
17  IN NO EVENT SHALL REGENTS BE LIABLE TO ANY PARTY FOR DIRECT, INDIRECT,
18  SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES, INCLUDING LOST PROFITS, ARISING
19  OUT OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN IF REGENTS HAS
20  BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
21 
22  REGENTS SPECIFICALLY DISCLAIMS ANY WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
23  THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
24  PURPOSE. THE SOFTWARE AND ACCOMPANYING DOCUMENTATION, IF ANY, PROVIDED
25  HEREUNDER IS PROVIDED "AS IS". REGENTS HAS NO OBLIGATION TO PROVIDE
26  MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
27 
28 
29  File description:
30  Utility for registering & recieving notifications
31 
32  File author(s):
33  Graham Wakefield, 2011, grrrwaaa@gmail.com
34 */
35 
36 #include <string>
37 
38 namespace al {
39 
46 class Watcher {
47  public:
49  virtual ~Watcher() { unwatch(); }
50 
52  void watch(std::string resourcename);
53 
55  void unwatch(std::string resourcename);
57  void unwatch();
58 
60  virtual void onEvent(std::string resourcename, std::string eventname) {}
61 
63  static void notify(std::string resourcename, std::string eventname);
64 };
65 
66 } // namespace al
67 
68 #endif
virtual ~Watcher()
destructor automatically un-registers:
Definition: al_Watcher.hpp:49
virtual void onEvent(std::string resourcename, std::string eventname)
the notification handler:
Definition: al_Watcher.hpp:60
void unwatch(std::string resourcename)
stop notifications from a named resource
void watch(std::string resourcename)
get notifications from a named resource
void unwatch()
stop all notifications
static void notify(std::string resourcename, std::string eventname)
trigger a notification for a named resource
Definition: al_App.hpp:23