MINT2
src
Mojito
Chi2Test
MessageService.cpp
Go to the documentation of this file.
1
#include "
Mint/MessageService.h
"
2
3
4
MessageSerivce
*
MessageSerivce::s_messageService
= 0;
5
8
MessageSerivce
&
MessageSerivce::getMessageService
(
ErrorType
errorType){
9
10
//if the singleton doesn't exist, return make it
11
if
(
s_messageService
== 0){
12
s_messageService
=
new
MessageSerivce
();
13
}
14
15
//See if we should be printing the error type given.
16
//Set the _printOrNot variable accordingly
17
s_messageService
->
_printOrNot
=
s_messageService
->
_outputOptions
[errorType];
18
19
20
21
//Set the error type to the one given
22
if
(
s_messageService
->
_printOrNot
){
23
24
//if the message type has changed, and no endl was called, then
25
//force a new line.
26
if
(
s_messageService
->
_errorType
!= errorType &&
s_messageService
->
_endlCalled
== 0){
27
*
s_messageService
<< std::endl;
28
}
29
30
s_messageService
->
_errorType
= errorType;
31
}
32
33
//return the singleton
34
return
*
s_messageService
;
35
36
}
37
40
MessageSerivce
&
MessageSerivce::getMessageService
(){
41
42
//if the singleton doesn't exist, return make it
43
if
(
s_messageService
== 0){
44
s_messageService
=
new
MessageSerivce
();
45
}
46
47
//return the singleton
48
return
*
s_messageService
;
49
50
}
51
52
55
MessageSerivce::MessageSerivce
() :
56
_stream(std::cout),
57
_endlCalled(true),
58
_errorCount(0)
59
{
60
61
_outputOptions
[
WELCOME
] =
false
;
62
_outputOptions
[
ERROR
] = true ;
63
_outputOptions
[
INFO
] = true ;
64
_outputOptions
[
VERBOSE
] =
false
;
65
_outputOptions
[
GOODBYE
] =
false
;
66
67
_outputHeaders
[
WELCOME
] =
"HyperPlot Welcome : "
;
68
_outputHeaders
[
ERROR
] =
"\033[31mHyperPlot Error : "
;
69
_outputHeaders
[
INFO
] =
"\033[32mHyperPlot Info : "
;
70
_outputHeaders
[
VERBOSE
] =
"HyperPlot Verbose : "
;
71
_outputHeaders
[
GOODBYE
] =
"HyperPlot Goodbye : "
;
72
73
}
74
77
void
MessageSerivce::printErrorCount
(){
78
79
//turns out that it never gets destructed so this doesn't work. Bit of a shame
80
if
(
_errorCount
!= 0){
81
_errorCount
--;
//This isn't actually an error, so -1
82
getMessageService
(
ERROR
) <<
"There were "
<<
_errorCount
<<
" errors during runtime"
<< std::endl;
83
}
84
}
85
88
MessageSerivce::~MessageSerivce
(){
89
90
//turns out that it never gets destructed so this doesn't work. Bit of a shame
91
if
(
_errorCount
!= 0){
92
_errorCount
--;
93
getMessageService
(
ERROR
) <<
"There was "
<<
_errorCount
<<
" errors during runtime"
<< std::endl;
94
}
95
96
}
97
98
MessageSerivce::WELCOME
Definition:
MessageService.h:45
MessageSerivce::_printOrNot
bool _printOrNot
Definition:
MessageService.h:66
MessageService.h
MessageSerivce::s_messageService
static MessageSerivce * s_messageService
static variable that holds the singleton object
Definition:
MessageService.h:38
MessageSerivce::getMessageService
static MessageSerivce & getMessageService()
Definition:
MessageService.cpp:40
MessageSerivce::ERROR
Definition:
MessageService.h:45
MessageSerivce::printErrorCount
void printErrorCount()
Definition:
MessageService.cpp:77
MessageSerivce::MessageSerivce
MessageSerivce()
Definition:
MessageService.cpp:55
MessageSerivce::_endlCalled
bool _endlCalled
Definition:
MessageService.h:61
MessageSerivce::_errorType
ErrorType _errorType
Definition:
MessageService.h:70
MessageSerivce::VERBOSE
Definition:
MessageService.h:45
MessageSerivce::GOODBYE
Definition:
MessageService.h:45
MessageSerivce::_outputHeaders
std::map< ErrorType, TString > _outputHeaders
Definition:
MessageService.h:57
MessageSerivce::_outputOptions
std::map< ErrorType, bool > _outputOptions
Definition:
MessageService.h:53
MessageSerivce
Definition:
MessageService.h:33
MessageSerivce::INFO
Definition:
MessageService.h:45
MessageSerivce::~MessageSerivce
~MessageSerivce()
Definition:
MessageService.cpp:88
MessageSerivce::ErrorType
ErrorType
Define the possible error types.
Definition:
MessageService.h:45
MessageSerivce::_errorCount
long int _errorCount
Definition:
MessageService.h:74
Generated by
1.8.15