A Discrete-Event Network Simulator
API
Loading...
Searching...
No Matches
waypoint.cc
Go to the documentation of this file.
1/*
2 * Copyright (c) 2009 Phillip Sitbon
3 *
4 * SPDX-License-Identifier: GPL-2.0-only
5 *
6 * Author: Phillip Sitbon <phillip@sitbon.net>
7 */
8#include "waypoint.h"
9
10namespace ns3
11{
12
14
15Waypoint::Waypoint(const Time& waypointTime, const Vector& waypointPosition)
16 : time(waypointTime),
17 position(waypointPosition)
18{
19}
20
22 : time(Seconds(0.0)),
23 position(0, 0, 0)
24{
25}
26
27/**
28 * \brief Stream insertion operator.
29 *
30 * \param os the stream
31 * \param waypoint the waypoint
32 * \returns a reference to the stream
33 */
34std::ostream&
35operator<<(std::ostream& os, const Waypoint& waypoint)
36{
37 os << waypoint.time.GetSeconds() << "$" << waypoint.position;
38 return os;
39}
40
41/**
42 * \brief Stream extraction operator.
43 *
44 * \param is the stream
45 * \param waypoint the waypoint
46 * \returns a reference to the stream
47 */
48std::istream&
49operator>>(std::istream& is, Waypoint& waypoint)
50{
51 char separator;
52 is >> waypoint.time >> separator >> waypoint.position;
53 if (separator != '$')
54 {
55 is.setstate(std::ios_base::failbit);
56 }
57 return is;
58}
59
60} // namespace ns3
Simulation virtual time values and global simulation resolution.
Definition nstime.h:94
double GetSeconds() const
Get an approximation of the time stored in this instance in the indicated unit.
Definition nstime.h:392
a (time, location) pair.
Definition waypoint.h:25
Waypoint()
Create a waypoint at time 0 and position (0,0,0).
Definition waypoint.cc:21
Time time
The waypoint time.
Definition waypoint.h:42
Vector position
The position of the waypoint.
Definition waypoint.h:46
#define ATTRIBUTE_HELPER_CPP(type)
Define the attribute value, accessor and checkers for class type
Time Seconds(double value)
Construct a Time in the indicated unit.
Definition nstime.h:1308
Every class exported by the ns3 library is enclosed in the ns3 namespace.
std::ostream & operator<<(std::ostream &os, const Angles &a)
Definition angles.cc:148
std::istream & operator>>(std::istream &is, Angles &a)
Definition angles.cc:172