Trax3 3.1.0
trax track library
Loading...
Searching...
No Matches
Connector.h
1// trax track library
2// AD 2014
3//
4// "Hold up that light
5// I'm lost at sea
6// But I'm coming way home"
7//
8// Arkells
9//
10// Copyright (c) 2025 Trend Redaktions- und Verlagsgesellschaft mbH
11// Copyright (c) 2019 Marc-Michael Horstmann
12//
13// Permission is hereby granted to any person obtaining a copy of this software
14// and associated source code (the "Software"), to use, view, and study the
15// Software for personal or internal business purposes, subject to the following
16// conditions:
17//
18// 1. Redistribution, modification, sublicensing, or commercial use of the
19// Software is NOT permitted without prior written consent from the copyright
20// holder.
21//
22// 2. The Software is provided "AS IS", without warranty of any kind, express
23// or implied.
24//
25// 3. All copies of the Software must retain this license notice.
26//
27// For further information, please contact: horstmann.marc@trendverlag.de
28
29#pragma once
30
206
207#include "Identified.h"
208#include "Track.h"
209#include "ConnectorType.h"
210
211namespace trax{
212
213 struct MultiPlug;
214 struct Jack;
215 struct SocketRegistry;
216
217 class Location;
218
219 struct ConnectorUserData;
220
225 struct Connector : Identified<Connector>
226 {
228 virtual ConnectorType GetConnectorType() const noexcept = 0;
229
230
232 virtual const char* TypeName() const noexcept = 0;
233
234
237 virtual bool IsValid() const noexcept = 0;
238
239
243 virtual void Toggle( bool pulse = true ) = 0;
244
245
249 virtual void Set( const Track& trackA, Track::EndType trackendA, const Track& trackB, Track::EndType trackendB, bool pulse = true ) = 0;
250
251
253 virtual void Disconnect() = 0;
254
255
268 virtual int Slot( int slot, std::shared_ptr<TrackBuilder> pTrack, Track::EndType trackend, bool connectAnonymous = false ) = 0;
269
270
272 virtual int Slot( std::shared_ptr<TrackBuilder> pTrack, Track::EndType trackend, bool connectAnonymous = false ) = 0;
274
275
278 virtual std::pair<std::shared_ptr<TrackBuilder>,Track::EndType> Slot( int slot ) const noexcept = 0;
279
280
282 virtual int Slot( const Track& track, Track::EndType trackend ) const = 0;
283
284
286 virtual int CntSlots() const noexcept = 0;
287
288
291 virtual void SwapSlots( int slotA, int slotB ) = 0;
292
293
295 virtual bool IsComplete() const = 0;
296
297
308 virtual bool Check( std::ostream& os, Length e_distance = epsilon__length, Angle e_kink = epsilon__angle, Angle e_twist = epsilon__angle ) const noexcept = 0;
309
310
313 virtual void Clear( int slot ) = 0;
314
315
317 virtual void Clear() = 0;
318
319
321 virtual void GetCenter( spat::Frame<Length,One>& center ) const = 0;
322
323
325 virtual MultiPlug& PlugToToggle() noexcept = 0;
326
327
329 virtual const MultiPlug& PlugToToggle() const noexcept = 0;
330
331
333 virtual Jack& JackOnChange() noexcept = 0;
334
335
337 virtual const Jack& JackOnChange() const noexcept = 0;
338
339
342 virtual void RegisterSockets( SocketRegistry& modul ) = 0;
343
344
346 virtual void UnregisterSockets( SocketRegistry& modul ) = 0;
347
348
352 virtual void UserData( ConnectorUserData* pData ) noexcept = 0;
353
354
356 virtual ConnectorUserData* UserData() const noexcept = 0;
357 };
358
359
390 dclspc void Couple(
391 std::pair<std::shared_ptr<TrackBuilder>,Track::EndType> trackEndA,
392 std::pair<std::shared_ptr<TrackBuilder>,Track::EndType> trackEndB,
393 int slotA = -1,
394 int slotB = -1,
395 bool connectAnyway = false );
396
397
405 dclspc void DeCouple( TrackBuilder& track, Track::EndType trackEnd, int ownerSlot = -1 );
406
407
416 dclspc Location GetFarEndLocation( const Connector& connector, int slotID );
417
418 dclspc Location GetEndLocation( const Connector& connector, int slotID );
420
421
428 dclspc spat::Vector<Length> DistanceToOtherEnd( const Connector& connector, int fromSlot );
429}
Home of the Track and TrackBuilder interfaces.
A Location specifies a position on a track system by referencing a track and a TrackLocation on it.
Definition Location.h:110
Value< Dimension< 0, 0, 0 > > One
Dimensionless value.
Definition DimensionedValues.h:319
Value< Dimension< 1, 0, 0 > > Length
Length.
Definition DimensionedValues.h:324
Value< Dimension< 0, 0, 0 > > Angle
Angle in radians.
Definition DimensionedValues.h:320
The namespace provides classes and methods for spatial computations.
Definition Box.h:32
STL namespace.
Namespace of all the trax track libraries classes and methods.
Definition Collection.h:17
dclspc void DeCouple(TrackBuilder &track, Track::EndType trackEnd, int ownerSlot=-1)
Uncouples a track end by clearing any Connectors.
dclspc Location GetFarEndLocation(const Connector &connector, int slotID)
dclspc spat::Vector< Length > DistanceToOtherEnd(const Connector &connector, int fromSlot)
std::pair< std::shared_ptr< TrackBuilder >, Track::EndType > dclspc Couple(const TrackCollection &collection, TrackBuilder &track, Track::EndType endType, Length maxDistance=1_m, Angle maxKink=pi, bool bSilent=true)
Searches open track ends inside an area around a given track end and couples to the closest.
dclspc Location GetEndLocation(const Connector &connector, int slotID)
A Frame ("TNBFrame") describes a location in 3d space and an orientation using a right handed coordin...
Definition Frame.h:52
Implements a 3D - vector in cartesian coordinates.
Definition Vector.h:48
A Connector rearranges the connections between several track ends.
Definition Connector.h:226
virtual void RegisterSockets(SocketRegistry &modul)=0
Registers all the Plugs with the module and supplies the Jacks with plug ids for connecting.
virtual void Toggle(bool pulse=true)=0
Sets the connector to the next setting.
virtual bool IsComplete() const =0
virtual Jack & JackOnChange() noexcept=0
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.
virtual ConnectorType GetConnectorType() const noexcept=0
virtual void SwapSlots(int slotA, int slotB)=0
Exchanges the content of the two slots.
virtual void Clear(int slot)=0
clears the slot with index slot.
virtual void GetCenter(spat::Frame< Length, One > &center) const =0
Gets the center of the tracks the connector is connecting.
virtual MultiPlug & PlugToToggle() noexcept=0
virtual int CntSlots() const noexcept=0
virtual bool IsValid() const noexcept=0
Checks whether the connector is valid.
virtual void Disconnect()=0
Disconnects all track ends from each other.
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 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 int Slot(int slot, std::shared_ptr< TrackBuilder > pTrack, Track::EndType trackend, bool connectAnonymous=false)=0
Populates a slot with a tracks end.
virtual const char * TypeName() const noexcept=0
A jack a plug can get connected with.
Definition Jack.h:83
A MultiPlug provides a variable number of actual Plugs to one input slot.
Definition Plug.h:307
Interface for a registry that reconnects Plugs and Jacks according to their IDs.
Definition SocketRegistry.h:40
Interface for making and shaping tracks.
Definition Track.h:831
Interface for a track used to calculate 3D positions.
Definition Track.h:275