~thomas-voss/location-service/robustify-event-propagation-in-case-of-multiple-providers-running

« back to all changes in this revision

Viewing changes to src/location_service/com/ubuntu/location/dispatching_provider.h

  • Committer: thomas-voss
  • Date: 2014-10-16 16:35:05 UTC
  • Revision ID: thomas.voss@canonical.com-20141016163505-4tnmxj0f7go9tom7
And some further fixes.

Show diffs side-by-side

added added

removed removed

Lines of Context:
46
46
    typedef std::function<void()> Task;
47
47
    typedef std::function<void(Task)> Dispatcher;
48
48
 
49
 
    DispatchingProvider(const Dispatcher& dispatcher, const Provider::Ptr& fwd);
 
49
    // Create a new instance wired up to the given Provider instance.
 
50
    static DispatchingProvider::Ptr create(const Dispatcher& dispatcher, const Provider::Ptr& fwd);
 
51
 
50
52
    ~DispatchingProvider() noexcept;
51
53
 
52
54
    bool supports(const location::Provider::Features& f) const override;
68
70
    void stop_velocity_updates() override;
69
71
 
70
72
private:
 
73
    // We want to pass ourselves around.
 
74
    DispatchingProvider(const Dispatcher& dispatcher, const Provider::Ptr& fwd);
 
75
 
 
76
    // Two stage initialization is evil, but we are somewhat forced to do it.
 
77
    DispatchingProvider::Ptr init();
 
78
 
71
79
    // The dispatcher we rely on to dispatch events/invocations.
72
80
    Dispatcher dispatcher;
73
81
    // The provider that we relay to/from.
74
82
    Provider::Ptr fwd;
75
83
    // We store all connections that should be cut on destruction.
76
 
    struct
77
 
    {
78
 
        core::ScopedConnection position_updates;
79
 
        core::ScopedConnection heading_updates;
80
 
        core::ScopedConnection velocity_updates;
81
 
    } connections;
 
84
    std::vector<core::ScopedConnection> connections;
82
85
};
83
86
}
84
87
}