Entity.hpp
1 #pragma once
2 #include <score/model/ComponentSerialization.hpp>
3 #include <score/model/EntityBase.hpp>
4 
5 #include <ossia-qt/name_utils.hpp>
6 
7 namespace score
8 {
9 template <typename T, bool Ordered>
10 class EntityMapInserter<score::Entity<T>, Ordered>
11 {
12  void add(EntityMap<T, Ordered>& map, T* obj)
13  {
14  SCORE_ASSERT(obj);
15 
16  std::vector<QString> bros_names;
17  bros_names.reserve(map.size());
18  std::transform(
19  map.begin(), map.end(), std::back_inserter(bros_names),
20  [&](const auto& res) { bros_names.push_back(res.metadata().getName()); });
21 
22  auto new_name = ossia::net::sanitize_name(obj->metadata().getName(), bros_names);
23  obj->metadata().setName(new_name);
24 
25  map.unsafe_map().insert(obj);
26 
27  map.mutable_added(*obj);
28  map.added(*obj);
29 
30  // If there are serialized components, we try to deserialize them
31  score::Components& comps = obj->components();
32  deserializeRemainingComponents(comps, obj);
33  }
34 };
35 }
Base for complex model objects.
Definition: EntityBase.hpp:24
The EntityMap class.
Definition: EntityMap.hpp:36
Definition: EntityMap.hpp:16
Base toolkit upon which the software is built.
Definition: Application.cpp:90
Definition: lib/score/model/Component.hpp:41