Synesis Software STLSoft - ... Robust, Lightweight, Cross-platform, Template Software ...

pantheios/inserters/threadid.hpp

Go to the documentation of this file.
00001 /* /////////////////////////////////////////////////////////////////////////
00002  * File:        pantheios/inserters/threadid.hpp
00003  *
00004  * Purpose:     String inserter for thread identity.
00005  *
00006  * Created:     16th October 2006
00007  * Updated:     22nd March 2010
00008  *
00009  * Home:        http://www.pantheios.org/
00010  *
00011  * Copyright (c) 2006-2010, Matthew Wilson and Synesis Software
00012  * All rights reserved.
00013  *
00014  * Redistribution and use in source and binary forms, with or without
00015  * modification, are permitted provided that the following conditions are
00016  * met:
00017  *
00018  * - Redistributions of source code must retain the above copyright notice,
00019  *   this list of conditions and the following disclaimer.
00020  * - Redistributions in binary form must reproduce the above copyright
00021  *   notice, this list of conditions and the following disclaimer in the
00022  *   documentation and/or other materials provided with the distribution.
00023  * - Neither the name(s) of Matthew Wilson and Synesis Software nor the
00024  *   names of any contributors may be used to endorse or promote products
00025  *   derived from this software without specific prior written permission.
00026  *
00027  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
00028  * IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
00029  * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
00030  * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
00031  * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
00032  * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
00033  * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
00034  * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
00035  * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
00036  * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
00037  * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
00038  *
00039  * ////////////////////////////////////////////////////////////////////// */
00040 
00041 
00047 #ifndef PANTHEIOS_INCL_PANTHEIOS_INSERTERS_HPP_THREADID
00048 #define PANTHEIOS_INCL_PANTHEIOS_INSERTERS_HPP_THREADID
00049 
00050 /* /////////////////////////////////////////////////////////////////////////
00051  * Version information
00052  */
00053 
00054 #ifndef PANTHEIOS_DOCUMENTATION_SKIP_SECTION
00055 # define PANTHEIOS_VER_PANTHEIOS_INSERTERS_HPP_THREADID_MAJOR       2
00056 # define PANTHEIOS_VER_PANTHEIOS_INSERTERS_HPP_THREADID_MINOR       2
00057 # define PANTHEIOS_VER_PANTHEIOS_INSERTERS_HPP_THREADID_REVISION    1
00058 # define PANTHEIOS_VER_PANTHEIOS_INSERTERS_HPP_THREADID_EDIT        18
00059 #endif /* !PANTHEIOS_DOCUMENTATION_SKIP_SECTION */
00060 
00061 /* /////////////////////////////////////////////////////////////////////////
00062  * Includes
00063  */
00064 
00065 #ifndef PANTHEIOS_INCL_PANTHEIOS_H_PANTHEIOS
00066 # include <pantheios/pantheios.h>
00067 #endif /* !PANTHEIOS_INCL_PANTHEIOS_H_PANTHEIOS */
00068 #ifndef PANTHEIOS_INCL_PANTHEIOS_INSERTERS_HPP_FMT
00069 # include <pantheios/inserters/fmt.hpp>
00070 #endif /* !PANTHEIOS_INCL_PANTHEIOS_INSERTERS_HPP_FMT */
00071 
00072 #ifndef STLSOFT_INCL_STLSOFT_SHIMS_ACCESS_STRING_H_FWD
00073 # include <stlsoft/shims/access/string/fwd.h>
00074 #endif /* !STLSOFT_INCL_STLSOFT_SHIMS_ACCESS_STRING_H_FWD */
00075 
00076 /* /////////////////////////////////////////////////////////////////////////
00077  * Namespace
00078  */
00079 
00080 #if !defined(PANTHEIOS_NO_NAMESPACE)
00081 namespace pantheios
00082 {
00083 #endif /* !PANTHEIOS_NO_NAMESPACE */
00084 
00085 /* /////////////////////////////////////////////////////////////////////////
00086  * Typedefs
00087  */
00088 
00089 #ifndef PANTHEIOS_DOCUMENTATION_SKIP_SECTION
00090 struct threadId_t;
00091 #endif /* !PANTHEIOS_DOCUMENTATION_SKIP_SECTION */
00092 
00108 extern struct threadId_t const* threadId;
00109 
00110 /* /////////////////////////////////////////////////////////////////////////
00111  * Inserter classes and String Access Shims
00112  */
00113 
00114 #ifndef PANTHEIOS_DOCUMENTATION_SKIP_SECTION
00115 
00116 # if !defined(PANTHEIOS_NO_NAMESPACE)
00117 namespace inserters
00118 {
00119 # endif /* !PANTHEIOS_NO_NAMESPACE */
00120 
00121 class thread_id_t
00122 {
00123 public:
00124     typedef thread_id_t             class_type;
00125 # if !defined(PANTHEIOS_NO_NAMESPACE)
00126     typedef ::pantheios::threadId_t id_type;
00127 # else /* ? !PANTHEIOS_NO_NAMESPACE */
00128     typedef threadId_t              id_type;
00129 # endif /* !PANTHEIOS_NO_NAMESPACE */
00130 
00131 public:
00132     thread_id_t();
00133 
00134 public:
00135     operator size_t () const;
00136     operator pan_char_t const* () const;
00137 
00138 private:
00139     void construct_();
00140     void construct_() const;
00141 
00142 private:
00143     pan_char_t  m_value[21];
00144     size_t      m_len;
00145 };
00146 
00147 # if !defined(PANTHEIOS_NO_NAMESPACE)
00148 } /* namespace inserters */
00149 #  define PANTHEIOS_INSERTERS_DECLARE_thread_id_t   ::pantheios::inserters::thread_id_t
00150 # else /* ? !PANTHEIOS_NO_NAMESPACE */
00151 #  define PANTHEIOS_INSERTERS_DECLARE_thread_id_t   thread_id_t
00152 # endif /* !PANTHEIOS_NO_NAMESPACE */
00153 
00154 # if !defined(PANTHEIOS_NO_NAMESPACE)
00155 namespace shims
00156 {
00157 # endif /* !PANTHEIOS_NO_NAMESPACE */
00158 
00159 # ifdef PANTHEIOS_USE_WIDE_STRINGS
00160 inline PANTHEIOS_INSERTERS_DECLARE_thread_id_t c_str_data_w(PANTHEIOS_INSERTERS_DECLARE_thread_id_t::id_type const*)
00161 # else /* ? PANTHEIOS_USE_WIDE_STRINGS */
00162 inline PANTHEIOS_INSERTERS_DECLARE_thread_id_t c_str_data_a(PANTHEIOS_INSERTERS_DECLARE_thread_id_t::id_type const*)
00163 # endif /* PANTHEIOS_USE_WIDE_STRINGS */
00164 {
00165     return PANTHEIOS_INSERTERS_DECLARE_thread_id_t();
00166 }
00167 inline PANTHEIOS_INSERTERS_DECLARE_thread_id_t c_str_data(PANTHEIOS_INSERTERS_DECLARE_thread_id_t::id_type const*)
00168 {
00169     return PANTHEIOS_INSERTERS_DECLARE_thread_id_t();
00170 }
00171 
00172 # ifdef PANTHEIOS_USE_WIDE_STRINGS
00173 inline PANTHEIOS_INSERTERS_DECLARE_thread_id_t c_str_len_w(PANTHEIOS_INSERTERS_DECLARE_thread_id_t::id_type const*)
00174 # else /* ? PANTHEIOS_USE_WIDE_STRINGS */
00175 inline PANTHEIOS_INSERTERS_DECLARE_thread_id_t c_str_len_a(PANTHEIOS_INSERTERS_DECLARE_thread_id_t::id_type const*)
00176 # endif /* PANTHEIOS_USE_WIDE_STRINGS */
00177 {
00178     return PANTHEIOS_INSERTERS_DECLARE_thread_id_t();
00179 }
00180 inline PANTHEIOS_INSERTERS_DECLARE_thread_id_t c_str_len(PANTHEIOS_INSERTERS_DECLARE_thread_id_t::id_type const*)
00181 {
00182     return PANTHEIOS_INSERTERS_DECLARE_thread_id_t();
00183 }
00184 
00185 # ifdef PANTHEIOS_USE_WIDE_STRINGS
00186 inline PANTHEIOS_INSERTERS_DECLARE_thread_id_t c_str_ptr_w(PANTHEIOS_INSERTERS_DECLARE_thread_id_t::id_type const*)
00187 # else /* ? PANTHEIOS_USE_WIDE_STRINGS */
00188 inline PANTHEIOS_INSERTERS_DECLARE_thread_id_t c_str_ptr_a(PANTHEIOS_INSERTERS_DECLARE_thread_id_t::id_type const*)
00189 # endif /* PANTHEIOS_USE_WIDE_STRINGS */
00190 {
00191     return PANTHEIOS_INSERTERS_DECLARE_thread_id_t();
00192 }
00193 inline PANTHEIOS_INSERTERS_DECLARE_thread_id_t c_str_ptr(PANTHEIOS_INSERTERS_DECLARE_thread_id_t::id_type const*)
00194 {
00195     return PANTHEIOS_INSERTERS_DECLARE_thread_id_t();
00196 }
00197 
00198 # if !defined(PANTHEIOS_NO_NAMESPACE)
00199 } /* namespace shims */
00200 
00201 #  if defined(STLSOFT_COMPILER_IS_GCC)
00202     /* GCC does not seem to correctly handle the phases of
00203      * processing of C++ templates, so we need to 'use' the
00204      * shims into the same namespace as the inserter class
00205      * in order that ADL can suffice instead.
00206      */
00207     using ::pantheios::shims::c_str_data_a;
00208     using ::pantheios::shims::c_str_data;
00209 
00210     using ::pantheios::shims::c_str_len_a;
00211     using ::pantheios::shims::c_str_len;
00212 
00213     using ::pantheios::shims::c_str_ptr_a;
00214     using ::pantheios::shims::c_str_ptr;
00215 #  endif /* compiler */
00216 
00217 # endif /* !PANTHEIOS_NO_NAMESPACE */
00218 
00219 #endif /* !PANTHEIOS_DOCUMENTATION_SKIP_SECTION */
00220 
00221 /* /////////////////////////////////////////////////////////////////////////
00222  * Namespace
00223  */
00224 
00225 #if !defined(PANTHEIOS_NO_NAMESPACE)
00226 
00227 } /* namespace pantheios */
00228 
00229 namespace stlsoft
00230 {
00231     // 'Export' the string access shims into the STLSoft namespace
00232     //
00233     // c_str_ptr(_a) is not necessary for version 1.0 of Pantheios, but it's
00234     // defined and exported in order to allow for the case where someone
00235     // may find a legitimate use for the conversion classes additional to
00236     // the type-tunneling of the Pantheios API.
00237 
00238 # ifdef PANTHEIOS_USE_WIDE_STRINGS
00239     using ::pantheios::shims::c_str_data_w;
00240     using ::pantheios::shims::c_str_len_w;
00241     using ::pantheios::shims::c_str_ptr_w;
00242 # else /* ? PANTHEIOS_USE_WIDE_STRINGS */
00243     using ::pantheios::shims::c_str_data_a;
00244     using ::pantheios::shims::c_str_len_a;
00245     using ::pantheios::shims::c_str_ptr_a;
00246 # endif /* PANTHEIOS_USE_WIDE_STRINGS */
00247     using ::pantheios::shims::c_str_data;
00248     using ::pantheios::shims::c_str_len;
00249     using ::pantheios::shims::c_str_ptr;
00250 }
00251 
00252 #endif /* !PANTHEIOS_NO_NAMESPACE */
00253 
00254 /* /////////////////////////////////////////////////////////////////////////
00255  * Inclusion
00256  */
00257 
00258 #ifdef STLSOFT_PPF_pragma_once_SUPPORT
00259 # pragma once
00260 #endif /* STLSOFT_PPF_pragma_once_SUPPORT */
00261 
00262 /* ////////////////////////////////////////////////////////////////////// */
00263 
00264 #endif /* !PANTHEIOS_INCL_PANTHEIOS_INSERTERS_HPP_THREADID */
00265 
00266 /* ///////////////////////////// end of file //////////////////////////// */

pantheios Library documentation © Matthew Wilson & Synesis Software, 2006-2011 SourceForge.net Logo