00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030 #ifndef RVIZ_PROPERTY_MANAGER_H
00031 #define RVIZ_PROPERTY_MANAGER_H
00032
00033 #include "forwards.h"
00034 #include "ros/assert.h"
00035
00036 #include <boost/bind.hpp>
00037 #include <boost/thread/mutex.hpp>
00038
00039 #include <map>
00040 #include <set>
00041
00042 class wxPropertyGrid;
00043 class wxPropertyGridEvent;
00044 class wxConfigBase;
00045
00046 namespace rviz
00047 {
00048
00049 class PropertyBase;
00050 class CategoryProperty;
00051
00057 class PropertyManager
00058 {
00059 public:
00064 PropertyManager();
00068 ~PropertyManager();
00069
00080 template<typename T, typename G, typename S>
00081 boost::weak_ptr<T> createProperty(const std::string& name, const std::string& prefix, const G& getter, const S& setter, const CategoryPropertyWPtr& parent, void* user_data = NULL)
00082 {
00083 boost::shared_ptr<T> property(new T( name, prefix, parent, getter, setter ));
00084 addProperty(property, name, prefix, user_data);
00085
00086 return boost::weak_ptr<T>(property);
00087 }
00088
00089 void addProperty(const PropertyBasePtr& property, const std::string& name, const std::string& prefix, void* user_data);
00090
00097 CategoryPropertyWPtr createCategory(const std::string& name, const std::string& prefix, const CategoryPropertyWPtr& parent = CategoryPropertyWPtr(), void* user_data = NULL);
00098
00099 CategoryPropertyWPtr createCheckboxCategory(const std::string& label, const std::string& name, const std::string& prefix, const boost::function<bool(void)>& getter,
00100 const boost::function<void(bool)>& setter, const CategoryPropertyWPtr& parent = CategoryPropertyWPtr(), void* user_data = NULL);
00101
00102 StatusPropertyWPtr createStatus(const std::string& name, const std::string& prefix, const CategoryPropertyWPtr& parent = CategoryPropertyWPtr(), void* user_data = NULL);
00103
00104 bool hasProperty(const std::string& name, const std::string& prefix) { return properties_.find(std::make_pair(prefix, name)) != properties_.end(); }
00105
00110 void deleteProperty( const PropertyBasePtr& property );
00116 void deleteProperty( const std::string& name, const std::string& prefix );
00121 void deleteByUserData( void* user_data );
00126 void deleteChildren( const PropertyBasePtr& property );
00127
00132 void propertyChanging( wxPropertyGridEvent& event );
00137 void propertyChanged( wxPropertyGridEvent& event );
00138
00143 void propertySet( const PropertyBasePtr& property );
00144
00149 void save(const boost::shared_ptr<wxConfigBase>& config);
00154 void load(const boost::shared_ptr<wxConfigBase>& config, const StatusCallback& cb = StatusCallback());
00155
00160 wxPropertyGrid* getPropertyGrid() { return grid_; }
00161
00165 void changePrefix(const std::string& old_prefix, const std::string& new_prefix);
00166
00167 void setPropertyGrid(wxPropertyGrid* grid);
00168
00169 void setDefaultUserData(void* data) { default_user_data_ = data; }
00170
00171 void refreshAll();
00172 void clear();
00173 void update();
00174
00175 protected:
00176 wxPropertyGrid* grid_;
00177
00178 typedef std::map< std::pair<std::string, std::string>, PropertyBasePtr > M_Property;
00179 M_Property properties_;
00180
00181 boost::mutex changed_mutex_;
00182 typedef std::set<PropertyBaseWPtr> S_PropertyBaseWPtr;
00183 S_PropertyBaseWPtr changed_properties_;
00184
00185 void* default_user_data_;
00186
00187 boost::shared_ptr<wxConfigBase> config_;
00188 };
00189
00190 }
00191
00192 #endif