19#ifndef HEDGEHOG_CX_PROPERTY_MAP_H_ 
   20#define HEDGEHOG_CX_PROPERTY_MAP_H_ 
   37template<
class PropertyType>
 
   40  static_assert(std::is_default_constructible_v<PropertyType>, 
"The property mapped should be default constructible.");
 
   41  std::vector<std::string>
 
   43  std::vector<PropertyType>
 
   48  constexpr PropertyMap() = 
default;
 
   51  constexpr void clear() {
 
   60  constexpr void insert(std::string 
const &staticNodeName, PropertyType 
const &property) {
 
   61    if (std::find(ids_.cbegin(), ids_.cend(), staticNodeName) != ids_.cend()) {
 
   62      throw std::runtime_error(
"The node has already been inserted.");
 
   64      ids_.push_back(staticNodeName);
 
   65      properties_.push_back(property);
 
   72  constexpr void insert_or_assign(std::string 
const &staticNodeName, PropertyType 
const &property) {
 
   73    auto posIt = std::find(ids_.cbegin(), ids_.cend(), staticNodeName);
 
   74    if (posIt != ids_.cend()) {
 
   75      properties_.at(std::distance(ids_.cbegin(), posIt)) = property;
 
   77      ids_.push_back(staticNodeName);
 
   78      properties_.push_back(property);
 
   84  constexpr void erase(std::string 
const &staticNodeName) {
 
   85    auto posIt = std::find(ids_.cbegin(), ids_.cend(), staticNodeName);
 
   86    if (posIt != ids_.cend()) {
 
   87      for(
auto pos = std::distance(ids_.cbegin(), posIt); pos < ids_.size() - 1; ++pos){
 
   88        ids_.at(pos) = ids_.at(pos + 1);
 
   89        properties_.at(pos) = properties_.at(pos + 1);
 
   91        properties_.pop_back();
 
   99  [[nodiscard]] 
constexpr bool contains(std::string 
const &staticNodeName){
 
  100    return std::find(ids_.cbegin(), ids_.cend(), staticNodeName) != ids_.cend();
 
  107  [[nodiscard]] 
constexpr PropertyType & property(std::string 
const &staticNodeName){
 
  108    if(contains(staticNodeName)){
 
  109      return properties_.at(std::distance(ids_.cbegin(), std::find(ids_.cbegin(), ids_.cend(), staticNodeName)));
 
  111      throw std::runtime_error(
"You are looking for hedgehog property associated to an unregistered node.");