2011-11-08 21:05:08 +01:00
|
|
|
#include <iostream>
|
|
|
|
#include <string>
|
|
|
|
#include <iomanip>
|
|
|
|
|
|
|
|
#include "AktivesVO.h"
|
|
|
|
|
|
|
|
extern double dGlobaleZeit;
|
|
|
|
|
|
|
|
int AktivesVO::p_iMaxID = 0;
|
|
|
|
map<string, AktivesVO*> AktivesVO::p_pObjekte;
|
|
|
|
|
|
|
|
AktivesVO::AktivesVO() {
|
|
|
|
vInitialisierung();
|
|
|
|
}
|
|
|
|
|
|
|
|
AktivesVO::AktivesVO(string sName) {
|
|
|
|
vInitialisierung();
|
|
|
|
p_sName = sName;
|
|
|
|
vRegister();
|
|
|
|
}
|
|
|
|
|
|
|
|
AktivesVO::AktivesVO(AktivesVO &vo) {
|
|
|
|
vInitialisierung();
|
|
|
|
p_sName = vo.p_sName;
|
|
|
|
vRegister();
|
|
|
|
}
|
|
|
|
|
|
|
|
AktivesVO::~AktivesVO() {
|
|
|
|
p_pObjekte.erase(p_sName);
|
|
|
|
}
|
|
|
|
|
|
|
|
void AktivesVO::vRegister() {
|
|
|
|
map<string, AktivesVO*>::iterator result = p_pObjekte.find(p_sName);
|
|
|
|
if (result != p_pObjekte.end()) {
|
2012-01-19 14:34:32 +01:00
|
|
|
throw string("Ein Objekt mit dem Namen existiert bereits! ") + p_sName;
|
2011-11-08 21:05:08 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
p_pObjekte[p_sName] = this;
|
|
|
|
}
|
|
|
|
|
|
|
|
AktivesVO * AktivesVO::pObjekt(string sName) {
|
|
|
|
map<string, AktivesVO*>::iterator result = p_pObjekte.find(sName);
|
|
|
|
if (result == p_pObjekte.end()) {
|
|
|
|
throw string("Ein Objekt mit dem Namen existiert nicht!");
|
|
|
|
}
|
|
|
|
|
|
|
|
return result->second;
|
|
|
|
}
|
|
|
|
|
|
|
|
void AktivesVO::vInitialisierung() {
|
|
|
|
p_iID = ++p_iMaxID;
|
|
|
|
|
|
|
|
p_sName = "";
|
|
|
|
p_dZeit = 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
void AktivesVO::vAusgabeHeader() {
|
2011-11-09 10:18:11 +01:00
|
|
|
cout << "ID Zeit Name : Kmh Strecke Abschnitt Verbrauch Tankinhalt" << endl;
|
|
|
|
cout << "++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++"
|
2011-11-08 21:05:08 +01:00
|
|
|
<< endl;
|
|
|
|
}
|
|
|
|
|
|
|
|
ostream& AktivesVO::ostreamAusgabe(ostream &stream) const {
|
|
|
|
stream << setprecision(1) << setiosflags(ios::fixed)
|
|
|
|
<< resetiosflags(ios::right) << setiosflags(ios::left)
|
|
|
|
<< setw(3) << p_iID
|
2011-11-09 10:18:11 +01:00
|
|
|
<< setw(6) << p_dZeit
|
|
|
|
<< setw(9) << p_sName << ":";
|
2011-11-08 21:05:08 +01:00
|
|
|
|
|
|
|
return stream;
|
|
|
|
}
|
|
|
|
|
|
|
|
istream& AktivesVO::istreamEingabe(istream &stream) {
|
|
|
|
if (p_sName != "") {
|
|
|
|
throw string("Verkehrsobjekt ist bereits initialisiert!");
|
|
|
|
}
|
|
|
|
|
|
|
|
stream >> p_sName;
|
|
|
|
|
|
|
|
vRegister();
|
|
|
|
|
|
|
|
return stream;
|
|
|
|
}
|
|
|
|
|
|
|
|
string AktivesVO::getName() const {
|
|
|
|
return p_sName;
|
|
|
|
}
|
|
|
|
|
|
|
|
ostream& operator<<(ostream &stream, const AktivesVO &vo) {
|
|
|
|
return vo.ostreamAusgabe(stream);
|
|
|
|
}
|
|
|
|
|
|
|
|
istream& operator>>(istream &in, AktivesVO &vo) {
|
|
|
|
return vo.istreamEingabe(in);
|
|
|
|
}
|