AGXDynamics  2.35.0.3
ConnectionIteratorTraits.h
Go to the documentation of this file.
1 /*
2 Copyright 2007-2022. 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
agxPowerLine::detail::ConnectionIteratorOperations::getConnections
static const ConnectionRefVector & getConnections(SourcePtr source, Side side)
Definition: ConnectionIteratorTraits.h:111
agxPowerLine::detail::ConnectionIteratorTypes< const PhysicalDimension * >::SourcePtr
const typedef PhysicalDimension * SourcePtr
Definition: ConnectionIteratorTraits.h:57
agxPowerLine::detail::ConnectionIteratorTypes< const PhysicalDimension * >::SideType
Side SideType
Definition: ConnectionIteratorTraits.h:60
agxPowerLine::Side
Side
Definition: Sides.h:30
agx::Vector< ConnectionRef >
agxPowerLine::detail::ConnectionIteratorTypes< PhysicalDimension * >::getTarget
static TargetPtr getTarget(ConnectionPtr connection)
Definition: ConnectionIteratorTraits.h:46
agxPowerLine::detail::ConnectionIteratorTypes< PhysicalDimension * >::TargetPtr
Connector * TargetPtr
Definition: ConnectionIteratorTraits.h:43
agxPowerLine::detail::ConnectionIteratorTypes< const PhysicalDimension * >::TargetPtr
const typedef Connector * TargetPtr
Definition: ConnectionIteratorTraits.h:59
agxPowerLine::detail::ConnectionIteratorTypes< Connector * >::SourcePtr
Connector * SourcePtr
Definition: ConnectionIteratorTraits.h:72
agxPowerLine::detail::ConnectionIteratorTypes< const Connector * >::SideType
Side SideType
Definition: ConnectionIteratorTraits.h:91
agxPowerLine::PhysicalDimension
Pure virtual class.
Definition: PhysicalDimension.h:93
agxPowerLine::detail::ConnectionIteratorOperations::TargetPtr
ConnectionIteratorTypes< T >::TargetPtr TargetPtr
Definition: ConnectionIteratorTraits.h:108
agxPowerLine::detail::ConnectionIteratorTypes< const PhysicalDimension * >::getTarget
static TargetPtr getTarget(ConnectionPtr connection)
Definition: ConnectionIteratorTraits.h:62
agxPowerLine::detail::ConnectionIteratorTypes< Connector * >::ConnectionPtr
Connection * ConnectionPtr
Definition: ConnectionIteratorTraits.h:73
agxPowerLine::detail::ConnectionIteratorTypes< Connector * >::SideType
Side SideType
Definition: ConnectionIteratorTraits.h:75
agxPowerLine::detail::ConnectionIteratorTypes< PhysicalDimension * >::SourcePtr
PhysicalDimension * SourcePtr
Definition: ConnectionIteratorTraits.h:41
agxPowerLine::detail::ConnectionIteratorTypes< Connector * >::getTarget
static TargetPtr getTarget(ConnectionPtr connection)
Definition: ConnectionIteratorTraits.h:77
agxPowerLine::detail::ConnectionIteratorTypes< const Connector * >::SourcePtr
const typedef Connector * SourcePtr
Definition: ConnectionIteratorTraits.h:88
agxPowerLine::detail::ConnectionIteratorTypes< const Connector * >::ConnectionPtr
const typedef Connection * ConnectionPtr
Definition: ConnectionIteratorTraits.h:89
agxPowerLine::detail::ConnectionIteratorTypes< PhysicalDimension * >::ConnectionPtr
Connection * ConnectionPtr
Definition: ConnectionIteratorTraits.h:42
agxPowerLine::detail::ConnectionIteratorOperations::isConnectionValid
static bool isConnectionValid(SourcePtr source, Side side, size_t index)
Definition: ConnectionIteratorTraits.h:126
agxPowerLine::detail::ConnectionIteratorOperations::getConnection
static ConnectionPtr getConnection(SourcePtr source, Side side, size_t index)
Definition: ConnectionIteratorTraits.h:116
agxPowerLine::detail::ConnectionIteratorTypes< Connector * >::TargetPtr
PhysicalDimension * TargetPtr
Definition: ConnectionIteratorTraits.h:74
Connector.h
agxPowerLine::detail::ConnectionIteratorTypes< const Connector * >::TargetPtr
const typedef PhysicalDimension * TargetPtr
Definition: ConnectionIteratorTraits.h:90
agxPowerLine::detail::ConnectionIteratorTypes< const Connector * >::getTarget
static TargetPtr getTarget(ConnectionPtr connection)
Definition: ConnectionIteratorTraits.h:93
agxPowerLine::detail::ConnectionIteratorOperations::SourcePtr
ConnectionIteratorTypes< T >::SourcePtr SourcePtr
Definition: ConnectionIteratorTraits.h:106
agxPowerLine::detail::ConnectionIteratorOperations::ConnectionPtr
ConnectionIteratorTypes< T >::ConnectionPtr ConnectionPtr
Definition: ConnectionIteratorTraits.h:107
agxPowerLine
agxPowerLine contains a collection of connected components that transport power across a system.
Definition: MotorUnit.h:23
agxPowerLine::Connector
Links two connections together.
Definition: Connector.h:53
agxPowerLine::Connection::getConnector
const agxPowerLine::Connector * getConnector() const
agxPowerLine::detail::ConnectionIteratorOperations
Definition: ConnectionIteratorTraits.h:103
Sides.h
agxPowerLine::Connection
Definition: PowerLineUtils.h:258
agxPowerLine::detail::ConnectionIteratorOperations::getTarget
static TargetPtr getTarget(ConnectionPtr connection)
Definition: ConnectionIteratorTraits.h:121
agxPowerLine::detail::ConnectionIteratorTypes
Definition: ConnectionIteratorTraits.h:32
agxPowerLine::Connection::getDimension
const agxPowerLine::PhysicalDimension * getDimension() const
agxPowerLine::detail::ConnectionIteratorTypes< const PhysicalDimension * >::ConnectionPtr
const typedef Connection * ConnectionPtr
Definition: ConnectionIteratorTraits.h:58
agxPowerLine::detail::ConnectionIteratorTypes< PhysicalDimension * >::SideType
Side SideType
Definition: ConnectionIteratorTraits.h:44
agxPowerLine::detail::ConnectionIteratorOperations::SideType
ConnectionIteratorTypes< T >::SideType SideType
Definition: ConnectionIteratorTraits.h:109
PhysicalDimension.h