Trax3 3.1.0
trax track library
Loading...
Searching...
No Matches
Indicator.h
1// trax track library
2// AD 2014
3//
4// "the resolution of all the fruitless searches"
5//
6// Peter Gabriel
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
29#include "Configuration.h"
30#include "Units.h"
31#include "Identified.h"
32
33#include "spat/Frame.h"
34
35namespace trax{
36
37 struct Plug;
38 struct Jack;
39 struct SocketRegistry;
40
44 struct Indicator : Identified<Indicator>
45 {
46 enum class Type : char{
47 unknown = -1,
48 none = 0,
49 switch_mono,
50 switch_multi,
51 velocity_control,
52 };
53
55 static dclspc std::unique_ptr<Indicator> Make( Type type ) noexcept;
56
57
59 virtual const char* TypeName() const noexcept = 0;
60
61
63 enum class Status{
64 none = -1,
65 unknown = 0,
66 one = 1,
67 two = 2,
68 three = 3,
69 four = 4,
70 five = 5,
71 six = 6,
72 seven = 7,
73 eight = 8,
74 nine = 9,
75 ten = 10,
76 eleven = 11,
77 twelve = 12,
78 thirteen= 13,
82 };
83
84
89 virtual void SetFrame( const spat::Frame<Length,One>& frame ) = 0;
90
91
94 virtual const spat::Frame<Length,One>& GetFrame() const = 0;
95
96
98 //virtual void SetAbsoluteFrame( const Frame<Real>& frame ) = 0;
99
100
102 //virtual const Frame<Real>& GetAbsoluteFrame() const = 0;
103
104
107 virtual void Get( spat::Frame<Length,One>& frame ) const = 0;
108
109
112 virtual void Toggle( bool pulse = true ) = 0;
113
114
119 virtual Status Set( Status status, bool pulse = true ) = 0;
120
121
123 virtual Status Get() const = 0;
124
125
128 virtual bool IsValidState( Status status ) const = 0;
129
130
132 virtual void RotateWithStatus( Status status, Real angle ) = 0;
133
134
136 virtual Real RotateWithStatus( Status status ) const = 0;
137
138
140 virtual Jack& JackOn( Status status ) = 0;
141
142
144 virtual Plug& PlugTo( Status status ) = 0;
145
146
148 virtual Plug& PlugToToggle() noexcept = 0;
149
150
152 virtual Jack& JackOnChange() noexcept = 0;
153
154
157 virtual void RegisterSockets( SocketRegistry& registry ) = 0;
158
159
161 virtual void UnregisterSockets( SocketRegistry& registry ) = 0;
162 };
163
164
166 dclspc std::string ToString( Indicator::Type type );
167
169 dclspc std::string ToString( Indicator::Status status );
170
171
174 dclspc Indicator::Status ToIndicatorStatus( const std::string& status );
175
176
177 dclspc Indicator::Status IndicatorStatusFrom( const std::string& socketName );
178
179
182
184 static dclspc std::unique_ptr<BinaryIndicator> Make( Type type ) noexcept;
185
186
188 virtual Jack& JackOnOne() noexcept = 0;
189
190
192 virtual Plug& PlugToOne() noexcept = 0;
193
194
196 virtual Jack& JackOnTwo() noexcept = 0;
197
198
200 virtual Plug& PlugToTwo() noexcept = 0;
201 };
202}
float Real
Underlying floating point type to be used with the dim library.
Definition DimensionedValues.h:190
STL namespace.
Namespace of all the trax track libraries classes and methods.
Definition Collection.h:17
dclspc Indicator::Status ToIndicatorStatus(const std::string &status)
Makes a status value from a status string.
A Frame ("TNBFrame") describes a location in 3d space and an orientation using a right handed coordin...
Definition Frame.h:52
An Indicator with two states.
Definition Indicator.h:181
static dclspc std::unique_ptr< BinaryIndicator > Make(Type type) noexcept
Makes a BinaryIndicator object.
virtual Plug & PlugToOne() noexcept=0
Gets a Plug that sets the BinaryIndicator to one.
virtual Plug & PlugToTwo() noexcept=0
Gets a Plug that sets the BinaryIndicator to zero.
virtual Jack & JackOnOne() noexcept=0
Gets a Jack that pulses its Plug if the BinaryIndicator is set to one.
virtual Jack & JackOnTwo() noexcept=0
Gets a Jack that pulses its Plug if the BinaryIndicator is set to zero.
Interface for objects that indicates system states somehow.
Definition Indicator.h:45
virtual void RotateWithStatus(Status status, Real angle)=0
Set an angle to rotate the indicator by with its status.
virtual const char * TypeName() const noexcept=0
virtual Plug & PlugToToggle() noexcept=0
virtual Status Get() const =0
Gets the setting of the indicator.
virtual void UnregisterSockets(SocketRegistry &registry)=0
Removes all references to Plugs and Jacks from the module.
virtual void Get(spat::Frame< Length, One > &frame) const =0
Gets the pose of the Indicator in global coordinates.
virtual bool IsValidState(Status status) const =0
virtual Plug & PlugTo(Status status)=0
Gets a Plug that switches to the specified Status.
virtual Jack & JackOnChange() noexcept=0
virtual void Toggle(bool pulse=true)=0
Sets the indicator to the next setting.
virtual Status Set(Status status, bool pulse=true)=0
Turns the indicator to the specified setting.
virtual Jack & JackOn(Status status)=0
Gets a Jack that pulses its Plug if the specified Status is set.
virtual void SetFrame(const spat::Frame< Length, One > &frame)=0
Set frame of reference.
Status
Possible Indicator states:
Definition Indicator.h:63
@ toggle
status toggle
Definition Indicator.h:80
@ count
Number of valid status.
Definition Indicator.h:79
@ change
status change
Definition Indicator.h:81
virtual Real RotateWithStatus(Status status) const =0
virtual const spat::Frame< Length, One > & GetFrame() const =0
Get frame of reference.
virtual void RegisterSockets(SocketRegistry &registry)=0
Registers all the Plugs with the module and supplies the Jacks with plug ids for connecting.
static dclspc std::unique_ptr< Indicator > Make(Type type) noexcept
Makes a Indicator object.
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
Interface for a registry that reconnects Plugs and Jacks according to their IDs.
Definition SocketRegistry.h:40