Trax3 3.1.0
trax track library
Loading...
Searching...
No Matches
trax::Switch Struct Referenceabstract

A Switch rearranges the connections between three track ends. More...

#include <C:/Trend/Development/Trax3/Code/trax/Switch.h>

Inheritance diagram for trax::Switch:

Public Member Functions

virtual void DivergedTrack (std::shared_ptr< TrackBuilder > pDivergedTrack, Track::EndType trackEnd)=0
 Occupies the slot for the diverged track.
virtual std::pair< std::shared_ptr< TrackBuilder >, Track::EndTypeDivergedTrack () const =0
virtual void ClearDivergedTrack ()=0
 Clears the slot for the diverged track.
virtual void SwapTracks ()=0
 Swaps the straight and the diverged track.
virtual bool IsNormal (bool bStopAtFirstTrack=true, Length maxDistance=infinite__length) const =0
 Returns true, if the straight track has fewer deviation from the narrow's track direction than the diverged track.
virtual bool Normalize ()=0
 Swaps the outgoing tracks if this switch is not normal.
virtual bool IsY (bool bStopAtFirstTrack=true, Length maxDistance=infinite__length, AnglePerLength margin=epsilon__angle/80_m) const =0
 Is this an Y - switch?
virtual bool IsHorizontal (bool bStopAtFirstTrack=true, Length maxDistance=infinite__length) const =0
virtual bool IsVertical (bool bStopAtFirstTrack=true, Length maxDistance=infinite__length) const =0
virtual bool BranchLeftOrRight (bool bStopAtFirstTrack=true, Length maxDistance=infinite__length) const =0
 Tests wether the branching track develops to the left or right side of the straight track.
virtual bool BranchUpOrDown (bool bStopAtFirstTrack=true, Length maxDistance=infinite__length) const =0
 Tests wether the branching track develops to the up or down side of the straight track.
virtual JackJackOnBranch () noexcept=0
 Gets a Jack that pulses its Plug if the switch is set to branch.
virtual MultiPlugPlugToBranch () noexcept=0
 Gets a Plug that sets the switch to branch.
virtual void DivergedTrack (int divTrackID, std::shared_ptr< TrackBuilder > pDivergedTrack, Track::EndType trackEnd)=0
 Occupies the slot for the diverging track.
virtual std::pair< std::shared_ptr< TrackBuilder >, Track::EndTypeDivergedTrack (int divTrackID) const=0
virtual void ClearDivergedTrack (int divTrackID)=0
 Clears the slot for the straight track.
Public Member Functions inherited from trax::NarrowSwitch
virtual Status Set (Status to, bool pulse=true)=0
 Turns the switch to the specified setting.
virtual Status Get () const =0
 Gets the setting of the switch.
virtual void NarrowTrack (std::shared_ptr< TrackBuilder > pNarrowTrack, Track::EndType trackEnd)=0
 Occupies the slot for the narrow track.
virtual std::pair< std::shared_ptr< TrackBuilder >, Track::EndTypeNarrowTrack () const =0
virtual void ClearNarrowTrack ()=0
 Clears the slot for the narrow track.
virtual void StraightTrack (std::shared_ptr< TrackBuilder > pStaightTrack, Track::EndType trackEnd)=0
 Occupies the slot for the straight track.
virtual std::pair< std::shared_ptr< TrackBuilder >, Track::EndTypeStraightTrack () const =0
virtual void ClearStraightTrack ()=0
 Clears the slot for the straight track.
virtual int CntDivergedTracks () const =0
virtual Location Bifurcation () const =0
 Gets a track Location object right at the bifurcation point of the switch with a foreward direction aiming towards the branching tracks.
virtual JackJackOnGo () noexcept=0
 Gets a Jack that pulses its Plug if the switch is set to go.
virtual MultiPlugPlugToGo () noexcept=0
 Gets a Plug that sets the switch to go.
virtual JackJackOn (Status status)=0
 Gets a Jack that pulses its Plug if the specified Status is set.
virtual MultiPlugPlugTo (Status status)=0
 Gets a Plug that switches to the specified Status.
virtual JackJackOnDivergedTrack (int divTrackID)=0
 Gets a Jack that pulses its Plug if the switch is set to the branching track.
virtual MultiPlugPlugToDivergedTrack (int divTrackID)=0
 Gets a Plug that sets the switch to the outgoing track.
virtual void Set (const Track &trackA, Track::EndType trackendA, const Track &trackB, Track::EndType trackendB, bool pulse=true)=0
 Sets the Connector to the setting that connects the two track ends.
Public Member Functions inherited from trax::Connector
virtual ConnectorType GetConnectorType () const noexcept=0
virtual const char * TypeName () const noexcept=0
virtual bool IsValid () const noexcept=0
 Checks whether the connector is valid.
virtual void Toggle (bool pulse=true)=0
 Sets the connector to the next setting.
virtual void Disconnect ()=0
 Disconnects all track ends from each other.
virtual std::pair< std::shared_ptr< TrackBuilder >, Track::EndTypeSlot (int slot) const noexcept=0
virtual int Slot (const Track &track, Track::EndType trackend) const =0
virtual int CntSlots () const noexcept=0
virtual void SwapSlots (int slotA, int slotB)=0
 Exchanges the content of the two slots.
virtual bool IsComplete () const =0
virtual bool Check (std::ostream &os, Length e_distance=epsilon__length, Angle e_kink=epsilon__angle, Angle e_twist=epsilon__angle) const noexcept=0
 Checks the connector for consistency.
virtual void Clear (int slot)=0
 clears the slot with index slot.
virtual void Clear ()=0
 Releases all the tracks from the slots.
virtual void GetCenter (spat::Frame< Length, One > &center) const =0
 Gets the center of the tracks the connector is connecting.
virtual MultiPlugPlugToToggle () noexcept=0
virtual const MultiPlugPlugToToggle () const noexcept=0
virtual JackJackOnChange () noexcept=0
virtual const JackJackOnChange () const noexcept=0
virtual void RegisterSockets (SocketRegistry &modul)=0
 Registers all the Plugs with the module and supplies the Jacks with plug ids for connecting.
virtual void UnregisterSockets (SocketRegistry &modul)=0
 Removes all references to Plugs and Jacks from the module.
virtual void UserData (ConnectorUserData *pData) noexcept=0
 Sets a pointer to user provided data.
virtual ConnectorUserData * UserData () const noexcept=0
virtual int Slot (int slot, std::shared_ptr< TrackBuilder > pTrack, Track::EndType trackend, bool connectAnonymous=false)=0
 Populates a slot with a tracks end.
virtual int Slot (std::shared_ptr< TrackBuilder > pTrack, Track::EndType trackend, bool connectAnonymous=false)=0
 Populates the slot with the smallest ID that is still unpopulated.
Public Member Functions inherited from trax::Identified< Connector >
virtual const std::string & Reference (const std::string &name) const=0
 Gets a reference that was set for this object by name.
virtual const std::vector< char const * > & ReferenceNames (const std::string &namePart) const=0
 Searches for all reference names that countain namePart as substring in the name.
virtual IDType ID () const noexcept=0
 Identified (const Identified &)=delete
Identified & operator= (const Identified &)=delete

Static Public Member Functions

static dclspc std::unique_ptr< SwitchMake () noexcept
 Makes a standard Switch object.
Static Public Member Functions inherited from trax::NarrowSwitch
static dclspc std::unique_ptr< NarrowSwitchMake (unsigned char numBranches) noexcept
 Makes a standard NarrowSwitch object.

Static Public Attributes

static constexpr char slot_count = 3
static constexpr char status_count = 2
static constexpr char branch_count = 1

Additional Inherited Members

Public Types inherited from trax::NarrowSwitch
enum  SlotNames : char {
  slot_none = -1 , slot_0 = 0 , slot_1 , slot_2 ,
  slot_3 , slot_4 , slot_5 , slot_N = 125 ,
  maxSlots
}
enum class  Status : char {
  none = -1 , go , branch = 1 , branch1 = 1 ,
  branch2 = 2 , branch3 = 3 , branch4 = 4 , bramch5 = 5 ,
  branchN = 124 , maxBranches = 124 , toggle , change ,
  empty
}
 Status. More...

Detailed Description

A Switch rearranges the connections between three track ends.

Tracks only have one connection at each end. A switch will reconnect these connections according to its setting.

Member Function Documentation

◆ BranchLeftOrRight()

virtual bool trax::Switch::BranchLeftOrRight ( bool bStopAtFirstTrack = true,
Length maxDistance = infinite__length ) const
pure virtual

Tests wether the branching track develops to the left or right side of the straight track.

The test is done by the track locations at the minimum length of both outgoing tracks. The directions are understood in terms of the frame at the bifurcation: branching left would mean that the branch end develops to the positive N direction of that frame more or equally as the straight track does.

Parameters
bStopAtFirstTrackIf true the test will be done on the shorter length of the two outgoing tracks, if maxDistance doesn't provide a narrower limit. Limit the maxDistance carefully if you set bStopAtFirstTrack to false.
maxDistanceMaximum distance along the outgoing tracks to look for comparison points. If there is an open end that would define the maximum distance.
Returns
true if the branch develops to the left, false if to the right. If there is no difference, the method returns true.

◆ BranchUpOrDown()

virtual bool trax::Switch::BranchUpOrDown ( bool bStopAtFirstTrack = true,
Length maxDistance = infinite__length ) const
pure virtual

Tests wether the branching track develops to the up or down side of the straight track.

The test is done by the track locations at the minimum length of both outgoing tracks. The directions are understood in terms of the frame at the bifurcation: branching up would mean that the branch end develops to the positive B direction of that frame more or equally as the straight track does.

Parameters
bStopAtFirstTrackIf true the test will be done on the shorter length of the two outgoing tracks, if maxDistance doesn't provide a narrower limit. Limit the maxDistance carefully if you set bStopAtFirstTrack to false.
maxDistanceMaximum distance along the outgoing tracks to look for comparison points. If there is an open end that would define the maximum distance.
Returns
true if the branch develops to the up, false if to the down. If there is no difference, the method returns true.

◆ ClearDivergedTrack()

virtual void trax::NarrowSwitch::ClearDivergedTrack ( int divTrackID)
virtual

Clears the slot for the straight track.

Implements trax::NarrowSwitch.

◆ DivergedTrack() [1/4]

virtual std::pair< std::shared_ptr< TrackBuilder >, Track::EndType > trax::Switch::DivergedTrack ( ) const
pure virtual
Returns
the track and the end type in the diverged slot.

◆ DivergedTrack() [2/4]

virtual std::pair< std::shared_ptr< TrackBuilder >, Track::EndType > trax::NarrowSwitch::DivergedTrack ( int divTrackID) const
virtual
Returns
the track and the end type in the straight slot.

Implements trax::NarrowSwitch.

◆ DivergedTrack() [3/4]

virtual void trax::NarrowSwitch::DivergedTrack ( int divTrackID,
std::shared_ptr< TrackBuilder > pDivergedTrack,
Track::EndType trackEnd )
virtual

Occupies the slot for the diverging track.

The diverging track is the branching track of a switch.

Parameters
divTrackIDzero based id of the diverging track to set.
pDivergedTrackShared pointer to track.
trackEndEnd of track to connect.

Implements trax::NarrowSwitch.

◆ DivergedTrack() [4/4]

virtual void trax::Switch::DivergedTrack ( std::shared_ptr< TrackBuilder > pDivergedTrack,
Track::EndType trackEnd )
pure virtual

Occupies the slot for the diverged track.

The diverged track is the branching track of a switch.

Parameters
pDivergedTrackShared pointer to track.
trackEndEnd of track to connect.

◆ IsHorizontal()

virtual bool trax::Switch::IsHorizontal ( bool bStopAtFirstTrack = true,
Length maxDistance = infinite__length ) const
pure virtual
Parameters
bStopAtFirstTrackIf true the test will be done on the shorter length of the two outgoing tracks, if maxDistance doesn't provide a narrower limit. Limit the maxDistance carefully if you set bStopAtFirstTrack to false.
maxDistanceMaximum distance along the outgoing tracks to look for comparison points. If there is an open end that would define the maximum distance.
Returns
true if the branch develops horizontally more than vertically.
See also
BranchLeftOrRight

◆ IsNormal()

virtual bool trax::Switch::IsNormal ( bool bStopAtFirstTrack = true,
Length maxDistance = infinite__length ) const
pure virtual

Returns true, if the straight track has fewer deviation from the narrow's track direction than the diverged track.

This property should typically be assigned with the straight track. Use SwapTracks() to make a switch normal. The test is done by the track locations at the minimum length of both outgoing tracks if bStopAtFirstTrack is true, only limited by maxDistance.

Parameters
bStopAtFirstTrackIf true the test will be done on the shorter length of the two outgoing tracks, if maxDistance doesn't provide a narrower limit. Limit the maxDistance carefully if you set bStopAtFirstTrack to false.
maxDistanceMaximum distance along the outgoing tracks to look for comparison points. If there is an open end that would define the maximum distance.
Returns
true if the switch is normal.
Exceptions
std::invalid_argumentif bStopAtFirstTrack == false and maxDistance == infinite_length.

◆ IsVertical()

virtual bool trax::Switch::IsVertical ( bool bStopAtFirstTrack = true,
Length maxDistance = infinite__length ) const
pure virtual
Parameters
bStopAtFirstTrackIf true the test will be done on the shorter length of the two outgoing tracks, if maxDistance doesn't provide a narrower limit. Limit the maxDistance carefully if you set bStopAtFirstTrack to false.
maxDistanceMaximum distance along the outgoing tracks to look for comparison points. If there is an open end that would define the maximum distance.
Returns
true if the branch develops vertically more than horizontally.
See also
BranchUpOrDown

◆ IsY()

virtual bool trax::Switch::IsY ( bool bStopAtFirstTrack = true,
Length maxDistance = infinite__length,
AnglePerLength margin = epsilon__angle/80_m ) const
pure virtual

Is this an Y - switch?

An Y - switch is a switch with its straight and diverged tracks going in opposite directions with respect to the narrow track's direction. The test is done by the track locations at the minimum length of both outgoing tracks if bStopAtFirstTrack is true, only limited by maxDistance. There is a margin that qualifies a track for diverting from the 'straight direction': if it just does so by a smaller or equal angle than margin, it would be considered to be straight and the switch would not qualify for being an Y-switch.

Parameters
bStopAtFirstTrackIf true the test will be done on the shorter length of the two outgoing tracks, if maxDistance doesn't provide a narrower limit. Limit the maxDistance carefully if you set bStopAtFirstTrack to false.
maxDistanceMaximum distance along the outgoing tracks to look for comparison points. If there is an open end that would define the maximum distance.
marginif the two branches divert to opposite sides but one only be equal or less the deviation given by margin, the switch will not be Y.
Returns
true if the switch qualifies for being an Y-switch.
Exceptions
std::invalid_argumentif bStopAtFirstTrack == false and maxDistance == infinite_length.

◆ Normalize()

virtual bool trax::Switch::Normalize ( )
pure virtual

Swaps the outgoing tracks if this switch is not normal.

Returns
True if the track was normal at in the first palce.

The documentation for this struct was generated from the following file:
  • C:/Trend/Development/Trax3/Code/trax/Switch.h