2018-11-16 15:02:43 +00:00
|
|
|
#pragma once
|
2018-12-21 01:20:52 +00:00
|
|
|
#include <string>
|
2018-11-16 15:02:43 +00:00
|
|
|
#include "ki/pclass/types/Type.h"
|
2018-12-21 01:20:52 +00:00
|
|
|
#include "ki/pclass/HashCalculator.h"
|
|
|
|
#include "ki/pclass/Value.h"
|
|
|
|
#include "ki/util/BitStream.h"
|
2018-11-16 15:02:43 +00:00
|
|
|
|
|
|
|
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;
|
2018-12-20 15:39:31 +00:00
|
|
|
virtual bool is_array() const;
|
|
|
|
virtual std::size_t get_element_count() const;
|
|
|
|
virtual void set_element_count(std::size_t size) = 0;
|
2018-11-16 15:02:43 +00:00
|
|
|
|
2018-12-20 15:39:31 +00:00
|
|
|
virtual Value get_value(std::size_t index = 0) const = 0;
|
|
|
|
virtual void set_value(Value value, std::size_t index = 0) = 0;
|
2018-12-18 21:35:59 +00:00
|
|
|
|
2018-12-20 15:39:31 +00:00
|
|
|
virtual const PropertyClass *get_object(std::size_t index = 0) const = 0;
|
|
|
|
virtual void set_object(std::unique_ptr<PropertyClass> &object, std::size_t index = 0) = 0;
|
2018-11-16 15:02:43 +00:00
|
|
|
|
2018-12-21 01:20:52 +00:00
|
|
|
virtual void write_value_to(BitStream &stream, std::size_t index = 0) const;
|
|
|
|
virtual void read_value_from(BitStream &stream, std::size_t index = 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;
|
|
|
|
};
|
|
|
|
}
|
|
|
|
}
|