00001 /* 00002 * 00003 * D-Bus++ - C++ bindings for D-Bus 00004 * 00005 * Copyright (C) 2005-2007 Paolo Durante <shackan@gmail.com> 00006 * 00007 * 00008 * This library is free software; you can redistribute it and/or 00009 * modify it under the terms of the GNU Lesser General Public 00010 * License as published by the Free Software Foundation; either 00011 * version 2.1 of the License, or (at your option) any later version. 00012 * 00013 * This library is distributed in the hope that it will be useful, 00014 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00015 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 00016 * Lesser General Public License for more details. 00017 * 00018 * You should have received a copy of the GNU Lesser General Public 00019 * License along with this library; if not, write to the Free Software 00020 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 00021 * 00022 */ 00023 00024 00025 #ifndef __DBUSXX_PROPERTY_H 00026 #define __DBUSXX_PROPERTY_H 00027 00028 #include "api.h" 00029 #include "types.h" 00030 #include "interface.h" 00031 00032 namespace DBus { 00033 00034 template <typename T> 00035 class PropertyAdaptor 00036 { 00037 public: 00038 00039 PropertyAdaptor() : _data(0) 00040 {} 00041 00042 void bind(PropertyData &data) 00043 { 00044 _data = &data; 00045 } 00046 00047 T operator() (void) const 00048 { 00049 return (T)_data->value; 00050 } 00051 00052 PropertyAdaptor &operator = (const T &t) 00053 { 00054 _data->value.clear(); 00055 MessageIter wi = _data->value.writer(); 00056 wi << t; 00057 return *this; 00058 } 00059 00060 private: 00061 00062 PropertyData *_data; 00063 }; 00064 00065 struct IntrospectedInterface; 00066 00067 class DXXAPI PropertiesAdaptor : public InterfaceAdaptor 00068 { 00069 public: 00070 00071 PropertiesAdaptor(); 00072 00073 Message Get(const CallMessage &); 00074 00075 Message Set(const CallMessage &); 00076 00077 protected: 00078 00079 virtual void on_get_property(InterfaceAdaptor &/*interface*/, const std::string &/*property*/, Variant &/*value*/) 00080 {} 00081 00082 virtual void on_set_property(InterfaceAdaptor &/*interface*/, const std::string &/*property*/, const Variant &/*value*/) 00083 {} 00084 00085 IntrospectedInterface *const introspect() const; 00086 }; 00087 00088 class DXXAPI PropertiesProxy : public InterfaceProxy 00089 { 00090 public: 00091 00092 PropertiesProxy(); 00093 00094 Variant Get(const std::string &interface, const std::string &property); 00095 00096 void Set(const std::string &interface, const std::string &property, const Variant &value); 00097 }; 00098 00099 } /* namespace DBus */ 00100 00101 #endif//__DBUSXX_PROPERTY_H 00102