34 lv.vehicleType = VehicleType_VL;
35 hgv.vehicleType = VehicleType_PL;
38 arr[i].flowType = FlowType_CONST;
39 arr[i].trafficFlow = 0;
40 arr[i].trafficSpeed = 0;
41 assert((
arr[i].vehicleType == i + 1) &&
"Bad consistency assumption wrt vehicles types in Ctor");
59 arr[i].flowType = other.
arr[i].flowType;
60 arr[i].trafficFlow = other.
arr[i].trafficFlow;
61 arr[i].trafficSpeed = other.
arr[i].trafficSpeed;
73 if (
arr[i].flowType != other.
arr[i].flowType)
77 if (
arr[i].trafficFlow != other.
arr[i].trafficFlow)
81 if (
arr[i].trafficSpeed != other.
arr[i].trafficSpeed)
103 assert(pOtherTrafic &&
"invalid cast to TYTrafic*");
105 *
this = *pOtherTrafic;
120 const RoadTrafficComponent& rtc =
arr[i];
121 QDomDocument domDoc = domTrafficElem.ownerDocument();
122 QDomElement componentElem = domDoc.createElement(
"TrafficComponent");
123 componentElem.setAttribute(
"flowType", rtc.flowType);
124 componentElem.setAttribute(
"trafficFlow", rtc.trafficFlow);
125 componentElem.setAttribute(
"trafficSpeed", rtc.trafficSpeed);
126 assert((rtc.vehicleType == i + 1) &&
"Bad consistency assumption wrt vehicles types");
127 componentElem.setAttribute(
"vehicleType", rtc.vehicleType);
128 domTrafficElem.appendChild(componentElem);
130 return domTrafficElem;
137 QDomNodeList children = domElement.elementsByTagName(
"TrafficComponent");
141 "%u TrafficComponent child elements were found but %u were expected",
148 QDomElement elem = children.item(i).toElement();
158 assert((
arr[i].vehicleType == i + 1) &&
"Inconsistent vehicle types in traffic components");
170 s = domElement.attribute(
"trafficFlow", QString());
174 "Can not read the TrafficComponent `trafficFlow` attribute for element %s.",
178 double trafficFlow =
s.toDouble(&ok);
182 "Floating point number expected for attribute `trafficFlow` on element %s, not %s",
188 s = domElement.attribute(
"trafficSpeed", QString());
192 "Can not read the TrafficComponent `trafficSpeed` attribute for element %s.",
196 double trafficSpeed =
s.toDouble(&ok);
200 "Floating point number expected for attribute `trafficSpeed` on element %s, not %s",
206 s = domElement.attribute(
"flowType", QString());
210 "Can not read the TrafficComponent `flowType` attribute for element %s.",
214 unsigned flowType =
s.toUInt(&ok);
223 s = domElement.attribute(
"vehicleType", QString());
227 "Can not read the TrafficComponent `vehicleType` attribute for element %s.",
231 unsigned vehicleType =
s.toUInt(&ok);
239 rtc.trafficFlow = trafficFlow;
240 rtc.trafficSpeed = trafficSpeed;
241 rtc.flowType =
static_cast<RoadFlowType
>(flowType);
242 rtc.vehicleType =
static_cast<RoadVehicleType
>(vehicleType);
const char * str_qt2c(const QString &qstr)
TY_EXTENSION_INST(TYTrafic)
virtual void error(const char *message,...)
static OMessageManager * get()
virtual const char * getClassName() const
virtual bool deepCopy(const TYElement *pOther, bool copyId=true, bool pUseCopyTag=false)
virtual DOM_Element toXML(DOM_Element &domElement)
QString _name
Nom courant de l'element.
TYElement & operator=(const TYElement &other)
virtual int fromXML(DOM_Element domElement)
QString getStringID() const
QString generateName(const char *classname)
Retourne le nom de la classe associe a un nombre.
static TYNameManager * get()
Retourne l'instance singleton.
virtual bool deepCopy(const TYElement *pOther, bool copyId=true, bool pUseCopyTag=false)
int fromXML_TrafficComponent(DOM_Element domElement, RoadTrafficComponent &rtc)
Auxilliary methods used to read a RoadTrafficComponent from XML.
RoadTrafficComponent arr[NB_VEHICLE_TYPES]
bool operator!=(const TYTrafic &other) const
Operateur !=.
virtual std::string toString() const
virtual DOM_Element toXML(DOM_Element &domElement)
TYTrafic & operator=(const TYTrafic &other)
Operateur =.
virtual int fromXML(DOM_Element domElement)
bool operator==(const TYTrafic &other) const
Operateur ==.