50 lines
1.1 KiB
C++
50 lines
1.1 KiB
C++
#ifndef BASIC_PROTOTYPE_INFO_HPP
|
|
#define BASIC_PROTOTYPE_INFO_HPP
|
|
|
|
#include <string>
|
|
#include <typeindex>
|
|
|
|
namespace matador::object {
|
|
|
|
class schema_node;
|
|
|
|
class basic_object_info {
|
|
public:
|
|
virtual ~basic_object_info() = default;
|
|
|
|
[[nodiscard]] std::type_index type_index() const;
|
|
[[nodiscard]] std::string name() const;
|
|
|
|
protected:
|
|
basic_object_info(schema_node &node, std::type_index type_index);
|
|
|
|
protected:
|
|
schema_node &node_; /**< prototype node of the represented object type */
|
|
std::type_index type_index_; /**< type index of the represented object type */
|
|
};
|
|
|
|
template<typename Type>
|
|
class object_info final : public basic_object_info {
|
|
public:
|
|
explicit object_info(schema_node &node)
|
|
: basic_object_info(node, typeid(Type)) {}
|
|
|
|
const Type &prototype() const { return prototype_; }
|
|
|
|
private:
|
|
Type prototype_;
|
|
};
|
|
|
|
template<typename Type>
|
|
using object_info_ref = std::reference_wrapper<const object_info<Type>>;
|
|
|
|
namespace detail {
|
|
struct null_type {};
|
|
}
|
|
|
|
using null_info = object_info<detail::null_type>;
|
|
|
|
}
|
|
|
|
#endif //BASIC_PROTOTYPE_INFO_HPP
|