Realistic 3D camera system
3D camera system components
basic_logger.hpp
Go to the documentation of this file.
1 //
2 // basic_logger.hpp
3 // ~~~~~~~~~~~~~~~~
4 //
5 // Copyright (c) 2003-2015 Christopher M. Kohlhoff (chris at kohlhoff dot com)
6 //
7 // Distributed under the Boost Software License, Version 1.0. (See accompanying
8 // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
9 //
10 
11 #ifndef SERVICES_BASIC_LOGGER_HPP
12 #define SERVICES_BASIC_LOGGER_HPP
13 
14 #include <asio.hpp>
15 #include <boost/noncopyable.hpp>
16 #include <string>
17 
18 namespace services {
19 
22 template <typename Service>
24  : private boost::noncopyable
25 {
26 public:
28  typedef Service service_type;
29 
31  typedef typename service_type::impl_type impl_type;
32 
34 
41  explicit basic_logger(asio::io_service& io_service,
42  const std::string& identifier)
43  : service_(asio::use_service<Service>(io_service)),
44  impl_(service_.null())
45  {
46  service_.create(impl_, identifier);
47  }
48 
51  {
52  service_.destroy(impl_);
53  }
54 
57  {
58  return service_.get_io_service();
59  }
60 
62  void use_file(const std::string& file)
63  {
64  service_.use_file(impl_, file);
65  }
66 
68  void log(const std::string& message)
69  {
70  service_.log(impl_, message);
71  }
72 
73 private:
75  service_type& service_;
76 
78  impl_type impl_;
79 };
80 
81 } // namespace services
82 
83 #endif // SERVICES_BASIC_LOGGER_HPP
Provides core I/O functionality.
Definition: io_service.hpp:184
Service service_type
The type of the service that will be used to provide timer operations.
~basic_logger()
Destructor.
Service & use_service(io_service &ios)
Definition: io_service.hpp:26
service_type::impl_type impl_type
The native implementation type of the timer.
void use_file(const std::string &file)
Set the output file for all logger instances.
asio::io_service & get_io_service()
Get the io_service associated with the object.
void log(const std::string &message)
Log a message.
basic_logger(asio::io_service &io_service, const std::string &identifier)
Constructor.