A Discrete-Event Network Simulator
API
vector.h
Go to the documentation of this file.
1 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
2 /*
3  * Copyright (c) 2007 INRIA
4  *
5  * This program is free software; you can redistribute it and/or modify
6  * it under the terms of the GNU General Public License version 2 as
7  * published by the Free Software Foundation;
8  *
9  * This program is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12  * GNU General Public License for more details.
13  *
14  * You should have received a copy of the GNU General Public License
15  * along with this program; if not, write to the Free Software
16  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17  *
18  * Author: Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
19  */
20 #ifndef NS3_VECTOR_H
21 #define NS3_VECTOR_H
22 
23 #include "attribute.h"
24 #include "attribute-helper.h"
25 
32 namespace ns3 {
33 
38 class Vector3D
39 {
40 public:
48  Vector3D (double _x, double _y, double _z);
52  Vector3D ();
56  double x;
60  double y;
64  double z;
65 
66  friend double CalculateDistance (const Vector3D &a, const Vector3D &b);
67  friend std::ostream &operator << (std::ostream &os, const Vector3D &vector);
68  friend std::istream &operator >> (std::istream &is, Vector3D &vector);
69 };
70 
75 class Vector2D
76 {
77 public:
84  Vector2D (double _x, double _y);
88  Vector2D ();
92  double x;
96  double y;
97 
98  friend double CalculateDistance (const Vector2D &a, const Vector2D &b);
99  friend std::ostream &operator << (std::ostream &os, const Vector2D &vector);
100  friend std::istream &operator >> (std::istream &is, Vector2D &vector);
101 };
102 
108 double CalculateDistance (const Vector3D &a, const Vector3D &b);
114 double CalculateDistance (const Vector2D &a, const Vector2D &b);
115 
118 
128 std::ostream &operator << (std::ostream &os, const Vector3D &vector);
138 std::ostream &operator << (std::ostream &os, const Vector2D &vector);
139 
149 std::istream &operator >> (std::istream &is, Vector3D &vector);
159 std::istream &operator >> (std::istream &is, Vector2D &vector);
160 
161 
166 typedef Vector3D Vector;
177 
178 
179 // Document these by hand so they go in group attribute_Vector3D
194 
201 
202 } // namespace ns3
203 
204 #endif /* NS3_VECTOR_H */
std::istream & operator>>(std::istream &is, Angles &a)
initialize a struct Angles from input
Definition: angles.cc:48
double x
x coordinate of vector
Definition: vector.h:56
Smart pointer class similar to boost::intrusive_ptr.
Definition: ptr.h:73
friend std::istream & operator>>(std::istream &is, Vector2D &vector)
Input streamer.
Definition: vector.cc:118
Vector3DValue VectorValue
Vector alias typedef for compatibility with mobility models.
Definition: vector.h:171
a 3d vector
Definition: vector.h:38
double x
x coordinate of vector
Definition: vector.h:92
Vector2D()
Create vector vector (0.0, 0.0)
Definition: vector.cc:70
double y
y coordinate of vector
Definition: vector.h:96
double CalculateDistance(const Vector3D &a, const Vector3D &b)
Definition: vector.cc:78
Vector3D()
Create vector (0.0, 0.0, 0.0)
Definition: vector.cc:55
Vector3D Vector
Definition: vector.h:166
ns3::AttributeValue, ns3::AttributeAccessor and ns3::AttributeChecker declarations.
std::ostream & operator<<(std::ostream &os, const Angles &a)
print a struct Angles to output
Definition: angles.cc:42
a 2d vector
Definition: vector.h:75
Every class exported by the ns3 library is enclosed in the ns3 namespace.
Ptr< const AttributeChecker > MakeVectorChecker(void)
Definition: vector.cc:40
double y
y coordinate of vector
Definition: vector.h:60
friend std::ostream & operator<<(std::ostream &os, const Vector2D &vector)
Output streamer.
Definition: vector.cc:113
Declaration of Attribute helper macros.
Vector3DChecker VectorChecker
Vector alias typedef for compatibility with mobility models.
Definition: vector.h:176
#define ATTRIBUTE_ACCESSOR_DEFINE(type)
Define the attribute accessor functions MakeTypeAccessor for class type.
friend std::ostream & operator<<(std::ostream &os, const Vector3D &vector)
Output streamer.
Definition: vector.cc:97
friend std::istream & operator>>(std::istream &is, Vector3D &vector)
Input streamer.
Definition: vector.cc:102
friend double CalculateDistance(const Vector3D &a, const Vector3D &b)
Definition: vector.cc:78
AttributeValue implementation for Vector3D.
Definition: vector.h:116
AttributeChecker implementation for Vector3DValue.
Definition: vector.h:116
#define ATTRIBUTE_HELPER_HEADER(type)
Declare the attribute value, accessor and checkers for class type.
friend double CalculateDistance(const Vector2D &a, const Vector2D &b)
Definition: vector.cc:88
double z
z coordinate of vector
Definition: vector.h:64