8 #ifndef BOOST_UI_APPLICATION_HPP
9 #define BOOST_UI_APPLICATION_HPP
13 #ifdef BOOST_HAS_PRAGMA_ONCE
17 #ifndef BOOST_NO_CXX11_HDR_CHRONO
21 #include <boost/function.hpp>
23 #ifdef BOOST_UI_USE_CHRONO
24 #include <boost/chrono.hpp>
27 #ifdef BOOST_UI_USE_DATE_TIME
28 #include <boost/date_time/time_duration.hpp>
31 #ifndef BOOST_NO_CXX11_VARIADIC_TEMPLATES
32 #include <boost/move/utility.hpp>
34 #include <boost/bind.hpp>
48 BOOST_UI_DECL
int entry(
int (*ui_main)(
int,
char*[]),
int argc,
char* argv[]);
49 BOOST_UI_DECL
int entry(
int (*ui_main)(),
int argc,
char* argv[]);
55 BOOST_UI_DECL
void on_timeout(
int milliseconds,
const boost::function<
void()>& fn);
57 #ifndef BOOST_NO_CXX11_HDR_CHRONO
58 template <
class Rep,
class Period>
59 void on_timeout(
const std::chrono::duration<Rep, Period>& d,
60 const boost::function<
void()>& fn)
62 on_timeout(
static_cast<int>(std::chrono::duration_cast<
63 std::chrono::milliseconds>(d).count()),
68 #ifdef BOOST_UI_USE_CHRONO
69 template <
class Rep,
class Period>
70 void on_timeout(
const boost::chrono::duration<Rep, Period>& d,
71 const boost::function<
void()>& fn)
73 on_timeout(
static_cast<int>(boost::chrono::duration_cast<
74 boost::chrono::milliseconds>(d).count()),
79 #ifdef BOOST_UI_USE_DATE_TIME
80 template <
class T,
typename rep_type>
81 void on_timeout(
const boost::date_time::time_duration<T, rep_type>& td,
82 const boost::function<
void()>& fn)
84 on_timeout(
static_cast<int>( td.total_milliseconds() ), fn);
102 #ifndef BOOST_NO_CXX11_HDR_CHRONO
103 #if !defined(BOOST_NO_CXX11_VARIADIC_TEMPLATES)
104 template <
class Rep,
class Period,
class F,
class ...Args>
106 F&& f, Args&&... args)
108 detail::on_timeout(d, std::bind(boost::forward<F>(f), boost::forward<Args>(args)...));
111 template <
class Rep,
class Period>
112 void on_timeout(
const std::chrono::duration<Rep, Period>& d,
113 const boost::function<
void()>& fn)
117 template <
class Rep,
class Period,
class F,
class Arg1>
118 void on_timeout(
const std::chrono::duration<Rep, Period>& d,
123 template <
class Rep,
class Period,
class F,
class Arg1,
class Arg2>
124 void on_timeout(
const std::chrono::duration<Rep, Period>& d,
125 F f, Arg1 a1, Arg2 a2)
132 #ifdef BOOST_UI_USE_CHRONO
133 #if !defined(BOOST_NO_CXX11_VARIADIC_TEMPLATES)
134 template <
class Rep,
class Period,
class F,
class ...Args>
135 void on_timeout(
const boost::chrono::duration<Rep, Period>& d,
136 F&& f, Args&&... args)
138 detail::on_timeout(d, std::bind(boost::forward<F>(f), boost::forward<Args>(args)...));
141 template <
class Rep,
class Period>
142 void on_timeout(
const boost::chrono::duration<Rep, Period>& d,
143 const boost::function<
void()>& fn)
147 template <
class Rep,
class Period,
class F,
class Arg1>
148 void on_timeout(
const boost::chrono::duration<Rep, Period>& d,
153 template <
class Rep,
class Period,
class F,
class Arg1,
class Arg2>
154 void on_timeout(
const boost::chrono::duration<Rep, Period>& d,
155 F f, Arg1 a1, Arg2 a2)
162 #ifdef BOOST_UI_USE_DATE_TIME
163 #if !defined(BOOST_NO_CXX11_VARIADIC_TEMPLATES)
164 template <
class T,
typename rep_type,
class F,
class ...Args>
165 void on_timeout(
const boost::date_time::time_duration<T, rep_type>& td,
166 F&& f, Args&&... args)
168 detail::on_timeout(td, std::bind(boost::forward<F>(f), boost::forward<Args>(args)...));
171 template <
class T,
typename rep_type>
172 void on_timeout(
const boost::date_time::time_duration<T, rep_type>& td,
173 const boost::function<
void()>& fn)
177 template <
class T,
typename rep_type,
class F,
class Arg1>
178 void on_timeout(
const boost::date_time::time_duration<T, rep_type>& td,
183 template <
class T,
typename rep_type,
class F,
class Arg1,
class Arg2>
184 void on_timeout(
const boost::date_time::time_duration<T, rep_type>& td,
185 F f, Arg1 a1, Arg2 a2)
197 BOOST_UI_DECL
void sleep_for_milliseconds(
unsigned long milliseconds);
198 BOOST_UI_DECL
void sleep_for_microseconds(
unsigned long microseconds);
206 #ifndef BOOST_NO_CXX11_HDR_CHRONO
207 template <
class Rep,
class Period>
208 void sleep_for(
const std::chrono::duration<Rep, Period>& d)
210 const unsigned long milliseconds =
static_cast<unsigned long>(
211 std::chrono::duration_cast<std::chrono::milliseconds>(d).count());
212 if ( milliseconds > 1000 )
213 detail::sleep_for_milliseconds(milliseconds);
215 detail::sleep_for_microseconds(
static_cast<unsigned long>(
216 std::chrono::duration_cast<std::chrono::microseconds>(d).count() ));
220 #ifdef BOOST_UI_USE_CHRONO
221 template <
class Rep,
class Period>
222 void sleep_for(
const boost::chrono::duration<Rep, Period>& d)
224 const unsigned long milliseconds =
static_cast<unsigned long>(
225 boost::chrono::duration_cast<boost::chrono::milliseconds>(d).count());
226 if ( milliseconds > 1000 )
227 detail::sleep_for_milliseconds(milliseconds);
229 detail::sleep_for_microseconds(
static_cast<unsigned long>(
230 boost::chrono::duration_cast<boost::chrono::microseconds>(d).count() ));
234 #ifdef BOOST_UI_USE_DATE_TIME
235 template <
class T,
typename rep_type>
236 void sleep_for(
const boost::date_time::time_duration<T, rep_type>& td)
238 const unsigned long milliseconds =
static_cast<unsigned long>(td.total_milliseconds());
239 if ( milliseconds > 1000 )
240 detail::sleep_for_milliseconds(milliseconds);
242 detail::sleep_for_microseconds(
static_cast<unsigned long>( td.total_microseconds() ));
252 BOOST_UI_DECL
void assertion_failed_msg(
char const* expr,
char const* msg,
253 char const*
function,
254 char const* file,
long line);
261 inline void assertion_failed_msg(
char const* expr,
char const* msg,
262 char const*
function,
263 char const* file,
long line)
265 ui::detail::assertion_failed_msg(expr, msg,
function, file, line);
268 inline void assertion_failed(
char const* expr,
269 char const*
function,
270 char const* file,
long line)
272 assertion_failed_msg(expr, NULL,
function, file, line);
278 #endif // BOOST_UI_APPLICATION_HPP