MINT2
MessageService.cpp
Go to the documentation of this file.
1 #include "Mint/MessageService.h"
2 
3 
5 
9 
10  //if the singleton doesn't exist, return make it
11  if (s_messageService == 0){
13  }
14 
15  //See if we should be printing the error type given.
16  //Set the _printOrNot variable accordingly
18 
19 
20 
21  //Set the error type to the one given
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 
41 
42  //if the singleton doesn't exist, return make it
43  if (s_messageService == 0){
45  }
46 
47  //return the singleton
48  return *s_messageService;
49 
50 }
51 
52 
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 
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 
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 
static MessageSerivce * s_messageService
static variable that holds the singleton object
static MessageSerivce & getMessageService()
ErrorType _errorType
std::map< ErrorType, TString > _outputHeaders
std::map< ErrorType, bool > _outputOptions
ErrorType
Define the possible error types.
long int _errorCount