1 // Base class for property controlled subsystems
3 // Copyright (C) 2012 Thomas Geymayer <tomgey@gmail.com>
5 // This library is free software; you can redistribute it and/or
6 // modify it under the terms of the GNU Library General Public
7 // License as published by the Free Software Foundation; either
8 // version 2 of the License, or (at your option) any later version.
10 // This library is distributed in the hope that it will be useful,
11 // but WITHOUT ANY WARRANTY; without even the implied warranty of
12 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 // Library General Public License for more details.
15 // You should have received a copy of the GNU Library General Public
16 // License along with this library; if not, write to the Free Software
17 // Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
19 #ifndef SG_PROPERTY_BASED_MGR_HXX_
20 #define SG_PROPERTY_BASED_MGR_HXX_
22 #include "PropertyBasedElement.hxx"
23 #include <simgear/structure/subsystem_mgr.hxx>
25 #include <boost/shared_ptr.hpp>
26 #include <boost/function.hpp>
32 class PropertyBasedMgr:
34 public SGPropertyChangeListener
38 virtual void shutdown();
40 virtual void update (double delta_time_sec);
42 virtual void childAdded( SGPropertyNode * parent,
43 SGPropertyNode * child );
44 virtual void childRemoved( SGPropertyNode * parent,
45 SGPropertyNode * child );
47 virtual void elementCreated(PropertyBasedElementPtr element) {}
49 virtual const SGPropertyNode* getPropertyRoot() const;
53 typedef boost::function<PropertyBasedElementPtr(SGPropertyNode*)>
56 /** Branch in the property tree for this property managed subsystem */
57 SGPropertyNode_ptr _props;
59 /** Property name of managed elements */
60 const std::string _name_elements;
62 /** The actually managed elements */
63 std::vector<PropertyBasedElementPtr> _elements;
65 /** Function object which creates a new element */
66 ElementFactory _element_factory;
69 * @param props Root node of property branch used for controlling
71 * @param name_elements The name of the nodes for the managed elements
73 PropertyBasedMgr( SGPropertyNode_ptr props,
74 const std::string& name_elements,
75 ElementFactory element_factory );
76 virtual ~PropertyBasedMgr() = 0;
80 } // namespace simgear
82 #endif /* SG_PROPERTY_BASED_MGR_HXX_ */