Mir
prompt_session_manager_impl.h
Go to the documentation of this file.
1 /*
2  * Copyright © 2014 Canonical Ltd.
3  *
4  * This program is free software: you can redistribute it and/or modify it
5  * under the terms of the GNU 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 General Public License for more details.
12  *
13  * You should have received a copy of the GNU General Public License
14  * along with this program. If not, see <http://www.gnu.org/licenses/>.
15  *
16  * Authored by: Alan Griffiths <alan@octopull.co.uk>
17  */
18 
19 #ifndef MIR_SCENE_PROMPT_SESSION_MANAGERIMPL_H_
20 #define MIR_SCENE_PROMPT_SESSION_MANAGERIMPL_H_
21 
23 #include "mir_toolkit/common.h"
24 
25 #include <mutex>
26 #include <memory>
27 
28 namespace mir
29 {
30 namespace scene
31 {
32 class Session;
33 class SessionContainer;
34 class PromptSession;
35 class PromptSessionContainer;
36 class PromptSessionCreationParameters;
37 class PromptSessionListener;
38 
40 {
41 public:
42  explicit PromptSessionManagerImpl(
43  std::shared_ptr<SessionContainer> const& app_container,
44  std::shared_ptr<PromptSessionListener> const& prompt_session_listener);
45 
46  std::shared_ptr<PromptSession> start_prompt_session_for(
47  std::shared_ptr<Session> const& session,
48  PromptSessionCreationParameters const& params) const override;
49 
51  std::shared_ptr<PromptSession> const& prompt_session) const override;
52 
54  std::shared_ptr<PromptSession> const& prompt_session) const override;
55 
57  std::shared_ptr<PromptSession> const& prompt_session) const override;
58 
60  std::shared_ptr<PromptSession> const& prompt_session,
61  std::shared_ptr<Session> const& prompt_provider) const override;
62 
63  void remove_session(
64  std::shared_ptr<Session> const& session) const override;
65 
66  std::shared_ptr<Session> application_for(
67  std::shared_ptr<PromptSession> const& prompt_session) const override;
68 
69  std::shared_ptr<Session> helper_for(
70  std::shared_ptr<PromptSession> const& prompt_session) const override;
71 
73  std::shared_ptr<PromptSession> const& prompt_session,
74  std::function<void(std::shared_ptr<Session> const& prompt_provider)> const& f) const override;
75 
76 private:
77  std::shared_ptr<PromptSessionContainer> const prompt_session_container;
78  std::shared_ptr<PromptSessionListener> const prompt_session_listener;
79  std::shared_ptr<SessionContainer> const app_container;
80 
81  std::mutex mutable prompt_sessions_mutex;
82 
83  void stop_prompt_session_locked(
84  std::lock_guard<std::mutex> const&,
85  std::shared_ptr<PromptSession> const& prompt_session) const;
86 };
87 }
88 }
89 
90 #endif // MIR_SCENE_PROMPT_SESSION_MANAGERIMPL_H_
All things Mir.
Definition: atomic_callback.h:25
PromptSessionManagerImpl(std::shared_ptr< SessionContainer > const &app_container, std::shared_ptr< PromptSessionListener > const &prompt_session_listener)
Definition: prompt_session_manager_impl.cpp:30
std::shared_ptr< Session > helper_for(std::shared_ptr< PromptSession > const &prompt_session) const override
Retrieve the helper session for a prompt session.
Definition: prompt_session_manager_impl.cpp:177
void stop_prompt_session(std::shared_ptr< PromptSession > const &prompt_session) const override
Stop a started prompt session.
Definition: prompt_session_manager_impl.cpp:97
std::shared_ptr< PromptSession > start_prompt_session_for(std::shared_ptr< Session > const &session, PromptSessionCreationParameters const &params) const override
Start a new prompt session.
Definition: prompt_session_manager_impl.cpp:120
void for_each_provider_in(std::shared_ptr< PromptSession > const &prompt_session, std::function< void(std::shared_ptr< Session > const &prompt_provider)> const &f) const override
Iterate over all the prompt providers associated with a prompt session.
Definition: prompt_session_manager_impl.cpp:191
void add_prompt_provider(std::shared_ptr< PromptSession > const &prompt_session, std::shared_ptr< Session > const &prompt_provider) const override
Add a prompt provider to an existing prompt session.
Definition: prompt_session_manager_impl.cpp:153
void resume_prompt_session(std::shared_ptr< PromptSession > const &prompt_session) const override
Resume a suspended prompt session.
Definition: prompt_session_manager_impl.cpp:112
void suspend_prompt_session(std::shared_ptr< PromptSession > const &prompt_session) const override
Suspend a prompt session.
Definition: prompt_session_manager_impl.cpp:104
Definition: prompt_session_manager.h:34
void remove_session(std::shared_ptr< Session > const &session) const override
Remove a session from all associated prompt sessions.
Definition: prompt_session_manager_impl.cpp:68
Definition: prompt_session_creation_parameters.h:29
std::shared_ptr< Session > application_for(std::shared_ptr< PromptSession > const &prompt_session) const override
Retrieve the application session for a prompt session.
Definition: prompt_session_manager_impl.cpp:163
Definition: prompt_session_manager_impl.h:39

Copyright © 2012-2015 Canonical Ltd.
Generated on Thu Oct 8 16:20:16 UTC 2015