MeVisLab Toolbox Reference
mlNotify.h
Go to the documentation of this file.
1/*************************************************************************************
2**
3** Copyright 2007, MeVis Medical Solutions AG
4**
5** The user may use this file in accordance with the license agreement provided with
6** the Software or, alternatively, in accordance with the terms contained in a
7** written agreement between the user and MeVis Medical Solutions AG.
8**
9** For further information use the contact form at https://www.mevislab.de/contact
10**
11**************************************************************************************/
12
13#ifndef ML_NOTIFY_H
14#define ML_NOTIFY_H
15
17
31#include "mlUtilsSystem.h"
32
33#include <iostream>
34#include <vector>
35
37
38
39 //---------------------------------------------------------------------------------------------
41 //---------------------------------------------------------------------------------------------
43
44 public:
45 //---------------------------------------------------------------------------------------------
48 //---------------------------------------------------------------------------------------------
49
52
55
58
61
63 void reset();
64
66 void setEnabled(bool flag);
67
69 bool isEnabled() const;
70
72 void addNotifyCB(void* userData, MLNotifyCB* callback);
73
76 void removeNotifyCB(void* userData, MLNotifyCB* callback);
77
81
83 size_t getNumNotifyCBs() const;
84
86 const std::vector<void*>& getUserDataList() const;
87
89 const std::vector<MLNotifyCB*>& getCallbackList() const;
90
94 void* objData1=nullptr,
95 void* objData2=nullptr);
96
98
99 protected:
100
101 //---------------------------------------------------------------------------------------------
104 //---------------------------------------------------------------------------------------------
105
107 std::vector<void*> _notifyCBUserDataList;
108
110 std::vector<MLNotifyCB*> _notifyCBList;
111
114
116 };
117
118
119 //---------------------------------------------------------------------------------------------
121 //---------------------------------------------------------------------------------------------
123
125
126//-----------------------------------------------------------------------------------
127// Stream output for std::ostream
128//-----------------------------------------------------------------------------------
129namespace std {
130
132 ML_UTILS_EXPORT ostream& operator<<(ostream& s, const ML_UTILS_NAMESPACE::Notify &notify);
133
134}
135
136#endif // End of __mlNotify_H
Class to handle all ML Notify prints, errors and warnings.
Definition mlNotify.h:42
void notify(MLuint32 objType, void *objData1=nullptr, void *objData2=nullptr)
Calls all registered functions and pass object type code in objType.
const std::vector< MLNotifyCB * > & getCallbackList() const
Returns const access to callback function pointers.
void addNotifyCB(void *userData, MLNotifyCB *callback)
Registers a function callback callback that is called if any error, warning, Notify or cout/cerr prin...
void setEnabled(bool flag)
Enables/disables whether notifications are to be sent; default is true;.
size_t getNumNotifyCBs() const
Returns the number of registered callbacks.
const std::vector< void * > & getUserDataList() const
Returns const access to user data pointers.
void reset()
Resets instance to construction state.
std::vector< void * > _notifyCBUserDataList
User data for registered notify callbacks.
Definition mlNotify.h:107
void removeNotifyCB(void *userData, MLNotifyCB *callback)
Unregisters a given callback function with its user data.
~Notify()
Destructor. Destroys the Notify object after removing all registered callbacks.
bool _enabled
Flag if notify sends notifications; enabled by default.
Definition mlNotify.h:113
Notify()
Constructor. Creates a Notify object without registered callbacks.
std::vector< MLNotifyCB * > _notifyCBList
List of function pointers for error printing.
Definition mlNotify.h:110
bool isEnabled() const
Returns true if notifications are enabled.
void removeAllNotifyCBs()
Removes all registered callback functions.
Notify(const Notify &notifyObj)
Copy constructor.
Notify & operator=(const Notify &notifyObj)
Assignment operator.
Target mlrange_cast(Source arg)
Generic version of checked ML casts.
unsigned int MLuint32
Definition mlTypeDefs.h:185
void MLNotifyCB(MLuint32 objType, void *usrData, void *objectData1, void *objData2)
Function type which is registered by the Notify object; it receives a code objType of type MLNotifyCh...
#define ML_UTILS_EXPORT
Defines platform dependent DLL export macro for mlUtils.
Definition mlUtilities.h:20
ML_UTILS_EXPORT Notify MLNotify
Singleton which contains all registered callback functions of the ML.
STL namespace.
MLEXPORT std::ostream & operator<<(std::ostream &s, const ml::Field &v)
Overloads the operator "<<" for stream output of Field objects.