OpenWalnut
1.4.0
Main Page
Related Pages
Modules
Namespaces
Classes
Files
File List
src
core
scripting
wrappers
WLoggerWrapper.h
1
//---------------------------------------------------------------------------
2
//
3
// Project: OpenWalnut ( http://www.openwalnut.org )
4
//
5
// Copyright 2009 OpenWalnut Community, BSV@Uni-Leipzig and CNCF@MPI-CBS
6
// For more information see http://www.openwalnut.org/copying
7
//
8
// This file is part of OpenWalnut.
9
//
10
// OpenWalnut is free software: you can redistribute it and/or modify
11
// it under the terms of the GNU Lesser General Public License as published by
12
// the Free Software Foundation, either version 3 of the License, or
13
// (at your option) any later version.
14
//
15
// OpenWalnut is distributed in the hope that it will be useful,
16
// but WITHOUT ANY WARRANTY; without even the implied warranty of
17
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18
// GNU Lesser General Public License for more details.
19
//
20
// You should have received a copy of the GNU Lesser General Public License
21
// along with OpenWalnut. If not, see <http://www.gnu.org/licenses/>.
22
//
23
//---------------------------------------------------------------------------
24
25
#ifndef WLOGGERWRAPPER_H
26
#define WLOGGERWRAPPER_H
27
28
#include <string>
29
#include <vector>
30
31
#include <boost/shared_ptr.hpp>
32
#include <boost/tuple/tuple.hpp>
33
34
35
#include "core/common/WLogger.h"
36
#include "core/common/WLogStream.h"
37
38
/**
39
* \class WLoggerWrapper
40
*
41
* A wrapper for WLogger. This is used to expose a part of the WLogger functionality
42
* to script interpreters.
43
*/
44
class
WLoggerWrapper
45
{
46
/**
47
* A helper class for storing information about file streams that we added to
48
* the logger.
49
*/
50
struct
FileStreamEntry
51
{
52
//! The name of the log file.
53
std::string
m_filename
;
54
55
//! The actual stream.
56
boost::shared_ptr< std::ofstream >
m_fileStream
;
57
58
//! The logstream instance.
59
WLogStream::SharedPtr
m_WLogStream
;
60
};
61
62
public
:
63
/**
64
* Constructor. Creates an empty wrapper.
65
*/
66
WLoggerWrapper
();
67
68
/**
69
* Constructor.
70
*
71
* \param logger A pointer to a logger instance.
72
*/
73
explicit
WLoggerWrapper
(
WLogger
* logger );
74
75
/**
76
* Destructor.
77
*/
78
~WLoggerWrapper
();
79
80
/**
81
* Add a file to which the logger output will be written.
82
*
83
* \param filename The name of the file to write logging stuff into.
84
*
85
* \return true, if a stream to that file could be created and added successfully.
86
*/
87
bool
addFileStream
( std::string filename );
88
89
/**
90
* Remove a file to which the logger writes.
91
*
92
* \param filename The name of the file to remove.
93
*
94
* \return true, if a stream to that file existed and was removed successfully.
95
*/
96
bool
removeFileStream
( std::string filename );
97
98
/**
99
* Remove all files to which the logger writes (and which were added by this wrapper).
100
*/
101
void
removeAllFileStreams
();
102
103
private
:
104
/**
105
* Helper function that removes the file stream with the given index.
106
*
107
* \param i The index of the stream to remove.
108
*/
109
void
removeFileStreamNumber
(
size_t
i );
110
111
//! A pointer to the logger.
112
WLogger
*
m_logger
;
113
114
//! List of file streams.
115
std::vector< FileStreamEntry >
m_fileStreamList
;
116
};
117
118
#endif // WLOGGERWRAPPER_H
Generated by
1.8.4