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 
60  template <typename Property>
61  range<const typename Property::Type> get() const;
62 
63  uint32_t _id;
64  SectionRange _range;
65  std::shared_ptr<Property::Properties> _properties;
66 };
67 
68 template <typename T>
69 inline bool SectionBase<T>::operator==(const SectionBase& other) const noexcept {
70  return other._id == _id && other._properties == _properties;
71 }
72 
73 template <typename T>
74 inline bool SectionBase<T>::operator!=(const SectionBase& other) const noexcept {
75  return !(*this == other);
76 }
77 
78 template <typename T>
79 inline uint32_t SectionBase<T>::id() const noexcept {
80  return _id;
81 }
82 
83 } // namespace morphio
84 
85 std::ostream& operator<<(std::ostream& os, const morphio::Section& section);
86 std::ostream& operator<<(std::ostream& os, const morphio::range<const morphio::Point>& points);
87 
88 #include "section_base.tpp"
std::vector< T > children() const
Definition: dendritic_spine.h:9
uint32_t id() const noexcept
Definition: section_base.h:79
bool isRoot() const
Definition: section_base.h:24
Definition: section.h:36