AGX Dynamics  2.37.2.0
ConnectionIteratorImpl.h
Go to the documentation of this file.
1 /*
2 Copyright 2007-2024. Algoryx Simulation AB.
3 
4 All AGX source code, intellectual property, documentation, sample code,
5 tutorials, scene files and technical white papers, are copyrighted, proprietary
6 and confidential material of Algoryx Simulation AB. You may not download, read,
7 store, distribute, publish, copy or otherwise disseminate, use or expose this
8 material unless having a written signed agreement with Algoryx Simulation AB, or having been
9 advised so by Algoryx Simulation AB for a time limited evaluation, or having purchased a
10 valid commercial license from Algoryx Simulation AB.
11 
12 Algoryx Simulation AB disclaims all responsibilities for loss or damage caused
13 from using this software, unless otherwise stated in written agreements with
14 Algoryx Simulation AB.
15 */
16 
17 
18 #ifndef AGXPOWERLINE_CONNECTION_ITERATOR_IMPL_H
19 #define AGXPOWERLINE_CONNECTION_ITERATOR_IMPL_H
20 
22 #include <agxPowerLine/Unit.h>
23 
24 
26 
27 
28 template<typename T>
30  m_source(dimension), m_side(s_firstSearchSide), m_index(0)
31 {
32  this->scanForNonNull();
33 }
34 
35 
36 template<typename T>
38 {
39  if (!this->isValid())
40  return 0;
41 
42  return this->getConnection();
43 }
44 
45 
46 template<typename T>
48 {
49  if (!this->isValid())
50  return *this;
51 
52  ++m_index;
53  this->scanForNonNull();
54 
55  return *this;
56 }
57 
58 
59 template<typename T>
61 {
62  return m_source != 0 &&
63  m_side != agxPowerLine::Side::NO_SIDE &&
64  m_index != agx::InvalidIndex;
65 }
66 
67 
68 template<typename T>
70 {
72 }
73 
74 
75 template<typename T>
77 {
78  return this->getConnections()[m_index];
79 }
80 
81 
82 template<typename T>
84 {
85  ConnectionPtr connection = this->getConnection();
86  if (connection == 0)
87  return false;
88 
89  return detail::ConnectionIteratorTypes<T>::getTarget(connection) != 0;
90 }
91 
92 
93 template<typename T>
95 {
96  return this->getConnections().size();
97 }
98 
99 
100 template<typename T>
102 {
103  this->scanConnectionsForNonNull();
104  if (m_index == agx::InvalidIndex && m_side == s_firstSearchSide) {
105  m_side = agxPowerLine::opposite(m_side);
106  m_index = 0;
107  this->scanConnectionsForNonNull();
108  }
109  if (m_index == agx::InvalidIndex) {
110  this->invalidate();
111  }
112 }
113 
114 
115 template<typename T>
117 {
118  for (; m_index < this->getNumConnections(); ++m_index) {
119  if (this->isConnectionValid()) {
120  return;
121  }
122  }
123  m_index = agx::InvalidIndex;
124 }
125 
126 
127 template<typename T>
129 {
130  m_source = 0;
132  m_index = agx::InvalidIndex;
133 }
134 
135 
136 
137 #endif
detail::ConnectionIteratorTypes< T >::SourcePtr SourcePtr
AGXCORE_EXPORT const InvalidIndexStruct InvalidIndex
AGXMODEL_EXPORT const agxPowerLine::Side s_firstSearchSide
detail::ConnectionIteratorTypes< T >::ConnectionPtr ConnectionPtr
size_t size() const
Definition: Container.h:134
static const ConnectionRefVector & getConnections(SourcePtr source, Side side)
#define AGXMODEL_EXPORT
Iterator that iterates over all, both input and output, connections that have a non-null Connector...
AGXMODEL_EXPORT agxPowerLine::Side opposite(agxPowerLine::Side side)