libqi-api  release-2.5.3-2016-11-18
 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  Config();
48  ~Config();
49 
55  Config& setDefaultStandAlone(bool standAlone);
56  bool defaultStandAlone() const;
57 
58  Config& setOption(ApplicationSession::Option opt);
59  ApplicationSession::Option option() const;
60 
65  Config& setDefaultUrl(const Url& url);
66  const Url& defaultUrl() const;
67 
72  Config& setDefaultListenUrl(const Url& listenUrl);
73  const Url& defaultListenUrl() const;
74 
75  Config& setName(const std::string& name);
76  const std::string& name() const;
77 
78  private:
79  qi::uint32_t _stateMachine;
80  Option _opt;
81  Url _url;
82  Url _listenUrl;
83  std::string _name;
84  };
85 
98  ApplicationSession(int& argc, char**& argv, int opt = 0, const Url& url = "tcp://127.0.0.1:9559");
99  ApplicationSession(const std::string& name,
100  int& argc,
101  char**& argv,
102  int opt = 0,
103  const Url& url = "tcp://127.0.0.1:9559");
104  ApplicationSession(int& argc, char**& argv, const Config& defaultConfig);
105  virtual ~ApplicationSession();
106 
110  SessionPtr session();
111 
117  Url url();
118 
124  Url listenUrl();
125 
131  QI_API_DEPRECATED_MSG(Use 'startSession' instead)
132  void start();
133 
138  void startSession();
139 
142  void run();
143 
144 private:
145  ApplicationSessionPrivate* _p;
146 };
147 
149 }
150 
151 #endif // QIMESSAGING_APPLICATIONSESSION_HPP_
boost::shared_ptr< Session > SessionPtr
Definition: session.hpp:158
#define QI_API
Definition: api.hpp:33
uint32_t uint32_t
Definition: types.hpp:65
Class handling startup and teardown of an application.
Definition: application.hpp:30
#define QI_API_DEPRECATED_MSG(msg__)
Compiler flags to mark a function as deprecated. It will generate a compiler warning.
Definition: macro.hpp:53
Definition: url.hpp:35