AGX Dynamics 2.42.3.0
Loading...
Searching...
No Matches
SensorOutput.h
Go to the documentation of this file.
1/*
2Copyright 2007-2025. Algoryx Simulation AB.
3
4All AGX source code, intellectual property, documentation, sample code,
5tutorials, scene files and technical white papers, are copyrighted, proprietary
6and confidential material of Algoryx Simulation AB. You may not download, read,
7store, distribute, publish, copy or otherwise disseminate, use or expose this
8material unless having a written signed agreement with Algoryx Simulation AB, or having been
9advised so by Algoryx Simulation AB for a time limited evaluation, or having purchased a
10valid commercial license from Algoryx Simulation AB.
11
12Algoryx Simulation AB disclaims all responsibilities for loss or damage caused
13from using this software, unless otherwise stated in written agreements with
14Algoryx Simulation AB.
15*/
16#pragma once
18
19#include <agx/Logger.h>
20
21namespace agxSensor
22{
27 {
28 public:
33 template<typename T>
34 static bool verifySize( size_t elementSize );
35
36 public:
40 ISensorOutput() = default;
41
46 virtual size_t getElementSize() const = 0;
47
54 template<typename T>
56
62 virtual const BinaryOutputBuffer& getData() = 0;
63
70 virtual bool hasUnreadData( bool markAsRead = true ) = 0;
71
73
74 public:
75 virtual ~ISensorOutput() = default;
76
78 };
79
80 template<typename T>
81 bool ISensorOutput::verifySize( size_t elementSize )
82 {
83 const auto isValidSize = sizeof( T ) == elementSize;
84 if ( !isValidSize ) {
85 LOGGER_WARNING() << "View data type size mismatch, sizeof(" << typeid( T ).name() << ") = "
86 << sizeof( T ) << " != " << elementSize << " (elementSize)."
87 << LOGGER_ENDL();
88 }
89 return isValidSize;
90 }
91
92 template<typename T>
93 BinaryOutputView<T> ISensorOutput::view()
94 {
95 if ( !ISensorOutput::verifySize<T>( this->getElementSize() ) )
96 return {};
97 return getData().view<T>();
98 }
99}
#define LOGGER_WARNING()
Definition: Logger.h:23
#define LOGGER_ENDL()
Definition: Logger.h:27
#define AGXSENSOR_EXPORT
Buffer used for sensor output of a wide range of output element types.
View for reading sections of a binary packed buffer of the specified template parameter type.
Common interface for sensor output data.
Definition: SensorOutput.h:27
virtual const BinaryOutputBuffer & getData()=0
Returns access to the sensor output data.
virtual bool hasUnreadData(bool markAsRead=true)=0
ISensorOutput()=default
Default constructor.
virtual size_t getElementSize() const =0
"Element size" is the summed data size of the currently added sensor output fields.
#define DOXYGEN_END_INTERNAL_BLOCK()
Definition: macros.h:89
#define DOXYGEN_START_INTERNAL_BLOCK()
Definition: macros.h:88
The agxSensor namespace contains components to model real-time sensors connected to the physics of AG...