Index  Source Files  Annotated Class List  Alphabetical Class List  Class Hierarchy  Graphical Class Hierarchy   
 

FIX::CallStack Class Reference

Keeps track of callstacks for multiple threads. More...

#include <CallStack.h>

Collaboration diagram for FIX::CallStack:

Collaboration graph
[legend]
List of all members.

Public Member Functions

 CallStack (const std::string &name, const std::string &file, int line)
 ~CallStack ()

Static Public Member Functions

void output ()
void ignore (bool)
void caught (std::exception &e)
void caught ()
void terminate ()

Static Private Member Functions

ContextgetContext ()
ContextgetErrorContext ()

Static Private Attributes

std::map< unsigned, Contexts_stack
std::map< unsigned, Contexts_error
Mutex s_mutex

Detailed Description

Keeps track of callstacks for multiple threads.

Definition at line 39 of file CallStack.h.


Constructor & Destructor Documentation

FIX::CallStack::CallStack const std::string &  name,
const std::string &  file,
int  line
 

Definition at line 37 of file CallStack.cpp.

References getContext(), getErrorContext(), FIX::CallStack::Context::ignore, s_mutex, and terminate().

00038   {
00039     Locker locker(s_mutex);
00040 
00041     #if TERMINATE_IN_STD
00042       std::set_terminate(FIX::CallStack::terminate);
00043     #else
00044       set_terminate(FIX::CallStack::terminate);
00045     #endif
00046 
00047     Context& c = getContext();
00048     if( !c.ignore )
00049     {
00050       c.push(Method(name, file, line));
00051       getErrorContext() = c;
00052     }
00053   }

FIX::CallStack::~CallStack  ) 
 

Definition at line 55 of file CallStack.cpp.

References getContext(), FIX::CallStack::Context::ignore, and s_mutex.

00056   {
00057     Locker locker(s_mutex);
00058     Context& c = getContext();
00059     if( !c.ignore )
00060       c.pop();
00061   }


Member Function Documentation

void FIX::CallStack::caught  )  [static]
 

Definition at line 94 of file CallStack.cpp.

References FIX::CallStack::Context::caught(), getErrorContext(), FIX::CallStack::Context::ignore, and s_mutex.

00095   {
00096     Locker locker(s_mutex);
00097     Context& c = getErrorContext();
00098     if( c.ignore ) return;
00099     c.caught();
00100   }

void FIX::CallStack::caught std::exception &  e  )  [static]
 

Definition at line 86 of file CallStack.cpp.

References FIX::CallStack::Context::caught(), getErrorContext(), FIX::CallStack::Context::ignore, and s_mutex.

00087   {
00088     Locker locker(s_mutex);
00089     Context& c = getErrorContext();
00090     if( c.ignore ) return;
00091     c.caught(e);
00092   }

CallStack::Context & FIX::CallStack::getContext  )  [static, private]
 

Definition at line 102 of file CallStack.cpp.

References s_mutex, s_stack, and FIX::thread_self().

Referenced by CallStack(), ignore(), and ~CallStack().

00103   {
00104     Locker locker(s_mutex);
00105     return s_stack[thread_self()];
00106   }

CallStack::Context & FIX::CallStack::getErrorContext  )  [static, private]
 

Definition at line 108 of file CallStack.cpp.

References s_error, s_mutex, and FIX::thread_self().

Referenced by CallStack(), and caught().

00109   {
00110     Locker locker(s_mutex);
00111     return s_error[thread_self()];
00112   }

void FIX::CallStack::ignore bool   )  [static]
 

Definition at line 80 of file CallStack.cpp.

References getContext(), FIX::CallStack::Context::ignore, and s_mutex.

00081   {
00082     Locker locker(s_mutex);
00083     getContext().ignore = value;
00084   }

void FIX::CallStack::output  )  [static]
 

Definition at line 63 of file CallStack.cpp.

References FIX::CallStack::Context::exception, s_error, and s_mutex.

00064   {
00065     Locker locker(s_mutex);
00066     std::map<unsigned, CallStack::Context>::iterator i;
00067     for( i = s_error.begin(); i != s_error.end(); ++i )
00068     {
00069       Context& c = i->second;
00070       if(c.size())
00071         std::cerr << "thread(" << i->first << "):" << c.exception << std::endl;
00072       while(c.size())
00073       {
00074         std::cerr << "  at " << c.top() << std::endl;
00075         c.pop();
00076       }
00077     }
00078   }

void FIX::CallStack::terminate  )  [static]
 

Definition at line 114 of file CallStack.cpp.

References s_mutex.

Referenced by CallStack().

00115   {
00116     Locker locker(s_mutex);
00117     CallStack::output();
00118     abort();
00119   }


Member Data Documentation

std::map< unsigned, CallStack::Context > FIX::CallStack::s_error [static, private]
 

Definition at line 33 of file CallStack.cpp.

Referenced by getErrorContext(), and output().

Mutex FIX::CallStack::s_mutex [static, private]
 

Definition at line 34 of file CallStack.cpp.

Referenced by CallStack(), caught(), getContext(), getErrorContext(), ignore(), output(), terminate(), and ~CallStack().

std::map< unsigned, CallStack::Context > FIX::CallStack::s_stack [static, private]
 

Definition at line 32 of file CallStack.cpp.

Referenced by getContext().


The documentation for this class was generated from the following files:
Generated on Mon Jul 24 19:36:36 2006 for QuickFIX by doxygen 1.3.6-20040222 written by Dimitri van Heesch, © 1997-2001