summaryrefslogtreecommitdiffstats
path: root/src/type-info.h
blob: 3340e08e5c3177d9039bef4fe3a9f3993d592526 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
#pragma once

#include <typeinfo>

/**
 * A wrapper around typeinfo. Inspired by Andrei Alexandrescu's "Modern C++ Design".
 * Used as a temporary replacement for glib's type-checking system as long as SPObject
 * must not be polymorphic / new objects are instantiated by g_object_new.
 */
class TypeInfo {
public:
	TypeInfo(const std::type_info& type_info);
	TypeInfo(const TypeInfo& tinfo);

	TypeInfo& operator=(const TypeInfo& tinfo);

	bool before(const TypeInfo& tinfo) const;
	const char* name() const;

	const std::type_info& get() const;

private:
	const std::type_info* type_info;
};

bool operator==(const TypeInfo& lhs, const TypeInfo& rhs);
bool operator!=(const TypeInfo& lhs, const TypeInfo& rhs);
bool operator<(const TypeInfo& lhs, const TypeInfo& rhs);
bool operator<=(const TypeInfo& lhs, const TypeInfo& rhs);
bool operator>(const TypeInfo& lhs, const TypeInfo& rhs);
bool operator>=(const TypeInfo& lhs, const TypeInfo& rhs);