Trax3 3.1.0
trax track library
Loading...
Searching...
No Matches
Sensor.h
1// trax track library
2// AD 2014
3//
4// "It aint me"
5//
6// Creedence Clearwater Revival
7//
8// Copyright (c) 2025 Trend Redaktions- und Verlagsgesellschaft mbH
9// Copyright (c) 2019 Marc-Michael Horstmann
10//
11// Permission is hereby granted to any person obtaining a copy of this software
12// and associated source code (the "Software"), to use, view, and study the
13// Software for personal or internal business purposes, subject to the following
14// conditions:
15//
16// 1. Redistribution, modification, sublicensing, or commercial use of the
17// Software is NOT permitted without prior written consent from the copyright
18// holder.
19//
20// 2. The Software is provided "AS IS", without warranty of any kind, express
21// or implied.
22//
23// 3. All copies of the Software must retain this license notice.
24//
25// For further information, please contact: horstmann.marc@trendverlag.de
26
27#pragma once
28
52
53#include "Configuration.h"
54#include "Units.h"
55#include "Identified.h"
56
57#include "common/Interval.h"
58
59namespace trax{
60
61 struct Event;
62 struct Jack;
63 struct Plug;
64 struct SocketRegistry;
65 struct TrackBuilder;
66
67 class Location;
68
70 struct Sensor : Identified<Sensor>
71 {
73 static dclspc std::unique_ptr<Sensor> Make() noexcept;
74
75
77 virtual const char* TypeName() const noexcept = 0;
78
79
86 virtual void Trigger( const Event& _event ) = 0;
87
88
91 virtual TrackBuilder* TrackAttached() const = 0;
92
93
98 virtual void Attach( TrackBuilder* pTrackBuilder ) = 0;
99
100
102 virtual Jack& JackOnTrigger() = 0;
103
104
107 virtual void RegisterSockets( SocketRegistry& modul ) = 0;
108
109
111 virtual void UnregisterSockets( SocketRegistry& modul ) = 0;
112 };
113
121 //struct SensorFilterJack : Sensor
122 //{
123 // /// \brief Flags for filtering the trigger events.
124 // enum Effect{
125 // none = 0x0000, ///< triggers never
126 // train_tip = 0x0001, ///< triggers if the train tip with respect to moving direction is encountered
127 // train_end = 0x0002, ///< triggers if the train end with respect to moving direction is encountered
128 // train_north = 0x0004, ///< triggers if the north end of the train is encountered
129 // train_south = 0x0008, ///< triggers if the south end of the train is encountered
130 // wheelframe = 0x0010, ///< triggers on every wheelframe
131 // name = 0x0020, ///< triggers if the name of the sensor is a substring of the wheelset's name path (Train_Name/RollingStock_Name/Bogie_Name/SubBogieName/ ... /WheelframeName).
132 // not_name = 0x0040, ///< triggers if the name of the sensor is not a substring of the wheelset's name path.
133 // any = 0xffff ///< triggers always
134 // };
135
136 // /// \brief Makes a SensorFilterJack object.
137 // static dclspc std::unique_ptr<SensorFilterJack> Make( int flags = SensorFilterJack::any ) noexcept;
138
139
140 // virtual int GetEffect() const = 0;
141
142
143 // virtual void SetEffect( int effect ) = 0;
144 //};
145
146
147 //dclspc std::string ToString( SensorFilterJack::Effect effect );
148
149 //dclspc SensorFilterJack::Effect SensorEffectFromString( const std::string& effect );
150
151}
A Location specifies a position on a track system by referencing a track and a TrackLocation on it.
Definition Location.h:110
Namespace of all the trax track libraries classes and methods.
Definition Collection.h:17
Definition Event.h:40
A jack a plug can get connected with.
Definition Jack.h:83
A Plug of some object can get plugged into a jack of some object, specific to a certain event.
Definition Plug.h:57
A Sensor can get attached to a track and be triggerd when a Location runs over it.
Definition Sensor.h:71
virtual Jack & JackOnTrigger()=0
Gets a Jack that pulses its Plug if the sensor is triggering.
virtual void Trigger(const Event &_event)=0
Triggers this Sensor.
virtual void Attach(TrackBuilder *pTrackBuilder)=0
Attach the pointer to the track to the sensor.
virtual void UnregisterSockets(SocketRegistry &modul)=0
Removes all references to Plugs and Jacks from the module.
virtual void RegisterSockets(SocketRegistry &modul)=0
Registers all the Plugs with the module and supplies the Jacks with plug ids for connecting.
virtual TrackBuilder * TrackAttached() const =0
static dclspc std::unique_ptr< Sensor > Make() noexcept
Makes a Sensor object that triggers on all events.
virtual const char * TypeName() const noexcept=0
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