ReFRACtor
fp_type_index.h
Go to the documentation of this file.
1 #ifndef FP_TYPE_INDEX_H
2 #define FP_TYPE_INDEX_H
3 #include <cstring>
4 #include <typeinfo>
5 #include <boost/operators.hpp>
6 
7 namespace FullPhysics {
9 class null_type {
10 };
11 
12 /****************************************************************/
20 class type_index : public boost::totally_ordered<type_index> {
21 public:
22 
23 //-----------------------------------------------------------------------
25 //-----------------------------------------------------------------------
26 
27  type_index() : id(&typeid(null_type)) {}
28 
29 //-----------------------------------------------------------------------
31 //-----------------------------------------------------------------------
32 
33  type_index(std::type_info const& id) : id(&id) {}
34 
35 //-----------------------------------------------------------------------
37 //-----------------------------------------------------------------------
38 
39  bool operator==(type_index const& other) const
40  { return std::strcmp(id->name(), other.id->name()) == 0;}
41 
42 //-----------------------------------------------------------------------
44 //-----------------------------------------------------------------------
45 
46  bool operator<(type_index const& other) const
47  {return std::strcmp(id->name(), other.id->name()) < 0;}
48 
49 //-----------------------------------------------------------------------
51 //-----------------------------------------------------------------------
52 
53  std::string name() const {return id->name();}
54 private:
55  std::type_info const* id;
56 };
57 }
58 #endif
type_index(std::type_info const &id)
Constructor.
Definition: fp_type_index.h:33
Dummy class to use as a nice default for type_index.
Definition: fp_type_index.h:9
type_index()
Default constructor.
Definition: fp_type_index.h:27
bool operator==(type_index const &other) const
Comparison operator.
Definition: fp_type_index.h:39
bool operator<(type_index const &other) const
Comparison operator.
Definition: fp_type_index.h:46
std::string name() const
Return type name.
Definition: fp_type_index.h:53
Contains classes to abstract away details in various Spurr Radiative Transfer software.
Definition: doxygen_python.h:1
This is a wrapper around std::type_info that allows it to be used as an index in a associative contai...
Definition: fp_type_index.h:20

Copyright © 2017, California Institute of Technology.
ALL RIGHTS RESERVED.
U.S. Government Sponsorship acknowledged.
Generated Fri Aug 24 2018 15:44:11