/usr/share/cruisecontrol-bin-2.6.1/projects/qpid-trunk/cpp/src/qpid/sys/apr/APRBase.h

00001 /*
00002  *
00003  * Licensed to the Apache Software Foundation (ASF) under one
00004  * or more contributor license agreements.  See the NOTICE file
00005  * distributed with this work for additional information
00006  * regarding copyright ownership.  The ASF licenses this file
00007  * to you under the Apache License, Version 2.0 (the
00008  * "License"); you may not use this file except in compliance
00009  * with the License.  You may obtain a copy of the License at
00010  * 
00011  *   http://www.apache.org/licenses/LICENSE-2.0
00012  * 
00013  * Unless required by applicable law or agreed to in writing,
00014  * software distributed under the License is distributed on an
00015  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
00016  * KIND, either express or implied.  See the License for the
00017  * specific language governing permissions and limitations
00018  * under the License.
00019  *
00020  */
00021 #ifndef _APRBase_
00022 #define _APRBase_
00023 
00024 #include <string>
00025 #include <apr_thread_mutex.h>
00026 #include <apr_errno.h>
00027 
00028 namespace qpid {
00029 namespace sys {
00030 
00038     class APRBase{
00039         static APRBase* instance;
00040         apr_pool_t* pool;
00041         apr_thread_mutex_t* mutex;
00042         int count;
00043 
00044         APRBase();
00045         ~APRBase();
00046         static APRBase* getInstance();
00047         bool _increment();
00048         void _decrement();
00049     public:
00050         static void increment();
00051         static void decrement();
00052     };
00053 
00054     //this is also a convenient place for a helper function for error checking:
00055     void check(apr_status_t status, const char* file, const int line);
00056     std::string get_desc(apr_status_t status);
00057 
00058 #define CHECK_APR_SUCCESS(A) qpid::sys::check(A, __FILE__, __LINE__); 
00059 
00060 }
00061 }
00062 
00063 // Inlined as it is called *a lot*
00064 void inline qpid::sys::check(apr_status_t status, const char* file, const int line){
00065     if (status != APR_SUCCESS){
00066         char tmp[256];
00067         throw Exception(QPID_MSG(apr_strerror(status, tmp, size)))
00068     }
00069 }
00070 
00071 
00072 
00073 
00074 #endif

Generated on Thu Apr 10 11:08:18 2008 for Qpid by  doxygen 1.4.7