Files
Work/aladin/profiledata.hpp
2024-08-07 09:12:07 -04:00

127 lines
2.7 KiB
C++

#ifndef _ALADIN_PROFILEDATA_HPP_
#define _ALADIN_PROFILEDATA_HPP_
#ifndef _COMMON_WINDOWS_HPP_
#include <common/windows.hpp>
#endif
#ifndef _COMMON_STRING_HPP_
#include <common/string.hpp>
#endif
#ifndef _COMMON_FILE_HPP_
#include <common/file.hpp>
#endif
class ProfileData
{
public:
typedef enum Warning{TransmitErrorAirPressure=0x20,WorkTooHard=0x10,CeilingViolationOfDeco=0x08,AscentTooFast=0x04,RemainingBottomTimeTooShort=0x02,DecoStop=0x01,None=0};
ProfileData(void);
ProfileData(int depth,int stageTime,int warning);
bool operator==(const ProfileData &profileData)const;
bool writeTo(File &outFile);
bool readFrom(File &inFile);
virtual ~ProfileData();
int getDepth(void)const;
void setDepth(int depth);
int getStageTime(void)const;
void setStageTime(int stageTime);
Warning getWarning(void)const;
String getWarningString(void)const;
void setWarning(Warning warning);
String toString(void)const;
private:
int mDepth;
int mStageTime;
int mWarning;
};
inline
ProfileData::ProfileData()
: mDepth(0), mStageTime(0), mWarning(None)
{
}
inline
ProfileData::ProfileData(int depth,int stageTime,int warning)
: mDepth(depth), mStageTime(stageTime), mWarning(warning)
{
}
inline
ProfileData::~ProfileData()
{
}
inline
bool ProfileData::operator==(const ProfileData &profileData)const
{
return (mDepth==profileData.mDepth&&mStageTime==profileData.mStageTime&&mWarning==profileData.mWarning);
}
inline
String ProfileData::toString(void)const
{
String str;
str+=String("Depth:")+String().fromInt(getDepth())+String(" ");
str+=String("StageTime:")+String().fromInt(getStageTime())+String(" ");
str+=String("Warning:")+String().fromInt(getWarning());
return str;
}
inline
bool ProfileData::readFrom(File &inFile)
{
if(!inFile.isOkay())return false;
if(!inFile.read(&mDepth,sizeof(mDepth)))return false;
if(!inFile.read(&mStageTime,sizeof(mStageTime)))return false;
if(!inFile.read(&mWarning,sizeof(mWarning)))return false;
return true;
}
inline
bool ProfileData::writeTo(File &outFile)
{
if(!outFile.isOkay())return false;
if(!outFile.write(&mDepth,sizeof(mDepth)))return false;
if(!outFile.write(&mStageTime,sizeof(mStageTime)))return false;
if(!outFile.write(&mWarning,sizeof(mWarning)))return false;
return true;
}
inline
int ProfileData::getDepth(void)const
{
return mDepth;
}
inline
void ProfileData::setDepth(int depth)
{
mDepth=depth;
}
inline
int ProfileData::getStageTime(void)const
{
return mStageTime;
}
inline
void ProfileData::setStageTime(int stageTime)
{
mStageTime=stageTime;
}
inline
ProfileData::Warning ProfileData::getWarning(void)const
{
return (Warning)mWarning;
}
inline
void ProfileData::setWarning(Warning warning)
{
mWarning=warning;
}
#endif