| Line | Branch | Exec | Source |
|---|---|---|---|
| 1 | /* GATE PROJECT LICENSE: | ||
| 2 | +----------------------------------------------------------------------------+ | ||
| 3 | | Copyright (c) 2018-2026, Stefan Meislinger <sm@opengate.at> | | ||
| 4 | | All rights reserved. | | ||
| 5 | | | | ||
| 6 | | Redistribution and use in source and binary forms, with or without | | ||
| 7 | | modification, are permitted provided that the following conditions are met:| | ||
| 8 | | | | ||
| 9 | | 1. Redistributions of source code must retain the above copyright notice, | | ||
| 10 | | this list of conditions and the following disclaimer. | | ||
| 11 | | 2. Redistributions in binary form must reproduce the above copyright | | ||
| 12 | | notice, this list of conditions and the following disclaimer in the | | ||
| 13 | | documentation and/or other materials provided with the distribution. | | ||
| 14 | | | | ||
| 15 | | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"| | ||
| 16 | | AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | | ||
| 17 | | IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE | | ||
| 18 | | ARE DISCLAIMED.IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE | | ||
| 19 | | LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR | | ||
| 20 | | CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF | | ||
| 21 | | SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS | | ||
| 22 | | INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN | | ||
| 23 | | CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) | | ||
| 24 | | ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF | | ||
| 25 | | THE POSSIBILITY OF SUCH DAMAGE. | | ||
| 26 | +----------------------------------------------------------------------------+ | ||
| 27 | */ | ||
| 28 | |||
| 29 | /** @file | ||
| 30 | * @brief C++ typeinfo wrapper | ||
| 31 | * @ingroup gatecore_cpp | ||
| 32 | */ | ||
| 33 | |||
| 34 | #ifndef GATE_PLATFORM_CXX_TYPEINFO_HPP_INCLUDED | ||
| 35 | #define GATE_PLATFORM_CXX_TYPEINFO_HPP_INCLUDED | ||
| 36 | |||
| 37 | #if defined(GATEXX_NO_RTTI) | ||
| 38 | |||
| 39 | #include "gate/typeids.hpp" | ||
| 40 | |||
| 41 | namespace gate | ||
| 42 | { | ||
| 43 | |||
| 44 | struct cxx_type_info | ||
| 45 | { | ||
| 46 | public: | ||
| 47 | cxx_type_info(char const* cxx_type_name); | ||
| 48 | char const* name() const; | ||
| 49 | |||
| 50 | bool operator==(cxx_type_info const& that) const noexcept; | ||
| 51 | bool operator!=(cxx_type_info const& that) const noexcept; | ||
| 52 | |||
| 53 | private: | ||
| 54 | cxx_type_info(cxx_type_info const&); | ||
| 55 | cxx_type_info& operator=(cxx_type_info const&); | ||
| 56 | |||
| 57 | char const* name_member; | ||
| 58 | }; | ||
| 59 | |||
| 60 | typedef struct cxx_type_info cxx_type_info_t; | ||
| 61 | |||
| 62 | |||
| 63 | template<class T> | ||
| 64 | cxx_type_info_t const& get_cxx_type_info() | ||
| 65 | { | ||
| 66 | static char const* sig_name = TypeId<T>::sig(); | ||
| 67 | static cxx_type_info_t const stored_type_info(sig_name); | ||
| 68 | return stored_type_info; | ||
| 69 | } | ||
| 70 | |||
| 71 | } // end of namespace gate | ||
| 72 | |||
| 73 | #else | ||
| 74 | |||
| 75 | #include <typeinfo> | ||
| 76 | |||
| 77 | namespace gate | ||
| 78 | { | ||
| 79 | typedef std::type_info cxx_type_info_t; | ||
| 80 | |||
| 81 | template<class T> | ||
| 82 | 4 | cxx_type_info_t const& get_cxx_type_info() | |
| 83 | { | ||
| 84 | 4 | return typeid(T); | |
| 85 | } | ||
| 86 | |||
| 87 | } // end of namespace gate | ||
| 88 | |||
| 89 | #endif | ||
| 90 | |||
| 91 | #endif /* GATE_PLATFORM_CXX_TYPEINFO_HPP_INCLUDED */ | ||
| 92 |