- void setCallingContainer(Container* container) { issuer_ = container; }
-
- void logDefinition(e_event_type event_type);
- void logDefinition(Type* source, Type* dest);
+public:
+ static void on_creation_cb(const std::function<void(Type const&, PajeEventType event_type)>& cb)
+ {
+ on_creation.connect(cb);
+ }
+
+ Type(PajeEventType event_type, const std::string& name, const std::string& alias, const std::string& color,
+ Type* parent);
+ virtual ~Type() = default;
+
+ long long int get_id() const { return id_; }
+ const std::string& get_name() const { return name_; }
+ const char* get_cname() const { return name_.c_str(); }
+ const std::string& get_color() const { return color_; }
+ Type* get_parent() const { return parent_; }
+ const std::map<std::string, std::unique_ptr<Type>, std::less<>>& get_children() const { return children_; }
+ bool is_colored() const { return not color_.empty(); }
+
+ Type* by_name(const std::string& name);
+ LinkType* by_name_or_create(const std::string& name, const Type* source, const Type* dest);
+ VariableType* by_name_or_create(const std::string& name, const std::string& color);
+
+ template <class T> T* by_name_or_create(const std::string& name)
+ {
+ auto cont = children_.find(name);
+ return cont == children_.end() ? new T(name, this) : static_cast<T*>(cont->second.get());
+ }
+
+ Type* set_calling_container(Container* container)
+ {
+ issuer_ = container;
+ return this;
+ }