section_base.h
1 #pragma once
2 
3 #include <cstdint> // uint32_t
4 #include <memory> // std::shared_ptr
5 #include <vector> // std::vector
6 
7 #include <morphio/morphology.h>
8 #include <morphio/properties.h>
9 #include <morphio/types.h>
10 
11 namespace morphio {
23 template <typename T>
25 {
26  public:
27  SectionBase()
28  : _id(0) {}
29 
30  SectionBase(const SectionBase& section);
31 
32  SectionBase& operator=(const SectionBase& other);
33 
34  inline bool operator==(const SectionBase& other) const noexcept;
35  inline bool operator!=(const SectionBase& other) const noexcept;
36 
40  bool isRoot() const;
41 
47  T parent() const;
48 
52  std::vector<T> children() const;
53 
55  inline uint32_t id() const noexcept;
56 
57  protected:
58  SectionBase(uint32_t id, const std::shared_ptr<Property::Properties>& properties);
59  template <typename Property>
60  range<const typename Property::Type> get() const;
61 
62  uint32_t _id;
63  SectionRange _range;
64  std::shared_ptr<Property::Properties> _properties;
65 };
66 
67 template <typename T>
68 inline bool SectionBase<T>::operator==(const SectionBase& other) const noexcept {
69  return other._id == _id && other._properties == _properties;
70 }
71 
72 template <typename T>
73 inline bool SectionBase<T>::operator!=(const SectionBase& other) const noexcept {
74  return !(*this == other);
75 }
76 
77 template <typename T>
78 inline uint32_t SectionBase<T>::id() const noexcept {
79  return _id;
80 }
81 
82 } // namespace morphio
83 
84 std::ostream& operator<<(std::ostream& os, const morphio::Section& section);
85 std::ostream& operator<<(std::ostream& os, const morphio::range<const morphio::Point>& points);
86 
87 #include "section_base.tpp"
std::vector< T > children() const
Definition: endoplasmic_reticulum.h:5
uint32_t id() const noexcept
Definition: section_base.h:78
bool isRoot() const
Definition: section_base.h:24
Definition: section.h:36