2018-11-16 15:02:43 +00:00
|
|
|
#pragma once
|
|
|
|
#include "ki/pclass/types/Type.h"
|
|
|
|
|
|
|
|
namespace ki
|
|
|
|
{
|
|
|
|
namespace pclass
|
|
|
|
{
|
|
|
|
class PropertyClass;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* TODO: Documentation
|
|
|
|
*/
|
2018-12-01 17:16:40 +00:00
|
|
|
class IProperty
|
2018-11-16 15:02:43 +00:00
|
|
|
{
|
|
|
|
public:
|
2018-11-27 11:51:56 +00:00
|
|
|
// Do not allow copy assignment. Once a property has been constructed,
|
|
|
|
// it shouldn't be able to change.
|
2018-12-01 17:16:40 +00:00
|
|
|
virtual IProperty &operator=(const IProperty &that) = delete;
|
2018-11-27 11:51:56 +00:00
|
|
|
|
2018-12-01 17:16:40 +00:00
|
|
|
IProperty(PropertyClass &object,
|
2018-11-16 15:02:43 +00:00
|
|
|
const std::string &name, const Type &type);
|
2018-12-01 17:16:40 +00:00
|
|
|
IProperty(PropertyClass &object,
|
|
|
|
const IProperty &that);
|
2018-11-16 15:02:43 +00:00
|
|
|
|
2018-12-13 22:12:04 +00:00
|
|
|
virtual ~IProperty() {}
|
|
|
|
|
2018-11-27 15:36:57 +00:00
|
|
|
const PropertyClass &get_instance() const;
|
2018-11-16 15:02:43 +00:00
|
|
|
std::string get_name() const;
|
|
|
|
hash_t get_name_hash() const;
|
|
|
|
hash_t get_full_hash() const;
|
|
|
|
const Type &get_type() const;
|
|
|
|
|
|
|
|
virtual bool is_pointer() const;
|
|
|
|
virtual bool is_dynamic() const;
|
|
|
|
|
|
|
|
virtual Value get_value() const = 0;
|
|
|
|
virtual const PropertyClass *get_object() const = 0;
|
2018-12-13 22:12:04 +00:00
|
|
|
virtual void set_object(std::unique_ptr<PropertyClass> &object) = 0;
|
2018-11-16 15:02:43 +00:00
|
|
|
|
2018-11-27 11:51:56 +00:00
|
|
|
virtual void write_value_to(BitStream &stream) const = 0;
|
|
|
|
virtual void read_value_from(BitStream &stream) = 0;
|
2018-11-16 15:02:43 +00:00
|
|
|
|
|
|
|
private:
|
2018-11-27 15:36:57 +00:00
|
|
|
const PropertyClass *m_instance;
|
2018-11-16 15:02:43 +00:00
|
|
|
std::string m_name;
|
|
|
|
hash_t m_name_hash;
|
|
|
|
hash_t m_full_hash;
|
|
|
|
const Type *m_type;
|
|
|
|
};
|
|
|
|
|
|
|
|
/**
|
|
|
|
* TODO: Documentation
|
|
|
|
*/
|
2018-12-01 17:16:40 +00:00
|
|
|
class IDynamicProperty : public IProperty
|
2018-11-16 15:02:43 +00:00
|
|
|
{
|
|
|
|
public:
|
2018-11-27 11:51:56 +00:00
|
|
|
// Do not allow copy assignment. Once a property has been constructed,
|
|
|
|
// it shouldn't be able to change.
|
2018-12-01 17:16:40 +00:00
|
|
|
IDynamicProperty & operator=(const IDynamicProperty &that) = delete;
|
2018-11-27 11:51:56 +00:00
|
|
|
|
2018-12-01 17:16:40 +00:00
|
|
|
IDynamicProperty(PropertyClass &object,
|
2018-11-16 15:02:43 +00:00
|
|
|
const std::string &name, const Type &type);
|
2018-12-01 17:16:40 +00:00
|
|
|
IDynamicProperty(PropertyClass &object,
|
|
|
|
const IDynamicProperty &that);
|
2018-11-27 11:51:56 +00:00
|
|
|
|
2018-12-13 22:12:04 +00:00
|
|
|
virtual ~IDynamicProperty() {}
|
|
|
|
|
2018-11-16 15:02:43 +00:00
|
|
|
bool is_dynamic() const override;
|
|
|
|
virtual std::size_t get_element_count() const = 0;
|
2018-11-27 11:51:56 +00:00
|
|
|
virtual void set_element_count(std::size_t size) = 0;
|
2018-11-16 15:02:43 +00:00
|
|
|
|
|
|
|
Value get_value() const final override;
|
|
|
|
const PropertyClass *get_object() const final override;
|
2018-12-13 22:12:04 +00:00
|
|
|
void set_object(std::unique_ptr<PropertyClass> &object) final override;
|
2018-11-27 11:51:56 +00:00
|
|
|
void write_value_to(BitStream &stream) const final override;
|
|
|
|
void read_value_from(BitStream &stream) final override;
|
2018-11-16 15:02:43 +00:00
|
|
|
|
|
|
|
virtual Value get_value(int index) const = 0;
|
|
|
|
virtual const PropertyClass *get_object(int index) const = 0;
|
2018-12-13 22:12:04 +00:00
|
|
|
virtual void set_object(std::unique_ptr<PropertyClass> &object, int index) = 0;
|
2018-11-27 11:51:56 +00:00
|
|
|
virtual void write_value_to(BitStream &stream, int index) const = 0;
|
|
|
|
virtual void read_value_from(BitStream &stream, int index) = 0;
|
2018-11-16 15:02:43 +00:00
|
|
|
};
|
|
|
|
}
|
|
|
|
}
|