property.h
Go to the documentation of this file.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 00035 template <typename T> 00036 class PropertyAdaptor 00037 { 00038 public: 00039 00040 PropertyAdaptor() : _data(0) 00041 {} 00042 00043 void bind(PropertyData &data) 00044 { 00045 _data = &data; 00046 } 00047 00048 T operator()(void) const 00049 { 00050 return _data->value.operator T(); 00051 } 00052 00053 PropertyAdaptor &operator = (const T &t) 00054 { 00055 _data->value.clear(); 00056 MessageIter wi = _data->value.writer(); 00057 wi << t; 00058 return *this; 00059 } 00060 00061 private: 00062 00063 PropertyData *_data; 00064 }; 00065 00066 struct IntrospectedInterface; 00067 00068 class DXXAPI PropertiesAdaptor : public InterfaceAdaptor 00069 { 00070 public: 00071 00072 PropertiesAdaptor(); 00073 00074 Message Get(const CallMessage &); 00075 00076 Message Set(const CallMessage &); 00077 00078 protected: 00079 00080 virtual void on_get_property(InterfaceAdaptor &/*interface*/, const std::string &/*property*/, Variant &/*value*/) 00081 {} 00082 00083 virtual void on_set_property(InterfaceAdaptor &/*interface*/, const std::string &/*property*/, const Variant &/*value*/) 00084 {} 00085 00086 IntrospectedInterface *introspect() const; 00087 }; 00088 00089 class DXXAPI PropertiesProxy : public InterfaceProxy 00090 { 00091 public: 00092 00093 PropertiesProxy(); 00094 00095 Variant Get(const std::string &interface, const std::string &property); 00096 00097 void Set(const std::string &interface, const std::string &property, const Variant &value); 00098 }; 00099 00100 } /* namespace DBus */ 00101 00102 #endif//__DBUSXX_PROPERTY_H 00103