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