AGX Dynamics  2.37.2.0
ConnectionIteratorTraits.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_TRAITS_H
19 #define AGXPOWERLINE_CONNECTION_ITERATOR_TRAITS_H
20 
21 #include <agxPowerLine/Sides.h>
23 #include <agxPowerLine/Connector.h>
24 
25 namespace agxPowerLine
26 {
27 
28  namespace detail
29  {
30 
31  template<typename T>
33  {
34  public:
35  };
36 
37  template<>
39  {
40  public:
43  typedef Connector* TargetPtr;
44  typedef Side SideType;
45 
46  static TargetPtr getTarget(ConnectionPtr connection)
47  {
48  return connection->getConnector();
49  }
50  };
51 
52 
53  template<>
55  {
56  public:
57  typedef const PhysicalDimension* SourcePtr;
58  typedef const Connection* ConnectionPtr;
59  typedef const Connector* TargetPtr;
60  typedef Side SideType;
61 
62  static TargetPtr getTarget(ConnectionPtr connection)
63  {
64  return connection->getConnector();
65  }
66  };
67 
68  template<>
70  {
71  public:
72  typedef Connector* SourcePtr;
75  typedef Side SideType;
76 
77  static TargetPtr getTarget(ConnectionPtr connection)
78  {
79  return connection->getDimension();
80  }
81  };
82 
83 
84  template<>
86  {
87  public:
88  typedef const Connector* SourcePtr;
89  typedef const Connection* ConnectionPtr;
90  typedef const PhysicalDimension* TargetPtr;
91  typedef Side SideType;
92 
93  static TargetPtr getTarget(ConnectionPtr connection)
94  {
95  return connection->getDimension();
96  }
97  };
98 
99 
100 
101 
102  template<typename T>
104  {
105  public:
110 
111  static const ConnectionRefVector& getConnections(SourcePtr source, Side side)
112  {
113  return source->getConnections((SideType)side);
114  }
115 
116  static ConnectionPtr getConnection(SourcePtr source, Side side, size_t index)
117  {
118  return getConnections(source, side)[index];
119  }
120 
121  static TargetPtr getTarget(ConnectionPtr connection)
122  {
123  return ConnectionIteratorTypes<T>::getTarget(connection);
124  }
125 
126  static bool isConnectionValid(SourcePtr source, Side side, size_t index)
127  {
128  ConnectionPtr connection = getConnection(source, side, index);
129  return connection != 0 && getTarget(connection) != 0;
130  }
131  };
132 
133  }
134 }
135 
136 
137 #endif
Links two connections together.
Definition: Connector.h:53
static TargetPtr getTarget(ConnectionPtr connection)
ConnectionIteratorTypes< T >::ConnectionPtr ConnectionPtr
ConnectionIteratorTypes< T >::SourcePtr SourcePtr
agxPowerLine contains a collection of connected components that transport power across a system...
Definition: MotorUnit.h:23
const agxPowerLine::PhysicalDimension * getDimension() const
static bool isConnectionValid(SourcePtr source, Side side, size_t index)
static ConnectionPtr getConnection(SourcePtr source, Side side, size_t index)
static const ConnectionRefVector & getConnections(SourcePtr source, Side side)
ConnectionIteratorTypes< T >::TargetPtr TargetPtr
const agxPowerLine::Connector * getConnector() const