OW_FuncNamePrinter.hpp

Go to the documentation of this file.
00001 /*******************************************************************************
00002 * Copyright (C) 2001-2004 Vintela, Inc. All rights reserved.
00003 *
00004 * Redistribution and use in source and binary forms, with or without
00005 * modification, are permitted provided that the following conditions are met:
00006 *
00007 *  - Redistributions of source code must retain the above copyright notice,
00008 *    this list of conditions and the following disclaimer.
00009 *
00010 *  - Redistributions in binary form must reproduce the above copyright notice,
00011 *    this list of conditions and the following disclaimer in the documentation
00012 *    and/or other materials provided with the distribution.
00013 *
00014 *  - Neither the name of Vintela, Inc. nor the names of its
00015 *    contributors may be used to endorse or promote products derived from this
00016 *    software without specific prior written permission.
00017 *
00018 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS ``AS IS''
00019 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
00020 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
00021 * ARE DISCLAIMED. IN NO EVENT SHALL Vintela, Inc. OR THE CONTRIBUTORS
00022 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
00023 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
00024 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
00025 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
00026 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
00027 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
00028 * POSSIBILITY OF SUCH DAMAGE.
00029 *******************************************************************************/
00030 
00036 #ifndef OW_FUNC_NAME_PRINTER_HPP
00037 #define OW_FUNC_NAME_PRINTER_HPP
00038 #include "OW_config.h"
00039 #include "OW_Format.hpp"
00040 #include <stdio.h>
00041 #include <unistd.h>
00042 
00043 // The classes and functions defined in this file are not meant for general
00044 // use, they are internal implementation details.  They may change at any time.
00045 
00046 // For printing function names during debug
00047 #ifdef OW_PRINT_FUNC_DEBUG
00048 #define PRINT_FUNC_NAME OW_FuncNamePrinter fnp##__LINE__ (__PRETTY_FUNCTION__)
00049 
00050 #define PRINT_FUNC_NAME_ARGS1(a) OW_FuncNamePrinter fnp##__LINE__ ( __PRETTY_FUNCTION__ , a)
00051 #define PRINT_FUNC_NAME_ARGS2(a, b) OW_FuncNamePrinter fnp##__LINE__ ( __PRETTY_FUNCTION__ , a, b)
00052 #define PRINT_FUNC_NAME_ARGS3(a, b, c) OW_FuncNamePrinter fnp##__LINE__ ( __PRETTY_FUNCTION__ , a, b, c)
00053 #define PRINT_FUNC_NAME_ARGS4(a, b, c, d) OW_FuncNamePrinter fnp##__LINE__ ( __PRETTY_FUNCTION__ , a, b, c, d)
00054 #define PRINT_FUNC_NAME_ARGS5(a, b, c, d, e) OW_FuncNamePrinter fnp##__LINE__ ( __PRETTY_FUNCTION__ , a, b, c, d, e)
00055 #define PRINT_FUNC_NAME_ARGS6(a, b, c, d, e, f) OW_FuncNamePrinter fnp##__LINE__ ( __PRETTY_FUNCTION__ , a, b, c, d, e, f)
00056 #define PRINT_FUNC_NAME_ARGS7(a, b, c, d, e, f, g) OW_FuncNamePrinter fnp##__LINE__ ( __PRETTY_FUNCTION__ , a, b, c, d, e, f, g)
00057 #define PRINT_FUNC_NAME_ARGS8(a, b, c, d, e, f, g, h) OW_FuncNamePrinter fnp##__LINE__ ( __PRETTY_FUNCTION__ , a, b, c, d, e, f, g, h)
00058 #define PRINT_FUNC_NAME_ARGS9(a, b, c, d, e, f, g, h, i) OW_FuncNamePrinter fnp##__LINE__ ( __PRETTY_FUNCTION__ , a, b, c, d, e, f, g, h, i)
00059 #define PRINT_FUNC_NAME_ARGS10(a, b, c, d, e, f, g, h, i, j) OW_FuncNamePrinter fnp##__LINE__ ( __PRETTY_FUNCTION__ , a, b, c, d, e, f, g, h, i, j)
00060 #else
00061 #define PRINT_FUNC_NAME_ARGS1(a)
00062 #define PRINT_FUNC_NAME_ARGS2(a, b)
00063 #define PRINT_FUNC_NAME_ARGS3(a, b, c)
00064 #define PRINT_FUNC_NAME_ARGS4(a, b, c, d)
00065 #define PRINT_FUNC_NAME_ARGS5(a, b, c, d, e)
00066 #define PRINT_FUNC_NAME_ARGS6(a, b, c, d, e, f)
00067 #define PRINT_FUNC_NAME_ARGS7(a, b, c, d, e, f, g)
00068 #define PRINT_FUNC_NAME_ARGS8(a, b, c, d, e, f, g, h)
00069 #define PRINT_FUNC_NAME_ARGS9(a, b, c, d, e, f, g, h, i)
00070 #define PRINT_FUNC_NAME_ARGS10(a, b, c, d, e, f, g, h, i, j)
00071 #define PRINT_FUNC_NAME
00072 #endif /* #ifdef OW_PRINT_FUNC_DEBUG */
00073 
00074 namespace OW_NAMESPACE
00075 {
00076 
00077 class FuncNamePrinter
00078 {
00079 private:
00080    const char* m_funcName;
00081 public:
00082    
00083    FuncNamePrinter(const char* funcName) : m_funcName(funcName)
00084    {
00085       fprintf(stderr, "%d Entering: %s\n", getpid(), funcName);
00086    }
00087    template<typename A>
00088       FuncNamePrinter(const char* funcName, const A& a) : m_funcName(funcName)
00089       {
00090          fprintf(stderr, "%d Entering: %s\n\t%s\n", getpid(), funcName, 
00091             Format("(%1)", a).c_str());
00092       }
00093    template<typename A, typename B>
00094       FuncNamePrinter(const char* funcName, const A& a, const B& b) : m_funcName(funcName)
00095       {
00096          fprintf(stderr, "%d Entering: %s\n\t%s\n", getpid(), funcName, 
00097             Format("(%1, %2)", a, b).c_str());
00098       }
00099    template<typename A, typename B, typename C>
00100       FuncNamePrinter(const char* funcName, const A& a, const B& b, const C& c) : m_funcName(funcName)
00101       {
00102          fprintf(stderr, "%d Entering: %s\n\t%s\n", getpid(), funcName, 
00103             Format("(%1, %2, %3)", a, b, c).c_str());
00104       }
00105    template<typename A, typename B, typename C, typename D>
00106       FuncNamePrinter(const char* funcName, const A& a, const B& b, const C& c, const D& d) : m_funcName(funcName)
00107       {
00108          fprintf(stderr, "%d Entering: %s\n\t%s\n", getpid(), funcName, 
00109             Format("(%1, %2, %3, %4)", a, b, c, d).c_str());
00110       }
00111    template<typename A, typename B, typename C, typename D, typename E>
00112       FuncNamePrinter(const char* funcName, const A& a, const B& b, const C& c, const D& d, const E& e) : m_funcName(funcName)
00113       {
00114          fprintf(stderr, "%d Entering: %s\n\t%s\n", getpid(), funcName, 
00115             Format("(%1, %2, %3, %4, %5)", a, b, c, d, e).c_str());
00116       }
00117    template<typename A, typename B, typename C, typename D, typename E, typename F>
00118       FuncNamePrinter(const char* funcName, const A& a, const B& b, const C& c, const D& d, const E& e, const F& f) : m_funcName(funcName)
00119       {
00120          fprintf(stderr, "%d Entering: %s\n\t%s\n", getpid(), funcName, 
00121             Format("(%1, %2, %3, %4, %5, %6)", a, b, c, d, e, f).c_str());
00122       }
00123    template<typename A, typename B, typename C, typename D, typename E, typename F,
00124    typename G>
00125       FuncNamePrinter(const char* funcName, const A& a, const B& b, const C& c, const D& d, const E& e, const F& f, const G& g) : m_funcName(funcName)
00126       {
00127          fprintf(stderr, "%d Entering: %s\n\t%s\n", getpid(), funcName, 
00128             Format("(%1, %2, %3, %4, %5, %6, %7)", a, b, c, d, e, f, g).c_str());
00129       }
00130    template<typename A, typename B, typename C, typename D, typename E, typename F,
00131    typename G, typename H>
00132       FuncNamePrinter(const char* funcName, const A& a, const B& b, const C& c, const D& d, const E& e, const F& f, const G& g, const H& h) : m_funcName(funcName)
00133       {
00134          fprintf(stderr, "%d Entering: %s\n\t%s\n", getpid(), funcName, 
00135             Format("(%1, %2, %3, %4, %5, %6, %7, %8)", a, b, c, d, e, f, g, h).c_str());
00136       }
00137    template<typename A, typename B, typename C, typename D, typename E, typename F,
00138    typename G, typename H, typename I>
00139       FuncNamePrinter(const char* funcName, const A& a, const B& b, const C& c, const D& d, const E& e, const F& f, const G& g, const H& h, const I& i) : m_funcName(funcName)
00140       {
00141          fprintf(stderr, "%d Entering: %s\n\t%s\n", getpid(), funcName, 
00142             Format("(%1, %2, %3, %4, %5, %6, %7, %8, %9)", a, b, c, d, e, f, g, h, i).c_str());
00143       }
00144    template<typename A, typename B, typename C, typename D, typename E, typename F,
00145    typename G, typename H, typename I, typename J>
00146       FuncNamePrinter(const char* funcName, const A& a, const B& b, const C& c, const D& d, const E& e, const F& f, const G& g, const H& h, const I& i, const J& j) : m_funcName(funcName)
00147       {
00148          fprintf(stderr, "%d Entering: %s\n\t%s\n", getpid(), funcName, 
00149             Format("(%1, %2, %3, %4, %5, %6, %7, %8, %9)", a, b, c, d, e, f, g, h, Format("%1, %2", i, j)).c_str());
00150       }
00151    ~FuncNamePrinter()
00152       { fprintf(stderr, "%d Leaving:  %s\n", getpid(), m_funcName); }
00153 }; // class FuncNamePrinter
00154 
00155 } // end namespace OW_NAMESPACE
00156 
00157 #endif //#define OW_FUNC_NAME_PRINTER_HPP

Generated on Thu Feb 9 08:47:59 2006 for openwbem by  doxygen 1.4.6