Browse Source

* Implemented class type inheritance

master
bergmann 5 years ago
parent
commit
ccdee04f79
2 changed files with 20 additions and 3 deletions
  1. +12
    -3
      include/cpprtti/types/class_type.h
  2. +8
    -0
      include/cpprtti/types/class_type.inl

+ 12
- 3
include/cpprtti/types/class_type.h View File

@@ -1,6 +1,7 @@
#pragma once

#include <map>
#include <vector>
#include <memory>

#include "type.h"
@@ -13,11 +14,13 @@ namespace cpprtti
: public type
{
private:
using member_ptr_u = std::unique_ptr<member>;
using member_map = std::map<std::string, member_ptr_u>;
using member_ptr_u = std::unique_ptr<member>;
using member_map = std::map<std::string, member_ptr_u>;
using class_type_vector = std::vector<const class_type*>;

private:
member_map _members;
member_map _members;
class_type_vector _base_classes;

public:
/**
@@ -53,6 +56,12 @@ namespace cpprtti
inline auto& add_member_method(
const std::string& p_name,
T_args&&... p_args);

/**
* @brief Add a base class to this class type.
*/
inline auto& inherits(
const class_type& p_base_class);
};

}

+ 8
- 0
include/cpprtti/types/class_type.inl View File

@@ -84,4 +84,12 @@ namespace cpprtti
return ret;
}

auto& class_type
::inherits(
const class_type& p_base_class)
{
_base_classes.emplace_back(&p_base_class);
return *this;
}

}

Loading…
Cancel
Save