#pragma once #include "ki/pclass/types/Type.h" namespace ki { namespace pclass { class PropertyClass; /** * TODO: Documentation */ class PropertyBase { public: // Do not allow copy assignment. Once a property has been constructed, // it shouldn't be able to change. PropertyBase & operator=(const PropertyBase &that) = delete; PropertyBase(PropertyClass &object, const std::string &name, const Type &type); virtual ~PropertyBase() {} PropertyBase(PropertyClass &object, const PropertyBase &that); 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; virtual void set_object(PropertyClass *object) = 0; virtual void write_value_to(BitStream &stream) const = 0; virtual void read_value_from(BitStream &stream) = 0; private: std::string m_name; hash_t m_name_hash; hash_t m_full_hash; const Type *m_type; }; /** * TODO: Documentation */ class DynamicPropertyBase : public PropertyBase { public: // Do not allow copy assignment. Once a property has been constructed, // it shouldn't be able to change. DynamicPropertyBase & operator=(const DynamicPropertyBase &that) = delete; DynamicPropertyBase(PropertyClass &object, const std::string &name, const Type &type); virtual ~DynamicPropertyBase() {} DynamicPropertyBase(PropertyClass &object, const DynamicPropertyBase &that); bool is_dynamic() const override; virtual std::size_t get_element_count() const = 0; virtual void set_element_count(std::size_t size) = 0; Value get_value() const final override; const PropertyClass *get_object() const final override; void set_object(PropertyClass *object) final override; void write_value_to(BitStream &stream) const final override; void read_value_from(BitStream &stream) final override; virtual Value get_value(int index) const = 0; virtual const PropertyClass *get_object(int index) const = 0; virtual void set_object(PropertyClass *object, int index) = 0; virtual void write_value_to(BitStream &stream, int index) const = 0; virtual void read_value_from(BitStream &stream, int index) = 0; }; } }