Swarm-NG  1.1
logmanager.hpp
Go to the documentation of this file.
1 /*************************************************************************
2  * Copyright (C) 2011 by Saleh Dindar and the Swarm-NG Development Team *
3  * *
4  * This program is free software; you can redistribute it and/or modify *
5  * it under the terms of the GNU General Public License as published by *
6  * the Free Software Foundation; either version 3 of the License. *
7  * *
8  * This program is distributed in the hope that it will be useful, *
9  * but WITHOUT ANY WARRANTY; without even the implied warranty of *
10  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
11  * GNU General Public License for more details. *
12  * *
13  * You should have received a copy of the GNU General Public License *
14  * along with this program; if not, write to the *
15  * Free Software Foundation, Inc., *
16  * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
17  ************************************************************************/
18 
26 #pragma once
27 #include "../common.hpp"
28 #include "log.hpp"
29 #include "writer.h"
30 
31 
32 namespace swarm { namespace log {
33 
57 class manager {
59  gpulog::host_log hlog;
61  gpulog::device_log* pdlog;
63  Pwriter log_writer;
64 
67  static const int default_buffer_size = 50*1024*1024;
68  public:
69 
70  enum { memory = 0x01, if_full = 0x02 };
71 
78  void init(const config&, int host_buffer_size = default_buffer_size, int device_buffer_size = default_buffer_size);
79 
85  void flush(int flags = memory);
86 
88  void shutdown();
89 
90  gpulog::device_log* get_gpulog() { return pdlog; }
91  gpulog::host_log* get_hostlog() { return &hlog; }
92  Pwriter get_writer() { return log_writer; }
93 
96  static shared_ptr<manager>& default_log();
97 
98 };
99 
100 typedef shared_ptr<manager> Pmanager;
101 
102 }}