2022-07-11 00:15:58 -04:00
|
|
|
#ifndef CORE_H
|
|
|
|
#define CORE_H
|
|
|
|
|
2022-07-18 05:12:22 -04:00
|
|
|
#include <algorithm>
|
2022-07-11 00:15:58 -04:00
|
|
|
#include <vector>
|
|
|
|
|
2022-07-11 12:05:28 -04:00
|
|
|
#include "types.h"
|
2022-07-11 00:15:58 -04:00
|
|
|
|
|
|
|
namespace si {
|
|
|
|
|
|
|
|
class Core
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
Core();
|
|
|
|
LIBWEAVER_EXPORT virtual ~Core();
|
|
|
|
|
|
|
|
typedef std::vector<Core*> Children;
|
|
|
|
|
|
|
|
LIBWEAVER_EXPORT Core *GetParent() const { return parent_; }
|
|
|
|
LIBWEAVER_EXPORT const Children &GetChildren() const { return children_; }
|
|
|
|
|
|
|
|
bool FindParent(Core *p) const;
|
|
|
|
|
2022-07-11 17:19:36 -04:00
|
|
|
void AppendChild(Core *Core);
|
|
|
|
bool RemoveChild(Core *Core);
|
|
|
|
void InsertChild(size_t index, Core *Core);
|
|
|
|
Core *RemoveChild(size_t index);
|
|
|
|
|
|
|
|
LIBWEAVER_EXPORT size_t IndexOfChild(Core *Core) const;
|
2022-07-11 00:15:58 -04:00
|
|
|
LIBWEAVER_EXPORT Core *GetChildAt(size_t index) const { return children_.at(index); }
|
|
|
|
LIBWEAVER_EXPORT size_t GetChildCount() const { return children_.size(); }
|
2022-07-11 04:48:20 -04:00
|
|
|
LIBWEAVER_EXPORT bool HasChildren() const { return !children_.empty(); }
|
2022-07-18 05:12:22 -04:00
|
|
|
LIBWEAVER_EXPORT bool ContainsChild(Core *child) const { return std::find(children_.begin(), children_.end(), child) != children_.end(); }
|
2022-07-11 00:15:58 -04:00
|
|
|
|
|
|
|
protected:
|
|
|
|
void DeleteChildren();
|
|
|
|
|
|
|
|
private:
|
|
|
|
// Disable copy
|
|
|
|
Core(const Core& other);
|
|
|
|
Core& operator=(const Core& other);
|
|
|
|
|
|
|
|
Core *parent_;
|
|
|
|
Children children_;
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
#endif // CORE_H
|