QtGStreamer  0.10.2
 All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Pages
childproxy.h
1 /*
2  Copyright (C) 2010 George Kiagiadakis <kiagiadakis.george@gmail.com>
3 
4  This library is free software; you can redistribute it and/or modify
5  it under the terms of the GNU Lesser General Public License as published
6  by the Free Software Foundation; either version 2.1 of the License, or
7  (at your option) any later version.
8 
9  This program is distributed in the hope that it will be useful,
10  but WITHOUT ANY WARRANTY; without even the implied warranty of
11  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12  GNU Lesser General Public License for more details.
13 
14  You should have received a copy of the GNU Lesser General Public License
15  along with this program. If not, see <http://www.gnu.org/licenses/>.
16 */
17 #ifndef QGST_CHILDPROXY_H
18 #define QGST_CHILDPROXY_H
19 
20 #include "object.h"
21 
22 namespace QGst {
23 
27 class QTGSTREAMER_EXPORT ChildProxy : public QGlib::Interface
28 {
29  QGST_WRAPPER(ChildProxy)
30 public:
31  uint childrenCount() const;
32  ObjectPtr childByName(const char *name) const;
33  ObjectPtr childByIndex(uint index) const;
34 
35  bool findChildProperty(const char *name, ObjectPtr *object, QGlib::ParamSpecPtr *paramSpec) const;
36  QGlib::Value childProperty(const char *name) const;
37  template <typename T> void setChildProperty(const char *name, const T & value);
38 };
39 
40 template <typename T>
41 void ChildProxy::setChildProperty(const char *name, const T & value)
42 {
43  QGlib::ParamSpecPtr param;
44  ObjectPtr object;
45  if (findChildProperty(name, &object, &param)) {
46  QGlib::Value v;
47  v.init(param->valueType());
48  v.set<T>(value);
49  object->setProperty(param->name(), value);
50  }
51 }
52 
53 }
54 
55 QGST_REGISTER_TYPE(QGst::ChildProxy)
56 QGLIB_REGISTER_INTERFACE(QGst::ChildProxy)
57 
58 #endif // QGST_CHILDPROXY_H