| 1 | // tUnit.h  |
| 2 | //  |
| 3 | // This file implements the base class for all input units. Units read single values from hardware. One or more units  |
| 4 | // make a component.  |
| 5 | //  |
| 6 | // @todo It is at the unit level where remappings (input configurations) will be implemented. This allows any input unit  |
| 7 | // to map to any other compatable input unit.  |
| 8 | //  |
| 9 | // Copyright (c) 2025 Tristan Grimmer.  |
| 10 | // Permission to use, copy, modify, and/or distribute this software for any purpose with or without fee is hereby  |
| 11 | // granted, provided that the above copyright notice and this permission notice appear in all copies.  |
| 12 | //  |
| 13 | // THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL  |
| 14 | // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,  |
| 15 | // INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN  |
| 16 | // AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR  |
| 17 | // PERFORMANCE OF THIS SOFTWARE.  |
| 18 |   |
| 19 | #pragma once  |
| 20 | #include <mutex>  |
| 21 | #include <Foundation/tStandard.h>  |
| 22 | #include <Foundation/tName.h>  |
| 23 | #include <System/tPrint.h>  |
| 24 | #define InitUnit(n) n(name+"|" #n, mutex)  |
| 25 | namespace tInput  |
| 26 | {  |
| 27 |   |
| 28 |   |
| 29 | class tUnit  |
| 30 | {  |
| 31 | public:  |
| 32 | // All units have a name and a mutex. The mutex is a ref because it is shared with other components of a particular  |
| 33 | // controller.  |
| 34 | tUnit(const tName& name, std::mutex& mutex) : Name(name), Mutex(mutex) { }  |
| 35 | virtual ~tUnit() { }  |
| 36 |   |
| 37 | tName Name;  |
| 38 | std::mutex& Mutex;  |
| 39 | };  |
| 40 |   |
| 41 |   |
| 42 | }  |
| 43 | |