AGX Dynamics  2.38.0.2
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 #pragma once
17 
19 #include <agxPowerLine/Unit.h>
20 
21 
23 
24 
25 template<typename T>
27  m_source(dimension), m_side(s_firstSearchSide), m_index(0)
28 {
29  this->scanForNonNull();
30 }
31 
32 
33 template<typename T>
35 {
36  if (!this->isValid())
37  return 0;
38 
39  return this->getConnection();
40 }
41 
42 
43 template<typename T>
45 {
46  if (!this->isValid())
47  return *this;
48 
49  ++m_index;
50  this->scanForNonNull();
51 
52  return *this;
53 }
54 
55 
56 template<typename T>
58 {
59  return m_source != 0 &&
60  m_side != agxPowerLine::Side::NO_SIDE &&
61  m_index != agx::InvalidIndex;
62 }
63 
64 
65 template<typename T>
67 {
69 }
70 
71 
72 template<typename T>
74 {
75  return this->getConnections()[m_index];
76 }
77 
78 
79 template<typename T>
81 {
82  ConnectionPtr connection = this->getConnection();
83  if (connection == 0)
84  return false;
85 
86  return detail::ConnectionIteratorTypes<T>::getTarget(connection) != 0;
87 }
88 
89 
90 template<typename T>
92 {
93  return this->getConnections().size();
94 }
95 
96 
97 template<typename T>
99 {
100  this->scanConnectionsForNonNull();
101  if (m_index == agx::InvalidIndex && m_side == s_firstSearchSide) {
102  m_side = agxPowerLine::opposite(m_side);
103  m_index = 0;
104  this->scanConnectionsForNonNull();
105  }
106  if (m_index == agx::InvalidIndex) {
107  this->invalidate();
108  }
109 }
110 
111 
112 template<typename T>
114 {
115  for (; m_index < this->getNumConnections(); ++m_index) {
116  if (this->isConnectionValid()) {
117  return;
118  }
119  }
120  m_index = agx::InvalidIndex;
121 }
122 
123 
124 template<typename T>
126 {
127  m_source = 0;
129  m_index = agx::InvalidIndex;
130 }
agxPowerLine::detail::ConnectionIteratorOperations::getConnections
static const ConnectionRefVector & getConnections(SourcePtr source, Side side)
Definition: ConnectionIteratorTraits.h:109
agxPowerLine::opposite
AGXMODEL_EXPORT agxPowerLine::Side opposite(agxPowerLine::Side side)
agxPowerLine::Side
Side
Definition: Sides.h:28
agx::Vector< ConnectionRef >
Unit.h
agxPowerLine::ConnectionIterator::operator++
ConnectionIterator & operator++()
Definition: ConnectionIteratorImpl.h:44
agxPowerLine::ConnectionIterator::ConnectionPtr
detail::ConnectionIteratorTypes< T >::ConnectionPtr ConnectionPtr
Definition: ConnectionIterator.h:42
agxPowerLine::ConnectionIterator::operator*
ConnectionPtr operator*()
Definition: ConnectionIteratorImpl.h:34
agxPowerLine::ConnectionIterator::ConnectionIterator
ConnectionIterator(SourcePtr dimension)
Definition: ConnectionIteratorImpl.h:26
ConnectionIterator.h
agxPowerLine::NO_SIDE
@ NO_SIDE
Definition: Sides.h:32
agxPowerLine::ConnectionPtr
Connection * ConnectionPtr
Definition: PhysicalDimension.h:71
AGXMODEL_EXPORT
#define AGXMODEL_EXPORT
Definition: agxModel/export.h:42
agxPowerLine::ConnectionIterator
Iterator that iterates over all, both input and output, connections that have a non-null Connector.
Definition: ConnectionIterator.h:38
agx::InvalidIndex
const AGXCORE_EXPORT InvalidIndexStruct InvalidIndex
agxPowerLine::ConnectionIterator::SourcePtr
detail::ConnectionIteratorTypes< T >::SourcePtr SourcePtr
Definition: ConnectionIterator.h:41
agxPowerLine::ConnectionIterator::isValid
bool isValid() const
Definition: ConnectionIteratorImpl.h:57
s_firstSearchSide
const AGXMODEL_EXPORT agxPowerLine::Side s_firstSearchSide