2018-11-16 15:02:43 +00:00
|
|
|
#pragma once
|
|
|
|
#include <map>
|
|
|
|
#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;
|
|
|
|
|
|
|
|
explicit iterator(PropertyList &list, const int index = 0);
|
|
|
|
};
|
|
|
|
|
|
|
|
/**
|
|
|
|
* 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;
|
|
|
|
|
|
|
|
explicit const_iterator(const PropertyList &list, const int index = 0);
|
|
|
|
};
|
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;
|
|
|
|
|
|
|
|
protected:
|
2018-12-01 17:16:40 +00:00
|
|
|
void add_property(IProperty &prop);
|
2018-11-16 15:02:43 +00:00
|
|
|
|
|
|
|
private:
|
2018-12-01 17:16:40 +00:00
|
|
|
std::vector<IProperty *> m_properties;
|
|
|
|
std::map<std::string, IProperty *> m_property_name_lookup;
|
|
|
|
std::map<hash_t, IProperty *> m_property_hash_lookup;
|
2018-11-16 15:02:43 +00:00
|
|
|
};
|
|
|
|
}
|
|
|
|
}
|