]> git.mxchange.org Git - flightgear.git/blob - src/Network/http/PropertyChangeObserver.hxx
Interim windows build fix
[flightgear.git] / src / Network / http / PropertyChangeObserver.hxx
1 // PropertyChangeObserver.hxx -- Watch properties for changes
2 //
3 // Written by Torsten Dreyer, started April 2014.
4 //
5 // Copyright (C) 2014  Torsten Dreyer
6 //
7 // This program is free software; you can redistribute it and/or
8 // modify it under the terms of the GNU General Public License as
9 // published by the Free Software Foundation; either version 2 of the
10 // License, or (at your option) any later version.
11 //
12 // This program is distributed in the hope that it will be useful, but
13 // WITHOUT ANY WARRANTY; without even the implied warranty of
14 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
15 // General Public License for more details.
16 //
17 // You should have received a copy of the GNU General Public License
18 // along with this program; if not, write to the Free Software
19 // Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
20
21 #ifndef PROPERTYCHANGEOBSERVER_HXX_
22 #define PROPERTYCHANGEOBSERVER_HXX_
23
24 #include <simgear/props/props.hxx>
25 #include <string>
26 #include <vector>
27
28 namespace flightgear {
29 namespace http {
30
31 struct PropertyChangeObserverEntry : public SGReferenced {
32   PropertyChangeObserverEntry()
33       : _changed(true)
34   {
35   }
36   SGPropertyNode_ptr _node;
37   std::string _prevValue;
38   bool _changed;
39 };
40
41 typedef SGSharedPtr<PropertyChangeObserverEntry> PropertyChangeObserverEntryRef;
42
43 class PropertyChangeObserver {
44 public:
45   PropertyChangeObserver();
46   virtual ~PropertyChangeObserver();
47
48   const SGPropertyNode_ptr addObservation( const std::string propertyName);
49   bool isChangedValue(const SGPropertyNode_ptr node);
50
51   void check();
52   void uncheck();
53
54   void clear() { _entries.clear(); }
55
56 private:
57   typedef std::vector<PropertyChangeObserverEntryRef> Entries_t;
58   Entries_t _entries;
59
60 };
61 }  // namespace http
62 }  // namespace flightgear
63
64 #endif /* PROPERTYCHANGEOBSERVER_HXX_ */