2018-10-25 10:39:16 +00:00
|
|
|
#pragma once
|
2018-11-16 15:02:43 +00:00
|
|
|
#include "ki/pclass/types/Type.h"
|
|
|
|
#include "ki/pclass/PropertyList.h"
|
|
|
|
|
|
|
|
#define _KI_TYPE ki::pclass::Type
|
|
|
|
#define _KI_TYPE_SYSTEM ki::pclass::TypeSystem
|
|
|
|
#define _KI_PCLASS ki::pclass::PropertyClass
|
|
|
|
|
|
|
|
#define _KI_PCLASS_CONSTRUCTOR(derived) \
|
2018-11-27 11:51:56 +00:00
|
|
|
explicit derived(const _KI_TYPE &type, const _KI_TYPE_SYSTEM &type_system)
|
|
|
|
|
|
|
|
#define _KI_PCLASS_COPY_CONSTRUCTOR(derived) \
|
|
|
|
derived(const derived &that)
|
2018-11-16 15:02:43 +00:00
|
|
|
|
|
|
|
#define _KI_PCLASS_CONSTRUCT_BASE(base) \
|
2018-11-27 11:51:56 +00:00
|
|
|
: base(type, type_system)
|
|
|
|
|
|
|
|
#define _KI_PCLASS_COPY_CONSTRUCT_BASE(base) \
|
|
|
|
: base(that)
|
2018-11-16 15:02:43 +00:00
|
|
|
|
|
|
|
#define DERIVED_PCLASS(derived, base) class derived : public base
|
2018-12-01 17:16:40 +00:00
|
|
|
#define PCLASS(derived) DERIVED_PCLASS(derived, _KI_PCLASS)
|
2018-11-16 15:02:43 +00:00
|
|
|
|
|
|
|
#define PCLASS_CONSTRUCTOR(derived) \
|
|
|
|
_KI_PCLASS_CONSTRUCTOR(derived) \
|
|
|
|
_KI_PCLASS_CONSTRUCT_BASE(_KI_PCLASS)
|
|
|
|
|
|
|
|
#define DERIVED_PCLASS_CONSTRUCTOR(derived, base) \
|
|
|
|
_KI_PCLASS_CONSTRUCTOR(derived) \
|
|
|
|
_KI_PCLASS_CONSTRUCT_BASE(base)
|
|
|
|
|
2018-11-27 11:51:56 +00:00
|
|
|
#define PCLASS_COPY_CONSTRUCTOR(derived) \
|
|
|
|
_KI_PCLASS_COPY_CONSTRUCTOR(derived) \
|
|
|
|
_KI_PCLASS_COPY_CONSTRUCT_BASE(_KI_PCLASS)
|
|
|
|
|
|
|
|
#define DERIVED_PCLASS_COPY_CONSTRUCTOR(derived, base) \
|
|
|
|
_KI_PCLASS_COPY_CONSTRUCTOR(derived) \
|
|
|
|
_KI_PCLASS_COPY_CONSTRUCT_BASE(base)
|
|
|
|
|
2018-11-16 15:02:43 +00:00
|
|
|
#define TYPE(n) type_system.get_type(n)
|
|
|
|
|
|
|
|
#define INIT_PROPERTY(identifier, type) \
|
|
|
|
, identifier(*this, #identifier, TYPE(type))
|
|
|
|
|
2018-11-27 11:51:56 +00:00
|
|
|
#define INIT_PROPERTY_COPY(identifier) \
|
2018-12-10 21:35:51 +00:00
|
|
|
, identifier(*this, that.identifier)
|
2018-11-27 11:51:56 +00:00
|
|
|
|
2018-11-16 15:02:43 +00:00
|
|
|
#define INIT_PROPERTY_VALUE(identifier, type, value) \
|
|
|
|
, identifier(*this, #identifier, TYPE(type), value)
|
2018-10-25 10:39:16 +00:00
|
|
|
|
|
|
|
namespace ki
|
|
|
|
{
|
|
|
|
namespace pclass
|
|
|
|
{
|
2018-11-16 15:02:43 +00:00
|
|
|
template <typename ValueT>
|
|
|
|
class ClassType;
|
2018-10-25 10:39:16 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* TODO: Documentation
|
|
|
|
*/
|
|
|
|
class PropertyClass
|
|
|
|
{
|
2018-12-01 17:16:40 +00:00
|
|
|
friend IProperty;
|
2018-11-27 11:51:56 +00:00
|
|
|
|
2018-11-16 15:02:43 +00:00
|
|
|
public:
|
|
|
|
explicit PropertyClass(const Type &type, const TypeSystem &type_system);
|
2018-11-27 11:51:56 +00:00
|
|
|
virtual ~PropertyClass() {}
|
2018-11-16 15:02:43 +00:00
|
|
|
|
2018-11-27 11:51:56 +00:00
|
|
|
PropertyClass(const PropertyClass &that);
|
|
|
|
PropertyClass &operator=(const PropertyClass &that);
|
2018-10-25 10:39:16 +00:00
|
|
|
|
2018-11-27 11:51:56 +00:00
|
|
|
const Type &get_type() const;
|
2018-11-16 15:02:43 +00:00
|
|
|
PropertyList &get_properties();
|
|
|
|
const PropertyList &get_properties() const;
|
2018-10-25 10:39:16 +00:00
|
|
|
|
2018-11-27 11:51:56 +00:00
|
|
|
virtual PropertyClass *copy() const;
|
|
|
|
virtual void on_created() const {}
|
|
|
|
|
|
|
|
protected:
|
2018-12-01 17:16:40 +00:00
|
|
|
void add_property(IProperty &prop);
|
2018-11-27 11:51:56 +00:00
|
|
|
|
2018-10-25 10:39:16 +00:00
|
|
|
private:
|
2018-11-16 15:02:43 +00:00
|
|
|
const Type *m_type;
|
2018-11-27 11:51:56 +00:00
|
|
|
PropertyList m_properties;
|
2018-10-25 10:39:16 +00:00
|
|
|
};
|
|
|
|
}
|
|
|
|
}
|