2018-11-16 15:02:43 +00:00
|
|
|
#pragma once
|
2018-12-13 22:12:04 +00:00
|
|
|
#include <unordered_map>
|
2018-11-16 15:02:43 +00:00
|
|
|
#include <vector>
|
|
|
|
#include "ki/pclass/HashCalculator.h"
|
|
|
|
|
|
|
|
namespace ki
|
|
|
|
{
|
|
|
|
namespace pclass
|
|
|
|
{
|
2018-11-27 11:51:56 +00:00
|
|
|
class PropertyClass;
|
2018-12-01 17:16:40 +00:00
|
|
|
class IProperty;
|
2018-11-16 15:02:43 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* TODO: Documentation
|
|
|
|
*/
|
|
|
|
class PropertyList
|
|
|
|
{
|
2018-11-27 11:51:56 +00:00
|
|
|
friend PropertyClass;
|
2018-11-16 15:02:43 +00:00
|
|
|
|
|
|
|
public:
|
2018-11-27 11:51:56 +00:00
|
|
|
/**
|
|
|
|
* TODO: Documentation
|
|
|
|
*/
|
|
|
|
class iterator
|
|
|
|
{
|
|
|
|
friend PropertyList;
|
|
|
|
|
|
|
|
public:
|
2018-12-01 17:16:40 +00:00
|
|
|
IProperty &operator*() const;
|
|
|
|
IProperty *operator->() const;
|
2018-11-27 11:51:56 +00:00
|
|
|
iterator &operator++();
|
|
|
|
iterator operator++(int);
|
|
|
|
bool operator==(const iterator &that) const;
|
|
|
|
bool operator!=(const iterator &that) const;
|
|
|
|
|
|
|
|
private:
|
|
|
|
PropertyList *m_list;
|
|
|
|
int m_index;
|
|
|
|
|
2018-12-09 23:21:22 +00:00
|
|
|
explicit iterator(PropertyList &list, int index = 0);
|
2018-11-27 11:51:56 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
/**
|
|
|
|
* TODO: Documentation
|
|
|
|
*/
|
|
|
|
class const_iterator
|
|
|
|
{
|
|
|
|
friend PropertyList;
|
|
|
|
|
|
|
|
public:
|
2018-12-01 17:16:40 +00:00
|
|
|
const IProperty &operator*() const;
|
|
|
|
const IProperty *operator->() const;
|
2018-11-27 11:51:56 +00:00
|
|
|
const_iterator &operator++();
|
|
|
|
const_iterator operator++(int);
|
|
|
|
bool operator==(const const_iterator &that) const;
|
|
|
|
bool operator!=(const const_iterator &that) const;
|
|
|
|
|
|
|
|
private:
|
|
|
|
const PropertyList *m_list;
|
|
|
|
int m_index;
|
|
|
|
|
2018-12-09 23:21:22 +00:00
|
|
|
explicit const_iterator(const PropertyList &list, int index = 0);
|
2018-11-27 11:51:56 +00:00
|
|
|
};
|
2018-11-16 15:02:43 +00:00
|
|
|
|
|
|
|
std::size_t get_property_count() const;
|
|
|
|
|
|
|
|
bool has_property(const std::string &name) const;
|
|
|
|
bool has_property(hash_t hash) const;
|
|
|
|
|
2018-12-01 17:16:40 +00:00
|
|
|
IProperty &get_property(int index);
|
|
|
|
const IProperty &get_property(int index) const;
|
2018-11-27 11:51:56 +00:00
|
|
|
|
2018-12-01 17:16:40 +00:00
|
|
|
IProperty &get_property(const std::string &name);
|
|
|
|
const IProperty &get_property(const std::string &name) const;
|
2018-11-27 11:51:56 +00:00
|
|
|
|
2018-12-01 17:16:40 +00:00
|
|
|
IProperty &get_property(hash_t hash);
|
|
|
|
const IProperty &get_property(hash_t hash) const;
|
2018-11-16 15:02:43 +00:00
|
|
|
|
2018-11-27 11:51:56 +00:00
|
|
|
iterator begin();
|
2018-11-16 15:02:43 +00:00
|
|
|
const_iterator begin() const;
|
2018-11-27 11:51:56 +00:00
|
|
|
|
|
|
|
iterator end();
|
2018-11-16 15:02:43 +00:00
|
|
|
const_iterator end() const;
|
|
|
|
|
|
|
|
private:
|
2018-12-01 17:16:40 +00:00
|
|
|
std::vector<IProperty *> m_properties;
|
2018-12-13 22:12:04 +00:00
|
|
|
std::unordered_map<std::string, IProperty *> m_property_name_lookup;
|
|
|
|
std::unordered_map<hash_t, IProperty *> m_property_hash_lookup;
|
2018-12-09 23:21:22 +00:00
|
|
|
|
|
|
|
void add_property(IProperty &prop);
|
2018-11-16 15:02:43 +00:00
|
|
|
};
|
|
|
|
}
|
|
|
|
}
|