Commit 8aa98f7e authored by Philipp Schäfer's avatar Philipp Schäfer
Browse files

Serialization Helper

- now also supports VistaVector3D and ThirdOctaveMagnitudeSpectrum
- now uses includes instead of forward declarations
parent 5c4808f0
......@@ -3,14 +3,6 @@
// std includes
#include <cassert>
// ITA includes
#include <ITASampleFrame.h>
#include <ITASampleBuffer.h>
// Vista includes
#include <VistaAspects/VistaSerializer.h>
#include <VistaAspects/VistaDeSerializer.h>
int ITA::SimulationScheduler::SerializationHelper::WriteITASampleFrame ( IVistaSerializer& pSerializer,
const ITASampleFrame* pSampleFrame, const int iLength, const int iOffset )
{
......@@ -81,3 +73,47 @@ int ITA::SimulationScheduler::SerializationHelper::ReadITASampleBuffer (
return returnVal;
}
int ITA::SimulationScheduler::SerializationHelper::WriteITAThirdOctaveFactorMagnitudeSpectrum(IVistaSerializer& pSerializer, const ITABase::CThirdOctaveFactorMagnitudeSpectrum& oSpectrum)
{
int returnVal = 0;
for (int i = 0; i < oSpectrum.GetNumBands(); i++)
returnVal += pSerializer.WriteFloat32(oSpectrum[i]);
return returnVal;
}
int ITA::SimulationScheduler::SerializationHelper::ReadITAThirdOctaveFactorMagnitudeSpectrum(IVistaDeSerializer& pDeserializer, ITABase::CThirdOctaveFactorMagnitudeSpectrum& oSpectrum)
{
int returnVal = 0;
for (int i = 0; i < oSpectrum.GetNumBands(); i++)
returnVal += pDeserializer.ReadFloat32(oSpectrum[i]);
return returnVal;
}
int ITA::SimulationScheduler::SerializationHelper::WriteVistaVector3D(IVistaSerializer& pSerializer, const VistaVector3D& v3Vector)
{
int returnVal = 0;
returnVal += pSerializer.WriteFloat32(v3Vector[Vista::X]);
returnVal += pSerializer.WriteFloat32(v3Vector[Vista::Y]);
returnVal += pSerializer.WriteFloat32(v3Vector[Vista::Z]);
returnVal += pSerializer.WriteFloat32(v3Vector[Vista::W]);
return returnVal;
}
int ITA::SimulationScheduler::SerializationHelper::ReadVistaVector3D(IVistaDeSerializer& pDeserializer, VistaVector3D& v3Vector)
{
int returnVal = 0;
returnVal += pDeserializer.ReadFloat32(v3Vector[Vista::X]);
returnVal += pDeserializer.ReadFloat32(v3Vector[Vista::Y]);
returnVal += pDeserializer.ReadFloat32(v3Vector[Vista::Z]);
returnVal += pDeserializer.ReadFloat32(v3Vector[Vista::W]);
return returnVal;
}
#ifndef INCLUDE_WATCHER_ITA_SIMULATION_SCHEDULER_SERIALIZATION_HELPER
#define INCLUDE_WATCHER_ITA_SIMULATION_SCHEDULER_SERIALIZATION_HELPER
class ITASampleFrame;
class ITASampleBuffer;
//ITA
#include <ITASampleBuffer.h>
#include <ITASampleFrame.h>
#include <ITAThirdOctaveMagnitudeSpectrum.h>
class IVistaSerializer;
class IVistaDeSerializer;
// Vista
#include <VistaBase/VistaVector3D.h>
#include <VistaAspects/VistaSerializer.h>
#include <VistaAspects/VistaDeSerializer.h>
namespace ITA
{
......@@ -48,6 +52,12 @@ namespace ITA
/// \return the number of bytes written or -1 on failure.
///
static int ReadITASampleBuffer ( IVistaDeSerializer& pDeserializer, ITASampleBuffer& pBuffer );
static int WriteITAThirdOctaveFactorMagnitudeSpectrum(IVistaSerializer& pSerializer, const ITABase::CThirdOctaveFactorMagnitudeSpectrum& oSpectrum);
static int ReadITAThirdOctaveFactorMagnitudeSpectrum(IVistaDeSerializer& pDeserializer, ITABase::CThirdOctaveFactorMagnitudeSpectrum& oSpectrum);
static int WriteVistaVector3D(IVistaSerializer& pSerializer, const VistaVector3D& v3Vector);
static int ReadVistaVector3D(IVistaDeSerializer& pDeserializer, VistaVector3D& v3Vector);
};
} // namespace SimulationScheduler
} // namespace ITA
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment