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-11-16 15:02:43 +00:00
|
|
|
class PropertyBase;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* 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:
|
|
|
|
PropertyBase &operator*() const;
|
|
|
|
PropertyBase *operator->() const;
|
|
|
|
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:
|
|
|
|
const PropertyBase &operator*() const;
|
|
|
|
const PropertyBase *operator->() const;
|
|
|
|
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-11-27 11:51:56 +00:00
|
|
|
PropertyBase &get_property(int index);
|
2018-11-16 15:02:43 +00:00
|
|
|
const PropertyBase &get_property(int index) const;
|
2018-11-27 11:51:56 +00:00
|
|
|
|
|
|
|
PropertyBase &get_property(const std::string &name);
|
2018-11-16 15:02:43 +00:00
|
|
|
const PropertyBase &get_property(const std::string &name) const;
|
2018-11-27 11:51:56 +00:00
|
|
|
|
|
|
|
PropertyBase &get_property(hash_t hash);
|
2018-11-16 15:02:43 +00:00
|
|
|
const PropertyBase &get_property(hash_t hash) const;
|
|
|
|
|
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-11-27 11:51:56 +00:00
|
|
|
void add_property(PropertyBase &prop);
|
2018-11-16 15:02:43 +00:00
|
|
|
|
|
|
|
private:
|
|
|
|
std::vector<PropertyBase *> m_properties;
|
|
|
|
std::map<std::string, PropertyBase *> m_property_name_lookup;
|
|
|
|
std::map<hash_t, PropertyBase *> m_property_hash_lookup;
|
|
|
|
};
|
|
|
|
}
|
|
|
|
}
|