#pragma once #include #include #include #include #include "SensorDatumConcept.h" #include "NetMessengerStreamBuffer.h" #include "Vector.h" #include "Quat.h" //Written By Scott Nykl //This is an EXAMPLE class that is designed to be copy/pasted/renamed to *YOUR SPECIFIC* sensor datum type. //These are similar to NetMsgs w/ the to/fromStream (and even have a fromStream that extracts from a //NetMessengerStreamBuffer. namespace Aftr { //When used to parse data or log data, All SensorDatum-esque classes must adhear to the SensorDatumConcept by //implementing the exact signature of the methods defined below. Keep this class as a POD (don't do fancy things //with any constructors). //It is expected that each datum uses exactly one line and terminates with a single newline \n. //For example: // 2023.Apr.14_14.25.35.3359030.UTC 1.23 2.34 3.45 1 0 0 0 0 // 2023.Apr.14_14.25.36.3359030.UTC 6.63 7.74 8.85 0 0 0 0 1 class SensorDatum_Example { public: //This method extracts one datum from the inputstream and returns an instance of SensorDatum_Example static std::expected< SensorDatum_Example, ParseError > fromStreamOneDatum( std::istream& is ); static std::expected< SensorDatum_Example, ParseError > fromStreamOneDatum( NetMessengerStreamBuffer& is ); //This method should terminate each datum with a single newline \n. Only insert one newline per datum (at the end). //This method inserts the member data of this datum into the ostream&. bool toStreamOneDatum( std::ostream& os ) const; /// Returns the string placed at the top of a log file which describes this data format in ASCII text /// This string should begin with a # to denote a comment that is not parsed as a datum when reading from file. static std::string getHeaderDescribingData(); /// Returns the time_point associated with this datum std::chrono::utc_clock::time_point getTime() const { return this->time; } SensorDatum_Example( std::chrono::utc_clock::time_point t, Vector const& pos, Quat const& orient ); SensorDatum_Example() = default; ~SensorDatum_Example() = default; std::chrono::utc_clock::time_point time; Vector pos = { 0,0,0 }; Quat q = { 0,0,0,0 }; }; } //namespace Aftr