MeVisLab Toolbox Reference
mlMessageCollector.h
Go to the documentation of this file.
1 // Copyright (c) Fraunhofer MEVIS, Germany. All rights reserved.
2 // **InsertLicense** code
3 //----------------------------------------------------------------------------------
5 
10 //----------------------------------------------------------------------------------
11 
12 #pragma once
13 
14 #include "MLDICOMCachedIOSystem.h"
15 #include <mlModuleIncludes.h>
16 
17 ML_START_NAMESPACE
18 
21 {
22 public:
25 
27  virtual ~MessageCollector();
28 
30  virtual bool operator==(const MessageCollector &otherObj);
31 
33  virtual bool hasInfo() const;
35  virtual void appendInfo(const std::string &stringToAppend);
37  virtual void appendInfo(std::stringstream &streamToAppend);
39  virtual void setInfos(const std::string &stringToSet);
41  virtual void setInfos(std::stringstream &streamToSet);
43  virtual const std::string &getInfos() const;
46  virtual void postInfos(const std::string &funcName);
47 
49  virtual bool hasIssue() const;
51  virtual void appendIssue(const std::string &stringToAppend);
53  virtual void appendIssue(std::stringstream &streamToAppend);
55  virtual void setIssues(const std::string &stringToSet);
57  virtual void setIssues(std::stringstream &streamToSet);
59  virtual const std::string &getIssues() const;
63  virtual void postIssues(const std::string &funcName,
64  const std::string &reason);
65 
67  virtual bool hasError() const;
69  virtual void appendError(const std::string &stringToAppend);
71  virtual void appendError(std::stringstream &streamToAppend);
73  virtual void setErrors(const std::string &stringToSet);
75  virtual void setErrors(std::stringstream &streamToSet);
77  virtual const std::string &getErrors() const;
81  virtual void postErrors(const std::string &funcName,
82  const std::string &reason);
83 
85  virtual bool hasMessages() const;
87  virtual std::string getAllMessages() const;
89  virtual void clearMessages();
93  virtual void postMessages(const std::string &funcName,
94  const std::string &reason);
95 
96 
99 
101  virtual void appendMessagesFrom(const MessageCollector &other);
102 
105  std::string getFiltered(const std::string &stringToFilter) const;
106 
109 
110 protected:
113  virtual bool _filterMatches(const std::string & /*message*/) const { return false; }
114 
116  std::string _infos;
117 
119  std::string _issues;
120 
122  std::string _errors;
123 
128 };
129 
130 ML_END_NAMESPACE
Project global and OS specific declarations.
#define MLDICOMCachedIO_EXPORT
If included by external modules, exported symbols are declared as import symbols.
Class to collect messages of different types.
virtual void appendIssue(std::stringstream &streamToAppend)
Append an issue stream; indirectly uses appendIssue(const std::string &) for appending....
virtual void setIssues(const std::string &stringToSet)
Sets the current issue string.
virtual std::string getAllMessages() const
Get the current message + issue + error string.
virtual bool hasIssue() const
Returns true if the issue member is not empty, otherwise false.
virtual void setIssues(std::stringstream &streamToSet)
Set an issue stream.
virtual void convertAllMessagesToErrors()
Append all messages to error messages and then clears them.
virtual bool operator==(const MessageCollector &otherObj)
Returns true on member equality, otherwise false.
virtual void setErrors(std::stringstream &streamToSet)
Set an error stream.
virtual void clearMessages()
Clears all messages to empty strings, the handle is not changed.
virtual void setInfos(std::stringstream &streamToSet)
Set an info stream.
virtual const std::string & getErrors() const
Get the current error string.
virtual void postIssues(const std::string &funcName, const std::string &reason)
If there are issues then they are posted with one call of ML_PRINT_WARNING.
MessageCollector(const MessageCollector &)=default
Forbid copy constructor and assignment operator for others since often derived instances are passed; ...
virtual void postErrors(const std::string &funcName, const std::string &reason)
If there are errors then they are posted with one call of ML_PRINT_ERROR.
virtual void appendInfo(std::stringstream &streamToAppend)
Append an info stream; indirectly uses appendInfo(const std::string &) for appending.
virtual bool hasInfo() const
Returns true if the info member is not empty, otherwise false.
virtual void setInfos(const std::string &stringToSet)
Sets the current info string.
std::string _errors
Collects error information.
MessageCollector()
Construction with empty messages.
virtual const std::string & getIssues() const
Get the current issue string.
virtual ~MessageCollector()
Virtual destructor.
virtual void appendMessagesFrom(const MessageCollector &other)
Append all corresponding messages from other.
virtual bool hasError() const
Returns true if error messaqe member is not empty, otherwise false.
virtual MessageCollector * createClone()
Create a duplicate from *this.
virtual void appendInfo(const std::string &stringToAppend)
Append an info string; can be overwritten for replacement of the appendInfo functionality.
virtual const std::string & getInfos() const
Get the current info string.
std::string _infos
Collects any information.
virtual bool hasMessages() const
Returns true if any message is not empty, otherwise false.
virtual void appendError(std::stringstream &streamToAppend)
Append an error stream; indirectly uses appendError(const std::string &) for appending....
virtual bool _filterMatches(const std::string &) const
A filter method just returning false in this class; derived classes may implement filters reacting wi...
std::string getFiltered(const std::string &stringToFilter) const
Returns an empty string if _filterMatches returns true, otherwise stringToFilter is returned; otherwi...
virtual void appendIssue(const std::string &stringToAppend)
Append an issue string; can be overwritten for replacement of the appendIssue functionality.
std::string _issues
Collects issue information.
virtual void postMessages(const std::string &funcName, const std::string &reason)
If there are any messages then post them with their appropriate post methods.
MessageCollector & operator=(const MessageCollector &)=default
virtual void setErrors(const std::string &stringToSet)
Sets the current error string.
virtual void postInfos(const std::string &funcName)
If there are infos then they are posted with one call of ML_PRINT_INFO.
virtual void appendError(const std::string &stringToAppend)
Append an error string; can be overwritten for replacement of the appendError functionality.