Omnidome
Fulldome Mapping Software Toolkit
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
type_info.hpp
Go to the documentation of this file.
1 /* Copyright (c) 2014-2015 "Omnidome" by cr8tr
2  * Dome Mapping Projection Software (http://omnido.me).
3  * Omnidome was created by Michael Winkelmann aka Wilston Oreo (@WilstonOreo)
4  *
5  * This file is part of Omnidome.
6  *
7  * Omnidome is free software: you can redistribute it and/or modify
8  * it under the terms of the GNU Affero General Public License as
9  * published by the Free Software Foundation, either version 3 of the
10  * License, or (at your option) any later version.
11  *
12  * This program is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15  * GNU Affero General Public License for more details.
16  * You should have received a copy of the GNU Affero General Public License
17  * along with this program. If not, see <http://www.gnu.org/licenses/>.
18  */
19 
20 #ifndef BOOSTX_TYPE_INFO_HPP_
21 #define BOOSTX_TYPE_INFO_HPP_
22 
23 #include <string>
24 
25 /// Convenience macro for declaring a type info struct
26 
27 #define BOOSTX_DECL_TYPE_INFO(NAME,TYPEID,STATIC_MEMBER,VIRTUAL_MEMBER)\
28  template<typename T>\
29  struct NAME\
30  {\
31  typedef TYPEID typeid_type;\
32  typeid_type operator()() const\
33  {\
34  return T::STATIC_MEMBER();\
35  }\
36  template<typename PTR>\
37  typeid_type operator()(PTR&& _ptr) const\
38  {\
39  return _ptr->VIRTUAL_MEMBER();\
40  }\
41  };
42 
43 /// Convenience macro for defining a type id for a single class
44 #define BOOSTX_TYPE_ID(TYPEID_TYPE,TYPEID,STATIC_MEMBER,VIRTUAL_MEMBER)\
45  inline static TYPEID_TYPE STATIC_MEMBER() { return TYPEID; }\
46  inline virtual TYPEID_TYPE VIRTUAL_MEMBER() const { return STATIC_MEMBER(); }
47 
48 namespace boostx
49 {
50  /// Declare default type id mechanism
52  type_info, // Name of type id struct
53  std::string, // Type id type
54  type_id, // Static member function
55  get_type_id // Virtual member function of abstract interface
56  )
57 }
58 
59 #define BOOSTX_DECL_TYPE_ID_DEFAULT(TYPEID)\
60  BOOSTX_TYPE_ID(std::string,TYPEID,type_id,get_type_id)
61 
62 
63 #endif /* BOOSTX_TYPE_INFO_HPP_ */
#define BOOSTX_DECL_TYPE_INFO(NAME, TYPEID, STATIC_MEMBER, VIRTUAL_MEMBER)
Convenience macro for declaring a type info struct.
Definition: type_info.hpp:27