My question is In DemoSafteyMessage.h Why this function has Coord& type instead of double or any other datatype. besides the protected data member is also
protected: Coord senderSpeed;
public:
virtual Coord& getSenderSpeed();
virtual const Coord& getSenderSpeed() const {return const_cast<DemoSafetyMessage*>(this)->getSenderSpeed();}
virtual void setSenderSpeed(const Coord& senderSpeed);
I am askining this question because I want to populate DemoSafetyMessage with more parameters. So It is very important for me to understand Which datatype and Why this datatype is used because speed will return double or float or int value then why Coord&.
Like if I want to take distance then also do i need to take Coord& or i will take double? similarly for direction and nodeId because direction will return double and nodeID will return string.
Any guidance will be appriciated.
Thank You
The example simulation included with Veins 5.0 stores a speed vector in its demo messages. See https://github.com/sommer/veins/blob/veins-5.0/src/veins/modules/application/ieee80211p/DemoBaseApplLayer.cc#L198 for where the speed is read, see https://github.com/sommer/veins/blob/veins-5.0/src/veins/modules/application/ieee80211p/DemoBaseApplLayer.cc#L161 for where it is set in the message.
This allows a receiver to not only see how fast a vehicle is moving (magnitude of the vector), but also in which direction (angle of the vector).