property.h
Go to the documentation of this file.
1 /*
2  *
3  * D-Bus++ - C++ bindings for D-Bus
4  *
5  * Copyright (C) 2005-2007 Paolo Durante <shackan@gmail.com>
6  *
7  *
8  * This library is free software; you can redistribute it and/or
9  * modify it under the terms of the GNU Lesser General Public
10  * License as published by the Free Software Foundation; either
11  * version 2.1 of the License, or (at your option) any later version.
12  *
13  * This library is distributed in the hope that it will be useful,
14  * but WITHOUT ANY WARRANTY; without even the implied warranty of
15  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16  * Lesser General Public License for more details.
17  *
18  * You should have received a copy of the GNU Lesser General Public
19  * License along with this library; if not, write to the Free Software
20  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
21  *
22  */
23 
24 
25 #ifndef __DBUSXX_PROPERTY_H
26 #define __DBUSXX_PROPERTY_H
27 
28 #include "api.h"
29 #include "types.h"
30 #include "interface.h"
31 
32 namespace DBus
33 {
34 
35 template <typename T>
37 {
38 public:
39 
41  {}
42 
43  void bind(PropertyData &data)
44  {
45  _data = &data;
46  }
47 
48  T operator()(void) const
49  {
50  return _data->value.operator T();
51  }
52 
54  {
55  _data->value.clear();
56  MessageIter wi = _data->value.writer();
57  wi << t;
58  return *this;
59  }
60 
61 private:
62 
64 };
65 
67 
69 {
70 public:
71 
73 
74  Message Get(const CallMessage &);
75 
76  Message Set(const CallMessage &);
77 
78 protected:
79 
80  virtual void on_get_property(InterfaceAdaptor &/*interface*/, const std::string &/*property*/, Variant &/*value*/)
81  {}
82 
83  virtual void on_set_property(InterfaceAdaptor &/*interface*/, const std::string &/*property*/, const Variant &/*value*/)
84  {}
85 
86  IntrospectedInterface *introspect() const;
87 };
88 
90 {
91 public:
92 
94 
95  Variant Get(const std::string &interface, const std::string &property);
96 
97  void Set(const std::string &interface, const std::string &property, const Variant &value);
98 };
99 
100 } /* namespace DBus */
101 
102 #endif//__DBUSXX_PROPERTY_H
103 
virtual void on_get_property(InterfaceAdaptor &, const std::string &, Variant &)
Definition: property.h:80
void clear()
Definition: types.cpp:61
virtual void on_set_property(InterfaceAdaptor &, const std::string &, const Variant &)
Definition: property.h:83
T operator()(void) const
Definition: property.h:48
#define DXXAPI
Definition: api.h:36
MessageIter writer()
Definition: types.h:86
PropertyData * _data
Definition: property.h:63
void bind(PropertyData &data)
Definition: property.h:43
PropertyAdaptor & operator=(const T &t)
Definition: property.h:53