Class PropertyContainer

Class Documentation

class PropertyContainer

属性的容器, 可以包含多个容器 提供对属性的添加删除获取等操作

Public Functions

PropertyContainer() = default
inline ~PropertyContainer()
inline PropertyContainer(const PropertyContainer &rhs)
inline PropertyContainer &operator=(const PropertyContainer &rhs)

deep copy

inline std::vector<std::string> properties() const

返回所有属性的名字

inline bool exists(const std::string &name) const
template<typename T>
inline PropertyHandle<T> add(const std::string &name, const T default_value = T())

通过名字和默认值添加一个属性, 如果属性已经存在, 就抛出异常

template<typename T>
inline PropertyHandle<T> get(const std::string &name) const

通过名字查找属性, 如果存在, 就返回该属性的Handle, 如果不存在, 就抛出异常

template<typename T>
inline PropertyHandle<T> get_or_add(const std::string &name, const T default_value = T())

通过名字获取属性, 如果属性不存在, 就用参数给定的名字和默认值添加一个属性, 并返回属性的Handle

template<typename T>
inline void remove(PropertyHandle<T> &handle)

根据属性的Handle删除一个属性

inline void free_memory()

释放内存

inline void clear()

删除所有属性

inline size_t n_properties() const

返回这个容器里有多少个属性

inline size_t size() const

返回每个属性的大小(所有属性都是一样大的)

inline void push_back()

对所有属性添加一个元素

inline void resize(size_t n)

调整所有属性的大小

inline void reserve(size_t n)

为属性预留空间