Fraxinus  17.12-rc1
An IGT application
cxReporter.h
Go to the documentation of this file.
1 /*=========================================================================
2 This file is part of CustusX, an Image Guided Therapy Application.
3 
4 Copyright (c) 2008-2014, SINTEF Department of Medical Technology
5 All rights reserved.
6 
7 Redistribution and use in source and binary forms, with or without
8 modification, are permitted provided that the following conditions are met:
9 
10 1. Redistributions of source code must retain the above copyright notice,
11  this list of conditions and the following disclaimer.
12 
13 2. Redistributions in binary form must reproduce the above copyright notice,
14  this list of conditions and the following disclaimer in the documentation
15  and/or other materials provided with the distribution.
16 
17 3. Neither the name of the copyright holder nor the names of its contributors
18  may be used to endorse or promote products derived from this software
19  without specific prior written permission.
20 
21 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
22 AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
23 IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
24 DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
25 FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
26 DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
27 SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
28 CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
29 OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
30 OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
31 =========================================================================*/
32 
33 #ifndef CXREPORTER_H_
34 #define CXREPORTER_H_
35 
36 #include "cxResourceExport.h"
37 
38 #include <QMetaType>
39 #include <QObject>
40 #include <QMutex>
41 #include <QDateTime>
42 #include <QFile>
43 #include "boost/shared_ptr.hpp"
44 #include "boost/weak_ptr.hpp"
45 #include "cxDefinitions.h"
46 #include "cxAudio.h"
47 #include <sstream>
48 #include "cxTypeConversions.h"
49 #include "cxLogger.h"
50 #include "cxLogMessage.h"
51 #include "cxLogFileWatcher.h"
52 
53 class QString;
54 class QDomNode;
55 class QDomDocument;
56 class QFile;
57 class QTextStream;
58 
65 namespace cx
66 {
67 typedef boost::shared_ptr<class Reporter> ReporterPtr;
68 
84 class cxResource_EXPORT Reporter : public Log
85 {
86  Q_OBJECT
87 
88 public:
89  virtual ~Reporter();
90 
91  static void initialize();
92  static void shutdown();
93 
94  static ReporterPtr getInstance();
95 
96  void setAudioSource(AudioPtr audioSource);
97 
98  //Text
99  void sendInfo(QString info);
100  void sendSuccess(QString success);
101  void sendWarning(QString warning);
102  void sendError(QString error);
103  void sendDebug(QString debug);
104  void sendVolatile(QString volatile_msg);
105  void sendRaw(QString raw);
106 
107  void sendMessage(QString text, MESSAGE_LEVEL messageLevel=mlDEBUG, int timeout=-1, bool mute=false);
108  void sendMessage(Message msg);
109 
110  //Audio
111  void playStartSound();
112  void playStopSound();
113  void playCancelSound();
114 
115  void playSuccessSound();
116  void playWarningSound();
117  void playErrorSound();
118 
119  void playScreenShotSound();
120  void playSampleSound();
121 
122 private slots:
123  virtual void onEmittedMessage(Message message);
124 
125 protected:
126  virtual LogThreadPtr createWorker();
127 
128 private:
129  bool hasAudioSource() const;
130  Reporter();
131  Reporter(const Reporter&);
132  Reporter& operator=(const Reporter&);
133 
134  void playSound(MESSAGE_LEVEL messageLevel);
135 
136  AudioPtr mAudioSource;
137 
138 // static Reporter *mTheInstance; // global variable
139  static boost::weak_ptr<Reporter> mWeakInstance; // global variable
140  static boost::shared_ptr<Reporter> mPersistentInstance; // global variable
141 };
142 
145 cxResource_EXPORT ReporterPtr reporter();
146 
147 
148 } //namespace cx
149 
155 #endif /* CXREPORTER_H_ */
ReporterPtr reporter()
Definition: cxReporter.cpp:59
boost::shared_ptr< class Reporter > ReporterPtr
Definition: cxReporter.h:67
mlDEBUG
Definition: cxDefinitions.h:83
Definition: cxLog.h:76
boost::shared_ptr< class LogThread > LogThreadPtr
Definition: cxLog.h:67
boost::shared_ptr< Audio > AudioPtr
Definition: cxAudio.h:68
Namespace for all CustusX production code.