Main Page · Modules · All Classes · Class Hierarchy
MPContext.hpp
1 /*
2  * This file is part of the AiBO+ project
3  *
4  * Copyright (C) 2005-2016 Csaba Kertész (csaba.kertesz@gmail.com)
5  *
6  * AiBO+ is free software; you can redistribute it and/or modify
7  * it under the terms of the GNU General Public License as published by
8  * the Free Software Foundation; either version 2 of the License, or
9  * (at your option) any later version.
10  *
11  * AiBO+ is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14  * GNU General Public License for more details.
15  *
16  * You should have received a copy of the GNU General Public License
17  * along with this program; if not, write to the Free Software
18  * Foundation, Inc., 59 Temple Street #330, Boston, MA 02111-1307, USA.
19  *
20  */
21 
22 #pragma once
23 
24 #include <boost/scoped_ptr.hpp>
25 #include <boost/shared_ptr.hpp>
26 
27 #include <MSContext.hpp>
28 
29 class MPContext;
30 class MPSessionMemory;
31 
37 namespace MP
38 {
40 typedef boost::scoped_ptr<MPContext> Context;
41 
43 typedef boost::shared_ptr<MPSessionMemory> SessionMemorySPtr;
44 
46 typedef QMap<QString, SessionMemorySPtr> SessionMemorySPtrMap;
47 }
48 
52 class MPContext : public MSContext
53 {
54  Q_OBJECT
55  Q_DISABLE_COPY(MPContext)
56 
57 public:
58 
84  MPContext(int& argc, char **argv, bool graphical_context);
86  virtual ~MPContext();
87 
88  /*
89  -------------------------------------------------------------------
90  Context functions
91  -------------------------------------------------------------------
92  */
93 
101  static MPContext* GetInstance();
102 
111  bool IsConnectedToRobot();
112 
122  QStringList GetSessionDirectories(const QString& filter = "*") const;
123 
133  MP::SessionMemorySPtr GetSessionMemory(const QString& session_directory);
134 
140  void OptimizeSessionMemoryCache();
141 
142 public Q_SLOTS:
143 
149  void StartListening();
150 
156  void StopListening();
157 
165  void FinishSession();
166 
172  void ShutdownRobot();
173 
179  void RestartRobot();
180 
181 Q_SIGNALS:
182 
188  void RobotConnected();
189 
195  void RobotDisconnected();
196 
202  void RobotShutdown();
203 
209  void RobotShutdownFailed();
210 
211 private:
213  MP::SessionMemorySPtrMap SessionMemoryCache;
214 };
215 
Creates a context for an application.
Definition: MSContext.hpp:42
Context for libmindpiece applications.
Definition: MPContext.hpp:52
Session memory element.
Definition: MPContext.hpp:37
MP::SessionMemorySPtrMap SessionMemoryCache
Session memory cache.
Definition: MPContext.hpp:213