Message.h
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2012 SCHUNK GmbH & Co. KG
3  * Copyright (c) 2017 Fraunhofer Institute for Manufacturing Engineering and Automation (IPA)
4  *
5  * Licensed under the Apache License, Version 2.0 (the "License");
6  * you may not use this file except in compliance with the License.
7  * You may obtain a copy of the License at
8  *
9  * http://www.apache.org/licenses/LICENSE-2.0
10 
11  * Unless required by applicable law or agreed to in writing, software
12  * distributed under the License is distributed on an "AS IS" BASIS,
13  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14  * See the License for the specific language governing permissions and
15  * limitations under the License.
16  */
17 
18 #ifndef UTIL_MESSAGE
19 #define UTIL_MESSAGE
20 
21 // ---- local includes ------------------------------------------------------ ;
22 
23 #include "../Util/GlobalDefines.h"
24 #include "../Util/InlineFunctions.h"
25 
26 // ---- global includes ----------------------------------------------------- ;
27 
28 #include <stdio.h>
29 #include <stdlib.h>
30 #include <stdarg.h>
31 #include <string.h>
32 
33 // ---- globals ----------------------------------------------------------- ;
34 extern int g_iDebugLevel;
35 
36 extern bool g_bDebugFile;
37 
38 extern bool g_bDebug;
39 
40 extern const char* g_pcDebugFileName;
41 
42 // ---- typedefs ------------------------------------------------------------ ;
43 
44 // ---- class definition ---------------------------------------------------- ;
45 
46 class CMessage
47 {
48 
49 private:
50 
51  // ---- private data ---------------------------------------------------- ;
52 
53  static CRITICAL_SECTION *m_csMessage;
54 
55 protected:
56 
57  // ---- protected data -------------------------------------------------- ;
58 
59  char m_acClassName[50];
60  bool m_bDebug;
63  static double m_fInitTime;
64 public:
65 
66  // ---- public data ------------------------------------------------------- ;
67 
68  // ---- constructors / destructor ----------------------------------------- ;
69 
70  // default constructor
71  CMessage(void);
72  CMessage(const char* pcClassName, int iDebugLevel = 0, bool bDebug = true, bool bDebugFile = false);
73  // copy constructor
74  CMessage(const CMessage& clMessage);
75  // destructor
76  virtual ~CMessage(void);
77 
78  // ---- operators --------------------------------------------------------- ;
79 
80  // assignment operator
81  CMessage& operator=(const CMessage& clMessage);
82 
83  // ---- query functions --------------------------------------------------- ;
84 
85  int getDebugLevel() const;
86 
87  // ---- modify functions -------------------------------------------------- ;
88 
89  int initMessage(const char* pcClassName, int iDebuglevel = 0, bool bDebug = true, bool bDebugFile = false);
90 
91  void setInitTime(void);
92  void setDebug(bool bFlag);
93  void setDebugFile(bool bFlag);
94  void setDebugLevel(int iLevel);
95 
96  static void setCriticalSection(CRITICAL_SECTION *cs);
97 
98  // ---- I/O functions ----------------------------------------------------- ;
99 
100  // ---- exec functions ---------------------------------------------------- ;
101  void logging(const char *pcLoggingMessage,...);
102 
103  // output of a debug message with a debug level
104  void debug(const int iDebugLevel,
105  const char *pcDebugMessage,...) const;
106 
107  // output of a warning message
108  void warning(const char *pcWarningMessage,...) const;
109 
110  // output of an error message
111  void error(const int iErrorCode,
112  const char *pcErrorMessage,...) const;
113  void error(const char *pcErrorMessage,...) const;
114 };
115 
116 #endif
void setDebug(bool bFlag)
Definition: Message.cpp:124
static void setCriticalSection(CRITICAL_SECTION *cs)
Definition: Message.cpp:134
bool g_bDebugFile
Definition: Message.cpp:21
int initMessage(const char *pcClassName, int iDebuglevel=0, bool bDebug=true, bool bDebugFile=false)
Definition: Message.cpp:90
void setInitTime(void)
Definition: Message.cpp:99
void error(const int iErrorCode, const char *pcErrorMessage,...) const
Definition: Message.cpp:204
bool m_bDebugFile
Definition: Message.h:61
int getDebugLevel() const
Definition: Message.cpp:79
int g_iDebugLevel
Definition: Message.cpp:20
bool g_bDebug
Definition: Message.cpp:22
void warning(const char *pcWarningMessage,...) const
Definition: Message.cpp:257
void setDebugLevel(int iLevel)
Definition: Message.cpp:119
void setDebugFile(bool bFlag)
Definition: Message.cpp:129
static CRITICAL_SECTION * m_csMessage
Definition: Message.h:53
static double m_fInitTime
Definition: Message.h:63
void debug(const int iDebugLevel, const char *pcDebugMessage,...) const
Definition: Message.cpp:332
CMessage(void)
Definition: Message.cpp:39
virtual ~CMessage(void)
Definition: Message.cpp:54
int m_iDebugLevel
Definition: Message.h:62
void logging(const char *pcLoggingMessage,...)
Definition: Message.cpp:313
CMessage & operator=(const CMessage &clMessage)
Definition: Message.cpp:64
bool m_bDebug
Definition: Message.h:60
const char * g_pcDebugFileName
Definition: Message.cpp:23
char m_acClassName[50]
Definition: Message.h:59


schunk_libm5api
Author(s): Florian Weisshardt
autogenerated on Mon Nov 25 2019 03:48:19