libqi-api  2.8.7.4
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
applicationsession.hpp
Go to the documentation of this file.
1 #pragma once
2 /*
3  * Copyright (c) 2013 Aldebaran Robotics. All rights reserved.
4  * Use of this source code is governed by a BSD-style license that can be
5  * found in the COPYING file.
6  */
7 
8 #ifndef QI_MESSAGING_APPLICATIONSESSION_HPP_
9 #define QI_MESSAGING_APPLICATIONSESSION_HPP_
10 #include <boost/noncopyable.hpp>
11 #include <qi/application.hpp>
12 #include <qi/session.hpp>
13 
14 namespace qi
15 {
16 class ApplicationSessionPrivate;
17 
26 class QI_API ApplicationSession : public Application, private boost::noncopyable
27 {
28 public:
35  enum Option
36  {
37  Option_None = 0,
38  Option_NoAutoExit = 1,
39  };
40 
44  class QI_API Config
45  {
46  public:
47  // Regular:
48  Config();
49  ~Config();
50  KA_GENERATE_FRIEND_REGULAR_OPS_4(Config, _standalone, _opt, _sessionConfig, _name)
51 
52  // Config:
58  QI_API_DEPRECATED_MSG(Use 'setStandAlone' instead)
59  Config& setDefaultStandAlone(bool standAlone);
60 
61  QI_API_DEPRECATED_MSG(Use 'standAlone' instead)
62  bool defaultStandAlone() const;
63 
64  Config& setStandalone(bool standalone);
65 
66  bool standalone() const;
67 
68  Config& setOption(ApplicationSession::Option opt);
69  ApplicationSession::Option option() const;
70 
75  QI_API_DEPRECATED_MSG(Use 'setConnectUrl' instead)
76  Config& setDefaultUrl(const Url& connectUrl);
77  QI_API_DEPRECATED_MSG(Use 'connectUrl' instead)
78  const Url& defaultUrl() const;
79 
80  Config& setConnectUrl(Url connectUrl);
81 
82  const boost::optional<Url>& connectUrl() const;
83 
88  QI_API_DEPRECATED_MSG(Use 'setListenUrls' or 'addListenUrl' instead)
89  Config& setDefaultListenUrl(const Url& listenUrl);
90  QI_API_DEPRECATED_MSG(Use 'listenUrls' instead)
91  const Url& defaultListenUrl() const;
92 
93  Config& addListenUrl(Url listenUrl);
94 
96  Config& setListenUrls(std::vector<Url> listenUrls);
97 
98  const std::vector<Url>& listenUrls() const;
99 
100  Config& setSessionConfig(SessionConfig sessConfig);
101  const SessionConfig& sessionConfig() const;
102 
103  Config& setName(const std::string& name);
104  const std::string& name() const;
105 
106  private:
107  bool _standalone;
108  Option _opt;
109  SessionConfig _sessionConfig;
110  std::string _name;
111  };
112 
152  ApplicationSession(int& argc,
153  char**& argv,
154  int opt = 0,
155  const Url& defaultUrl = SessionConfig::defaultConnectUrl());
156  ApplicationSession(const std::string& name,
157  int& argc,
158  char**& argv,
159  int opt = 0,
160  const Url& defaultUrl = SessionConfig::defaultConnectUrl());
161  ApplicationSession(int& argc, char**& argv, const Config& defaultConfig);
162  virtual ~ApplicationSession();
163 
167  SessionPtr session() const;
168 
169  const Config& config() const;
170 
175  Url url() const;
176 
181  Url listenUrl() const;
182 
187  std::vector<Url> allListenUrl() const;
188 
194  QI_API_DEPRECATED_MSG(Use 'startSession' instead)
195  void start();
196 
201  void startSession();
202 
205  void run();
206 
210  bool standAlone();
211 
215  std::string helpText() const;
216 
217 private:
218  std::unique_ptr<ApplicationSessionPrivate> _p;
219 };
220 
222 }
223 
224 #endif // QIMESSAGING_APPLICATIONSESSION_HPP_
boost::shared_ptr< Session > SessionPtr
Definition: session.hpp:34
#define QI_API
Definition: api.hpp:33
static Url defaultConnectUrl()
These URLs are guaranteed to be valid.
Class handling startup and teardown of an application.
Definition: application.hpp:31
#define QI_API_DEPRECATED_MSG(msg__)
Compiler flags to mark a function as deprecated. It will generate a compiler warning.
Definition: macro.hpp:55
Definition: url.hpp:35