00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021 #ifndef _APRBase_
00022 #define _APRBase_
00023
00024 #include <string>
00025 #include <apr_thread_mutex.h>
00026 #include <apr_errno.h>
00027 #include "qpid/QpidError.h"
00028
00029 namespace qpid {
00030 namespace sys {
00031
00039 class APRBase{
00040 static APRBase* instance;
00041 apr_pool_t* pool;
00042 apr_thread_mutex_t* mutex;
00043 int count;
00044
00045 APRBase();
00046 ~APRBase();
00047 static APRBase* getInstance();
00048 bool _increment();
00049 void _decrement();
00050 public:
00051 static void increment();
00052 static void decrement();
00053 };
00054
00055
00056 void check(apr_status_t status, const char* file, const int line);
00057 std::string get_desc(apr_status_t status);
00058
00059 #define CHECK_APR_SUCCESS(A) qpid::sys::check(A, __FILE__, __LINE__);
00060
00061 }
00062 }
00063
00064
00065 void inline qpid::sys::check(apr_status_t status, const char* file, const int line){
00066 if (status != APR_SUCCESS){
00067 const int size = 50;
00068 char tmp[size];
00069 std::string msg(apr_strerror(status, tmp, size));
00070 throw qpid::QpidError(APR_ERROR + ((int) status), msg,
00071 qpid::SrcLine(file, line));
00072 }
00073 }
00074
00075
00076
00077
00078 #endif