Skip to content
Snippets Groups Projects
Select Git revision
  • b1cbee37fd5a40ab750856d20326eb4421f1bb3b
  • develop default protected
  • feature/variational-hydro
  • origin/stage/bouguettaia
  • feature/gmsh-reader
  • feature/reconstruction
  • save_clemence
  • feature/kinetic-schemes
  • feature/local-dt-fsi
  • feature/composite-scheme-sources
  • feature/composite-scheme-other-fluxes
  • feature/serraille
  • feature/composite-scheme
  • hyperplastic
  • feature/polynomials
  • feature/gks
  • feature/implicit-solver-o2
  • feature/coupling_module
  • feature/implicit-solver
  • feature/merge-local-dt-fsi
  • master protected
  • v0.5.0 protected
  • v0.4.1 protected
  • v0.4.0 protected
  • v0.3.0 protected
  • v0.2.0 protected
  • v0.1.0 protected
  • Kidder
  • v0.0.4 protected
  • v0.0.3 protected
  • v0.0.2 protected
  • v0 protected
  • v0.0.1 protected
33 results

ItemId.hpp

Blame
  • ItemId.hpp 1.79 KiB
    #ifndef ITEM_ID_HPP
    #define ITEM_ID_HPP
    
    #include <PastisMacros.hpp>
    #include <ItemType.hpp>
    
    template <ItemType item_type>
    class ItemIdT
    {
     public:
      using base_type = unsigned int;
    
     private:
      base_type m_id;
    
     public:
      PASTIS_INLINE
      constexpr operator const base_type&() const
      {
        return m_id;
      }
    
      PASTIS_INLINE
      constexpr ItemIdT operator++(int)
      {
        ItemIdT item_id(m_id);
        ++m_id;
        return std::move(item_id);
      }
    
      PASTIS_INLINE
      constexpr ItemIdT& operator++()
      {
        ++m_id;
        return *this;
      }
    
      PASTIS_INLINE
      constexpr ItemIdT& operator=(const base_type& id)
      {
        m_id = id;
        return *this;
      }
    
      PASTIS_INLINE
      constexpr ItemIdT& operator=(const ItemIdT&) = default;
    
      PASTIS_INLINE
      constexpr ItemIdT& operator=(ItemIdT&&) = default;
    
      PASTIS_INLINE
      constexpr ItemIdT(const base_type& id) : m_id{id}{}
    
      PASTIS_INLINE
      constexpr ItemIdT(const ItemIdT&) = default;
    
      PASTIS_INLINE
      constexpr ItemIdT(ItemIdT&&) = default;
    
      PASTIS_INLINE
      constexpr ItemIdT() = default;
    
      PASTIS_INLINE
      ~ItemIdT() = default;
    
      // forbidden rules
      template <ItemType other_item_type>
      ItemIdT(const ItemIdT<other_item_type>&)
      {
        static_assert(other_item_type == item_type,
                      "wrong type of item");
      }
    
      template <ItemType other_item_type>
      ItemIdT& operator=(const ItemIdT<other_item_type>&)
      {
        static_assert(other_item_type == item_type,
                      "wrong type of item");
      }
    
    
      template <ItemType other_item_type>
      ItemIdT& operator=(ItemIdT<other_item_type>&&)
      {
        static_assert(other_item_type == item_type,
                      "wrong type of item");
      }
    };
    
    using NodeId = ItemIdT<ItemType::node>;
    using EdgeId = ItemIdT<ItemType::edge>;
    using FaceId = ItemIdT<ItemType::face>;
    using CellId = ItemIdT<ItemType::cell>;
    
    #endif // ITEM_ID_HPP