~jpakkane/dbus-cpp/depfix

« back to all changes in this revision

Viewing changes to include/dbus/org/freedesktop/dbus/interfaces/object_manager.h

  • Committer: Thomas Voß
  • Date: 2013-05-21 09:49:21 UTC
  • Revision ID: thomas.voss@canonical.com-20130521094921-iac4thmiozeshjj7
Initial commit.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
2
 * Copyright © 2012 Canonical Ltd.
 
3
 *
 
4
 * This program is free software: you can redistribute it and/or modify it
 
5
 * under the terms of the GNU Lesser General Public License version 3,
 
6
 * as published by the Free Software Foundation.
 
7
 *
 
8
 * This program is distributed in the hope that it will be useful,
 
9
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 
10
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 
11
 * GNU Lesser General Public License for more details.
 
12
 *
 
13
 * You should have received a copy of the GNU Lesser General Public License
 
14
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 
15
 *
 
16
 * Authored by: Thomas Voß <thomas.voss@canonical.com>
 
17
 */
 
18
#ifndef DBUS_ORG_FREEDESKTOP_DBUS_INTERFACES_OBJECT_MANAGER_H_
 
19
#define DBUS_ORG_FREEDESKTOP_DBUS_INTERFACES_OBJECT_MANAGER_H_
 
20
 
 
21
#include "org/freedesktop/dbus/service.h"
 
22
#include "org/freedesktop/dbus/types/any.h"
 
23
#include "org/freedesktop/dbus/types/object_path.h"
 
24
#include "org/freedesktop/dbus/types/variant.h"
 
25
 
 
26
#include <chrono>
 
27
#include <string>
 
28
 
 
29
namespace org
 
30
{
 
31
namespace freedesktop
 
32
{
 
33
namespace dbus
 
34
{
 
35
namespace interfaces
 
36
{
 
37
class ObjectManager
 
38
{
 
39
public:
 
40
    virtual ~ObjectManager() = default;
 
41
 
 
42
    std::map<types::ObjectPath, std::map<std::string,std::map<std::string,types::Variant<types::Any>>>> get_managed_objects()
 
43
    {
 
44
        return service->root_object()->invoke_method_synchronously<
 
45
               GetManagedObjects, std::map<types::ObjectPath, std::map<std::string,std::map<std::string,types::Variant<types::Any>>>>
 
46
               >();
 
47
    }
 
48
 
 
49
protected:
 
50
    ObjectManager(const Service::Ptr& service) : service(service)
 
51
    {
 
52
    }
 
53
private:
 
54
    struct GetManagedObjects
 
55
    {
 
56
        typedef ObjectManager Interface;
 
57
        static std::string name()
 
58
        {
 
59
            return "GetManagedObjects";
 
60
        }
 
61
        static const bool call_synchronously = true;
 
62
        static const std::chrono::milliseconds default_timeout;
 
63
    };
 
64
    Service::Ptr service;
 
65
};
 
66
const std::chrono::milliseconds ObjectManager::GetManagedObjects::default_timeout
 
67
{
 
68
    10*1000
 
69
};
 
70
}
 
71
template<>
 
72
struct ServiceTraits<interfaces::ObjectManager>
 
73
{
 
74
    static const std::string& interface_name()
 
75
    {
 
76
        static const std::string s
 
77
        {"org.freedesktop.DBus.ObjectManager"
 
78
        };
 
79
        return s;
 
80
    }
 
81
};
 
82
}
 
83
}
 
84
}
 
85
 
 
86
 
 
87
#endif // DBUS_ORG_FREEDESKTOP_DBUS_INTERFACES_INTROSPECTABLE_H_