28 void mcs::Event::init(
string atFile,
unsigned int atLine,
31 if (! flInitialized) {
32 memset(vmsg, 0,
sizeof(vmsg));
35 (*custom_init_vmsg)(vmsg);
54 string s1,
string s2,
string s3)
56 init(atFile, atLine, type, code);
57 sprintf(buf, vmsg[code], s1.c_str(), s2.c_str(), s3.c_str());
64 init(atFile, atLine, type, code);
65 sprintf(buf, vmsg[code], s1.c_str(), i1);
73 init(atFile, atLine, type, code);
74 sprintf(buf, vmsg[code], i1, s1.c_str());
81 init(atFile, atLine, type, code);
82 sprintf(buf, vmsg[code], i1, i2);
115 sprintf(buf,
"%d", latLine);
116 lerror = latFile +
":" + string(buf);
118 sprintf(buf,
" (%d) ", lcode);
139 sprintf(buf,
"#%03d", code());
140 return (buf + msg());
162 ret = string(vmsg[i]);
179 pthread_t mcs::Debug::thrs[MCS_DEBUG_NTHR];
180 bool mcs::Debug::thrmap[MCS_DEBUG_NTHR];
181 int mcs::Debug::dummy = mcs::Debug::init();
183 int mcs::Debug::init()
186 for (i=0; i<MCS_DEBUG_NTHR; i++) {
203 void mcs::Debug::setDebug(
string lclassName,
void* lpthis,
206 className = lclassName;
211 void mcs::Debug::setDebug()
215 bool mcs::Debug::getDebugFlag()
219 #define DEBUG_MAXLENGTH 80 220 string mcs::Debug::debug(
const char* file,
int line,
const char*
function)
224 for (i=0; i<MCS_DEBUG_NTHR; i++) {
225 if (thrmap[i] && thrs[i] == pthread_self()) {
232 for (i=0; i<MCS_DEBUG_NTHR; i++)
235 thrs[i] = pthread_self();
241 char buf[DEBUG_MAXLENGTH];
242 sprintf(buf,
"*** THR %02d, %p, %s:%04d %s:%s ", i, pThis, file, line,
243 className.c_str(),
function);
244 buf[DEBUG_MAXLENGTH - 1] = 0;
249 #endif //ENABLE_DEBUG
string where()
Returns the place where the error occurred formatted as FILE:LINE (CODE).
Hold informations about an event.
#define MCS_VMSG_SIZE
Size of the Event.vmsg static array.
string codemsg()
Return the code and the message, formatted as MCS_PRE CODE MESSAGE.
string msg()
Returns the message.
RetValue
Return value for MCS routines.
RetValue type()
Return the event type.
string file()
Source file name where the event occurred.
int subcode()
Return event subcode.
Main include file for all MCS based applications.
int code()
Returns the event code.
static string static_vmsg(unsigned int i)
Return the msg in the i-th position of the vmsg array.
static void(* custom_init_vmsg)(const char *vmsg[1000])
Pointer to a callback function to initialize custom messages in the vmsg static array.
unsigned int line()
Source line number where the event occurred.
static bool flInitialized
Flag to tell if the init() method has been already called.
static const char * vmsg[1000]
Static array of descriptive messages.
Event(string atFile, unsigned int atLine, RetValue type, int code, string s1="", string s2="", string s3="")
Constructor with three optional strings.
Namespace for MCS library.