diff --git a/bindings/python/ns3_module_core.py b/bindings/python/ns3_module_core.py index 1d5cd0e9a..9b0535a14 100644 --- a/bindings/python/ns3_module_core.py +++ b/bindings/python/ns3_module_core.py @@ -83,6 +83,10 @@ def register_types(module): module.add_class('UniformVariable', parent=root_module['ns3::RandomVariable']) ## attribute-list.h: ns3::UnsafeAttributeList [class] module.add_class('UnsafeAttributeList') + ## vector.h: ns3::Vector2D [class] + module.add_class('Vector2D') + ## vector.h: ns3::Vector3D [class] + module.add_class('Vector3D') ## random-variable.h: ns3::WeibullVariable [class] module.add_class('WeibullVariable', parent=root_module['ns3::RandomVariable']) ## random-variable.h: ns3::ZipfVariable [class] @@ -165,6 +169,14 @@ def register_types(module): module.add_class('TypeIdValue', parent=root_module['ns3::AttributeValue']) ## uinteger.h: ns3::UintegerValue [class] module.add_class('UintegerValue', parent=root_module['ns3::AttributeValue']) + ## vector.h: ns3::Vector2DChecker [class] + module.add_class('Vector2DChecker', parent=root_module['ns3::AttributeChecker']) + ## vector.h: ns3::Vector2DValue [class] + module.add_class('Vector2DValue', parent=root_module['ns3::AttributeValue']) + ## vector.h: ns3::Vector3DChecker [class] + module.add_class('Vector3DChecker', parent=root_module['ns3::AttributeChecker']) + ## vector.h: ns3::Vector3DValue [class] + module.add_class('Vector3DValue', parent=root_module['ns3::AttributeValue']) ## traced-value.h: ns3::TracedValue [class] module.add_class('TracedValue', template_parameters=['unsigned int']) ## traced-value.h: ns3::TracedValue [class] @@ -175,6 +187,12 @@ def register_types(module): root_module['ns3::TracedValue< unsigned int >'].implicitly_converts_to(root_module['ns3::BooleanValue']) ## traced-value.h: ns3::TracedValue [class] root_module['ns3::TracedValue< unsigned int >'].implicitly_converts_to(root_module['ns3::EnumValue']) + typehandlers.add_type_alias('ns3::Vector3D', 'ns3::Vector') + module.add_typedef(root_module['ns3::Vector3D'], 'Vector') + typehandlers.add_type_alias('ns3::Vector3DValue', 'ns3::VectorValue') + module.add_typedef(root_module['ns3::Vector3DValue'], 'VectorValue') + typehandlers.add_type_alias('ns3::Vector3DChecker', 'ns3::VectorChecker') + module.add_typedef(root_module['ns3::Vector3DChecker'], 'VectorChecker') ## Register a nested module for the namespace Config @@ -261,6 +279,8 @@ def register_methods(root_module): register_Ns3TypeIdAttributeInfo_methods(root_module, root_module['ns3::TypeId::AttributeInfo']) register_Ns3UniformVariable_methods(root_module, root_module['ns3::UniformVariable']) register_Ns3UnsafeAttributeList_methods(root_module, root_module['ns3::UnsafeAttributeList']) + register_Ns3Vector2D_methods(root_module, root_module['ns3::Vector2D']) + register_Ns3Vector3D_methods(root_module, root_module['ns3::Vector3D']) register_Ns3WeibullVariable_methods(root_module, root_module['ns3::WeibullVariable']) register_Ns3ZipfVariable_methods(root_module, root_module['ns3::ZipfVariable']) register_Ns3Empty_methods(root_module, root_module['ns3::empty']) @@ -302,6 +322,10 @@ def register_methods(root_module): register_Ns3TypeIdChecker_methods(root_module, root_module['ns3::TypeIdChecker']) register_Ns3TypeIdValue_methods(root_module, root_module['ns3::TypeIdValue']) register_Ns3UintegerValue_methods(root_module, root_module['ns3::UintegerValue']) + register_Ns3Vector2DChecker_methods(root_module, root_module['ns3::Vector2DChecker']) + register_Ns3Vector2DValue_methods(root_module, root_module['ns3::Vector2DValue']) + register_Ns3Vector3DChecker_methods(root_module, root_module['ns3::Vector3DChecker']) + register_Ns3Vector3DValue_methods(root_module, root_module['ns3::Vector3DValue']) register_Ns3TracedValue__Unsigned_int_methods(root_module, root_module['ns3::TracedValue< unsigned int >']) register_Ns3ConfigMatchContainer_methods(root_module, root_module['ns3::Config::MatchContainer']) return @@ -1180,6 +1204,36 @@ def register_Ns3UnsafeAttributeList_methods(root_module, cls): is_const=True) return +def register_Ns3Vector2D_methods(root_module, cls): + cls.add_output_stream_operator() + ## vector.h: ns3::Vector2D::Vector2D(ns3::Vector2D const & arg0) [copy constructor] + cls.add_constructor([param('ns3::Vector2D const &', 'arg0')]) + ## vector.h: ns3::Vector2D::Vector2D(double _x, double _y) [constructor] + cls.add_constructor([param('double', '_x'), param('double', '_y')]) + ## vector.h: ns3::Vector2D::Vector2D() [constructor] + cls.add_constructor([]) + ## vector.h: ns3::Vector2D::x [variable] + cls.add_instance_attribute('x', 'double', is_const=False) + ## vector.h: ns3::Vector2D::y [variable] + cls.add_instance_attribute('y', 'double', is_const=False) + return + +def register_Ns3Vector3D_methods(root_module, cls): + cls.add_output_stream_operator() + ## vector.h: ns3::Vector3D::Vector3D(ns3::Vector3D const & arg0) [copy constructor] + cls.add_constructor([param('ns3::Vector3D const &', 'arg0')]) + ## vector.h: ns3::Vector3D::Vector3D(double _x, double _y, double _z) [constructor] + cls.add_constructor([param('double', '_x'), param('double', '_y'), param('double', '_z')]) + ## vector.h: ns3::Vector3D::Vector3D() [constructor] + cls.add_constructor([]) + ## vector.h: ns3::Vector3D::x [variable] + cls.add_instance_attribute('x', 'double', is_const=False) + ## vector.h: ns3::Vector3D::y [variable] + cls.add_instance_attribute('y', 'double', is_const=False) + ## vector.h: ns3::Vector3D::z [variable] + cls.add_instance_attribute('z', 'double', is_const=False) + return + def register_Ns3WeibullVariable_methods(root_module, cls): ## random-variable.h: ns3::WeibullVariable::WeibullVariable(ns3::WeibullVariable const & arg0) [copy constructor] cls.add_constructor([param('ns3::WeibullVariable const &', 'arg0')]) @@ -2046,6 +2100,86 @@ def register_Ns3UintegerValue_methods(root_module, cls): is_virtual=True) return +def register_Ns3Vector2DChecker_methods(root_module, cls): + ## vector.h: ns3::Vector2DChecker::Vector2DChecker(ns3::Vector2DChecker const & arg0) [copy constructor] + cls.add_constructor([param('ns3::Vector2DChecker const &', 'arg0')]) + ## vector.h: ns3::Vector2DChecker::Vector2DChecker() [constructor] + cls.add_constructor([]) + return + +def register_Ns3Vector2DValue_methods(root_module, cls): + ## vector.h: ns3::Vector2DValue::Vector2DValue(ns3::Vector2DValue const & arg0) [copy constructor] + cls.add_constructor([param('ns3::Vector2DValue const &', 'arg0')]) + ## vector.h: ns3::Vector2DValue::Vector2DValue() [constructor] + cls.add_constructor([]) + ## vector.h: ns3::Vector2DValue::Vector2DValue(ns3::Vector2D const & value) [constructor] + cls.add_constructor([param('ns3::Vector2D const &', 'value')]) + ## vector.h: void ns3::Vector2DValue::Set(ns3::Vector2D const & value) [member function] + cls.add_method('Set', + 'void', + [param('ns3::Vector2D const &', 'value')]) + ## vector.h: ns3::Vector2D ns3::Vector2DValue::Get() const [member function] + cls.add_method('Get', + 'ns3::Vector2D', + [], + is_const=True) + ## vector.h: ns3::Ptr ns3::Vector2DValue::Copy() const [member function] + cls.add_method('Copy', + 'ns3::Ptr< ns3::AttributeValue >', + [], + is_const=True, is_virtual=True) + ## vector.h: std::string ns3::Vector2DValue::SerializeToString(ns3::Ptr checker) const [member function] + cls.add_method('SerializeToString', + 'std::string', + [param('ns3::Ptr< ns3::AttributeChecker const >', 'checker')], + is_const=True, is_virtual=True) + ## vector.h: bool ns3::Vector2DValue::DeserializeFromString(std::string value, ns3::Ptr checker) [member function] + cls.add_method('DeserializeFromString', + 'bool', + [param('std::string', 'value'), param('ns3::Ptr< ns3::AttributeChecker const >', 'checker')], + is_virtual=True) + return + +def register_Ns3Vector3DChecker_methods(root_module, cls): + ## vector.h: ns3::Vector3DChecker::Vector3DChecker(ns3::Vector3DChecker const & arg0) [copy constructor] + cls.add_constructor([param('ns3::Vector3DChecker const &', 'arg0')]) + ## vector.h: ns3::Vector3DChecker::Vector3DChecker() [constructor] + cls.add_constructor([]) + return + +def register_Ns3Vector3DValue_methods(root_module, cls): + ## vector.h: ns3::Vector3DValue::Vector3DValue(ns3::Vector3DValue const & arg0) [copy constructor] + cls.add_constructor([param('ns3::Vector3DValue const &', 'arg0')]) + ## vector.h: ns3::Vector3DValue::Vector3DValue() [constructor] + cls.add_constructor([]) + ## vector.h: ns3::Vector3DValue::Vector3DValue(ns3::Vector3D const & value) [constructor] + cls.add_constructor([param('ns3::Vector3D const &', 'value')]) + ## vector.h: void ns3::Vector3DValue::Set(ns3::Vector3D const & value) [member function] + cls.add_method('Set', + 'void', + [param('ns3::Vector3D const &', 'value')]) + ## vector.h: ns3::Vector3D ns3::Vector3DValue::Get() const [member function] + cls.add_method('Get', + 'ns3::Vector3D', + [], + is_const=True) + ## vector.h: ns3::Ptr ns3::Vector3DValue::Copy() const [member function] + cls.add_method('Copy', + 'ns3::Ptr< ns3::AttributeValue >', + [], + is_const=True, is_virtual=True) + ## vector.h: std::string ns3::Vector3DValue::SerializeToString(ns3::Ptr checker) const [member function] + cls.add_method('SerializeToString', + 'std::string', + [param('ns3::Ptr< ns3::AttributeChecker const >', 'checker')], + is_const=True, is_virtual=True) + ## vector.h: bool ns3::Vector3DValue::DeserializeFromString(std::string value, ns3::Ptr checker) [member function] + cls.add_method('DeserializeFromString', + 'bool', + [param('std::string', 'value'), param('ns3::Ptr< ns3::AttributeChecker const >', 'checker')], + is_virtual=True) + return + def register_Ns3TracedValue__Unsigned_int_methods(root_module, cls): ## traced-value.h: ns3::TracedValue::TracedValue() [constructor] cls.add_constructor([]) @@ -2153,6 +2287,14 @@ def register_functions(root_module): module.add_function('BreakpointFallback', 'void', []) + ## vector.h: extern double ns3::CalculateDistance(ns3::Vector2D const & a, ns3::Vector2D const & b) [free function] + module.add_function('CalculateDistance', + 'double', + [param('ns3::Vector2D const &', 'a'), param('ns3::Vector2D const &', 'b')]) + ## vector.h: extern double ns3::CalculateDistance(ns3::Vector3D const & a, ns3::Vector3D const & b) [free function] + module.add_function('CalculateDistance', + 'double', + [param('ns3::Vector3D const &', 'a'), param('ns3::Vector3D const &', 'b')]) ## ptr.h: extern ns3::Ptr ns3::Create() [free function] module.add_function('Create', 'ns3::Ptr< ns3::ObjectVectorValue >', @@ -2207,6 +2349,18 @@ def register_functions(root_module): module.add_function('MakeTypeIdChecker', 'ns3::Ptr< ns3::AttributeChecker const >', []) + ## vector.h: extern ns3::Ptr ns3::MakeVector2DChecker() [free function] + module.add_function('MakeVector2DChecker', + 'ns3::Ptr< ns3::AttributeChecker const >', + []) + ## vector.h: extern ns3::Ptr ns3::MakeVector3DChecker() [free function] + module.add_function('MakeVector3DChecker', + 'ns3::Ptr< ns3::AttributeChecker const >', + []) + ## vector.h: extern ns3::Ptr ns3::MakeVectorChecker() [free function] + module.add_function('MakeVectorChecker', + 'ns3::Ptr< ns3::AttributeChecker const >', + []) ## type-name.h: extern std::string ns3::TypeNameGet() [free function] module.add_function('TypeNameGet', 'std::string', diff --git a/bindings/python/ns3_module_mobility.py b/bindings/python/ns3_module_mobility.py index fdf2f0bdd..4b89e1731 100644 --- a/bindings/python/ns3_module_mobility.py +++ b/bindings/python/ns3_module_mobility.py @@ -9,8 +9,6 @@ def register_types(module): module.add_class('Rectangle') ## rectangle.h: ns3::Rectangle::Side [enumeration] module.add_enum('Side', ['RIGHT', 'LEFT', 'TOP', 'BOTTOM'], outer_class=root_module['ns3::Rectangle']) - ## vector.h: ns3::Vector [class] - module.add_class('Vector') ## position-allocator.h: ns3::PositionAllocator [class] module.add_class('PositionAllocator', parent=root_module['ns3::Object']) ## position-allocator.h: ns3::RandomDiscPositionAllocator [class] @@ -21,10 +19,6 @@ def register_types(module): module.add_class('RectangleChecker', parent=root_module['ns3::AttributeChecker']) ## rectangle.h: ns3::RectangleValue [class] module.add_class('RectangleValue', parent=root_module['ns3::AttributeValue']) - ## vector.h: ns3::VectorChecker [class] - module.add_class('VectorChecker', parent=root_module['ns3::AttributeChecker']) - ## vector.h: ns3::VectorValue [class] - module.add_class('VectorValue', parent=root_module['ns3::AttributeValue']) ## position-allocator.h: ns3::GridPositionAllocator [class] module.add_class('GridPositionAllocator', parent=root_module['ns3::PositionAllocator']) ## position-allocator.h: ns3::GridPositionAllocator::LayoutType [enumeration] @@ -103,14 +97,11 @@ def register_types_ns3_olsr(module): def register_methods(root_module): register_Ns3ConstantVelocityHelper_methods(root_module, root_module['ns3::ConstantVelocityHelper']) register_Ns3Rectangle_methods(root_module, root_module['ns3::Rectangle']) - register_Ns3Vector_methods(root_module, root_module['ns3::Vector']) register_Ns3PositionAllocator_methods(root_module, root_module['ns3::PositionAllocator']) register_Ns3RandomDiscPositionAllocator_methods(root_module, root_module['ns3::RandomDiscPositionAllocator']) register_Ns3RandomRectanglePositionAllocator_methods(root_module, root_module['ns3::RandomRectanglePositionAllocator']) register_Ns3RectangleChecker_methods(root_module, root_module['ns3::RectangleChecker']) register_Ns3RectangleValue_methods(root_module, root_module['ns3::RectangleValue']) - register_Ns3VectorChecker_methods(root_module, root_module['ns3::VectorChecker']) - register_Ns3VectorValue_methods(root_module, root_module['ns3::VectorValue']) register_Ns3GridPositionAllocator_methods(root_module, root_module['ns3::GridPositionAllocator']) register_Ns3ListPositionAllocator_methods(root_module, root_module['ns3::ListPositionAllocator']) register_Ns3MobilityModel_methods(root_module, root_module['ns3::MobilityModel']) @@ -203,22 +194,6 @@ def register_Ns3Rectangle_methods(root_module, cls): cls.add_instance_attribute('yMin', 'double', is_const=False) return -def register_Ns3Vector_methods(root_module, cls): - cls.add_output_stream_operator() - ## vector.h: ns3::Vector::Vector(ns3::Vector const & arg0) [copy constructor] - cls.add_constructor([param('ns3::Vector const &', 'arg0')]) - ## vector.h: ns3::Vector::Vector(double _x, double _y, double _z) [constructor] - cls.add_constructor([param('double', '_x'), param('double', '_y'), param('double', '_z')]) - ## vector.h: ns3::Vector::Vector() [constructor] - cls.add_constructor([]) - ## vector.h: ns3::Vector::x [variable] - cls.add_instance_attribute('x', 'double', is_const=False) - ## vector.h: ns3::Vector::y [variable] - cls.add_instance_attribute('y', 'double', is_const=False) - ## vector.h: ns3::Vector::z [variable] - cls.add_instance_attribute('z', 'double', is_const=False) - return - def register_Ns3PositionAllocator_methods(root_module, cls): ## position-allocator.h: ns3::PositionAllocator::PositionAllocator(ns3::PositionAllocator const & arg0) [copy constructor] cls.add_constructor([param('ns3::PositionAllocator const &', 'arg0')]) @@ -334,46 +309,6 @@ def register_Ns3RectangleValue_methods(root_module, cls): is_virtual=True) return -def register_Ns3VectorChecker_methods(root_module, cls): - ## vector.h: ns3::VectorChecker::VectorChecker(ns3::VectorChecker const & arg0) [copy constructor] - cls.add_constructor([param('ns3::VectorChecker const &', 'arg0')]) - ## vector.h: ns3::VectorChecker::VectorChecker() [constructor] - cls.add_constructor([]) - return - -def register_Ns3VectorValue_methods(root_module, cls): - ## vector.h: ns3::VectorValue::VectorValue(ns3::VectorValue const & arg0) [copy constructor] - cls.add_constructor([param('ns3::VectorValue const &', 'arg0')]) - ## vector.h: ns3::VectorValue::VectorValue() [constructor] - cls.add_constructor([]) - ## vector.h: ns3::VectorValue::VectorValue(ns3::Vector const & value) [constructor] - cls.add_constructor([param('ns3::Vector const &', 'value')]) - ## vector.h: void ns3::VectorValue::Set(ns3::Vector const & value) [member function] - cls.add_method('Set', - 'void', - [param('ns3::Vector const &', 'value')]) - ## vector.h: ns3::Vector ns3::VectorValue::Get() const [member function] - cls.add_method('Get', - 'ns3::Vector', - [], - is_const=True) - ## vector.h: ns3::Ptr ns3::VectorValue::Copy() const [member function] - cls.add_method('Copy', - 'ns3::Ptr< ns3::AttributeValue >', - [], - is_const=True, is_virtual=True) - ## vector.h: std::string ns3::VectorValue::SerializeToString(ns3::Ptr checker) const [member function] - cls.add_method('SerializeToString', - 'std::string', - [param('ns3::Ptr< ns3::AttributeChecker const >', 'checker')], - is_const=True, is_virtual=True) - ## vector.h: bool ns3::VectorValue::DeserializeFromString(std::string value, ns3::Ptr checker) [member function] - cls.add_method('DeserializeFromString', - 'bool', - [param('std::string', 'value'), param('ns3::Ptr< ns3::AttributeChecker const >', 'checker')], - is_virtual=True) - return - def register_Ns3GridPositionAllocator_methods(root_module, cls): ## position-allocator.h: ns3::GridPositionAllocator::GridPositionAllocator(ns3::GridPositionAllocator const & arg0) [copy constructor] cls.add_constructor([param('ns3::GridPositionAllocator const &', 'arg0')]) @@ -744,18 +679,10 @@ def register_Ns3HierarchicalMobilityModel_methods(root_module, cls): def register_functions(root_module): module = root_module - ## vector.h: extern double ns3::CalculateDistance(ns3::Vector const & a, ns3::Vector const & b) [free function] - module.add_function('CalculateDistance', - 'double', - [param('ns3::Vector const &', 'a'), param('ns3::Vector const &', 'b')]) ## rectangle.h: extern ns3::Ptr ns3::MakeRectangleChecker() [free function] module.add_function('MakeRectangleChecker', 'ns3::Ptr< ns3::AttributeChecker const >', []) - ## vector.h: extern ns3::Ptr ns3::MakeVectorChecker() [free function] - module.add_function('MakeVectorChecker', - 'ns3::Ptr< ns3::AttributeChecker const >', - []) register_functions_ns3_Config(module.get_submodule('Config'), root_module) register_functions_ns3_TimeStepPrecision(module.get_submodule('TimeStepPrecision'), root_module) register_functions_ns3_addressUtils(module.get_submodule('addressUtils'), root_module) diff --git a/examples/wifi-clear-channel-cmu.cc b/examples/wifi-clear-channel-cmu.cc index 4028d6789..219f90b20 100644 --- a/examples/wifi-clear-channel-cmu.cc +++ b/examples/wifi-clear-channel-cmu.cc @@ -197,7 +197,8 @@ int main (int argc, char *argv[]) wifi.SetRemoteStationManager ("ns3::ConstantRateWifiManager", "DataMode",StringValue(modes[i]), "ControlMode",StringValue(modes[i])); - wifiMac.SetType ("ns3::AdhocWifiMac"); + wifiMac.SetType ("ns3::AdhocWifiMac", + "Standard",StringValue ("802.11b")); YansWifiPhyHelper wifiPhy = YansWifiPhyHelper::Default (); YansWifiChannelHelper wifiChannel ; diff --git a/src/mobility/vector.cc b/src/core/vector.cc similarity index 56% rename from src/mobility/vector.cc rename to src/core/vector.cc index 32da74326..03e96ce42 100644 --- a/src/mobility/vector.cc +++ b/src/core/vector.cc @@ -24,23 +24,39 @@ namespace ns3 { -ATTRIBUTE_HELPER_CPP (Vector); +ATTRIBUTE_HELPER_CPP (Vector3D); +ATTRIBUTE_HELPER_CPP (Vector2D); + // compatibility for mobility code +Ptr MakeVectorChecker (void) +{ + return MakeVector3DChecker (); +} -Vector::Vector (double _x, double _y, double _z) +Vector3D::Vector3D (double _x, double _y, double _z) : x (_x), y (_y), z (_z) {} -Vector::Vector () +Vector3D::Vector3D () : x (0.0), y (0.0), z (0.0) {} +Vector2D::Vector2D (double _x, double _y) + : x (_x), + y (_y) +{} + +Vector2D::Vector2D () + : x (0.0), + y (0.0) +{} + double -CalculateDistance (const Vector &a, const Vector &b) +CalculateDistance (const Vector3D &a, const Vector3D &b) { double dx = b.x - a.x; double dy = b.y - a.y; @@ -48,13 +64,21 @@ CalculateDistance (const Vector &a, const Vector &b) double distance = std::sqrt (dx * dx + dy * dy + dz * dz); return distance; } +double +CalculateDistance (const Vector2D &a, const Vector2D &b) +{ + double dx = b.x - a.x; + double dy = b.y - a.y; + double distance = std::sqrt (dx * dx + dy * dy); + return distance; +} -std::ostream &operator << (std::ostream &os, const Vector &vector) +std::ostream &operator << (std::ostream &os, const Vector3D &vector) { os << vector.x << ":" << vector.y << ":" << vector.z; return os; } -std::istream &operator >> (std::istream &is, Vector &vector) +std::istream &operator >> (std::istream &is, Vector3D &vector) { char c1, c2; is >> vector.x >> c1 >> vector.y >> c2 >> vector.z; @@ -65,5 +89,20 @@ std::istream &operator >> (std::istream &is, Vector &vector) } return is; } +std::ostream &operator << (std::ostream &os, const Vector2D &vector) +{ + os << vector.x << ":" << vector.y; + return os; +} +std::istream &operator >> (std::istream &is, Vector2D &vector) +{ + char c1; + is >> vector.x >> c1 >> vector.y; + if (c1 != ':') + { + is.setstate (std::ios_base::failbit); + } + return is; +} } // namespace ns3 diff --git a/src/core/vector.h b/src/core/vector.h new file mode 100644 index 000000000..434765e9e --- /dev/null +++ b/src/core/vector.h @@ -0,0 +1,126 @@ +/* -*- Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil; -*- */ +/* + * Copyright (c) 2007 INRIA + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2 as + * published by the Free Software Foundation; + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + * Author: Mathieu Lacage + */ +#ifndef NS3_VECTOR_H +#define NS3_VECTOR_H + +#include "ns3/attribute.h" +#include "ns3/attribute-helper.h" + +namespace ns3 { + +/** + * \brief a 3d vector + */ +class Vector3D +{ +public: + /** + * \param _x x coordinate of vector + * \param _y y coordinate of vector + * \param _z z coordinate of vector + * + * Create vector (_x, _y, _z) + */ + Vector3D (double _x, double _y, double _z); + /** + * Create vector (0.0, 0.0, 0.0) + */ + Vector3D (); + /** + * x coordinate of vector + */ + double x; + /** + * y coordinate of vector + */ + double y; + /** + * z coordinate of vector + */ + double z; +}; + +/** + * \brief a 3d vector + */ +class Vector2D +{ +public: + /** + * \param _x x coordinate of vector + * \param _y y coordinate of vector + * + * Create vector (_x, _y) + */ + Vector2D (double _x, double _y); + /** + * Create vector vector (0.0, 0.0) + */ + Vector2D (); + /** + * x coordinate of vector + */ + double x; + /** + * y coordinate of vector + */ + double y; +}; + +/** + * \param a one point + * \param b another point + * \returns the cartesian distance between a and b. + */ +double CalculateDistance (const Vector3D &a, const Vector3D &b); + +/** + * \param a one point + * \param b another point + * \returns the cartesian distance between a and b. + */ +double CalculateDistance (const Vector2D &a, const Vector2D &b); + +/** + * \class ns3::Vector3DValue + * \brief hold objects of type ns3::Vector3D + */ +/** + * \class ns3::Vector2DValue + * \brief hold objects of type ns3::Vector2D + */ +ATTRIBUTE_HELPER_HEADER (Vector3D); +ATTRIBUTE_HELPER_HEADER (Vector2D); + +std::ostream &operator << (std::ostream &os, const Vector3D &vector); +std::istream &operator >> (std::istream &is, Vector3D &vector); +std::ostream &operator << (std::ostream &os, const Vector2D &vector); +std::istream &operator >> (std::istream &is, Vector2D &vector); + +// for compatibility with mobility models +typedef Vector3D Vector; +typedef Vector3DValue VectorValue; +typedef Vector3DChecker VectorChecker; +ATTRIBUTE_ACCESSOR_DEFINE(Vector); +Ptr MakeVectorChecker (void); + +} // namespace ns3 + +#endif /* NS3_VECTOR_H */ diff --git a/src/core/wscript b/src/core/wscript index 1c8a5de37..b75c99e8b 100644 --- a/src/core/wscript +++ b/src/core/wscript @@ -78,6 +78,7 @@ def build(bld): 'config.cc', 'callback.cc', 'names.cc', + 'vector.cc', ] headers = bld.new_task_gen('ns3header') @@ -123,6 +124,7 @@ def build(bld): 'deprecated.h', 'abort.h', 'names.h', + 'vector.h', ] if sys.platform == 'win32': diff --git a/src/mobility/constant-position-mobility-model.h b/src/mobility/constant-position-mobility-model.h index 31aa2e978..ee9c894c7 100644 --- a/src/mobility/constant-position-mobility-model.h +++ b/src/mobility/constant-position-mobility-model.h @@ -21,7 +21,6 @@ #define CONSTANT_POSITION_MOBILITY_MODEL_H #include "mobility-model.h" -#include "vector.h" namespace ns3 { diff --git a/src/mobility/constant-velocity-helper.h b/src/mobility/constant-velocity-helper.h index 3430381e6..95346d4a1 100644 --- a/src/mobility/constant-velocity-helper.h +++ b/src/mobility/constant-velocity-helper.h @@ -21,7 +21,7 @@ #define CONSTANT_VELOCITY_HELPER_H #include "ns3/nstime.h" -#include "vector.h" +#include "ns3/vector.h" namespace ns3 { diff --git a/src/mobility/constant-velocity-mobility-model.h b/src/mobility/constant-velocity-mobility-model.h index 6db3312ec..8936c3ad0 100644 --- a/src/mobility/constant-velocity-mobility-model.h +++ b/src/mobility/constant-velocity-mobility-model.h @@ -21,8 +21,8 @@ #define CONSTANT_VELOCITY_MOBILITY_MODEL_H #include -#include "mobility-model.h" #include "ns3/nstime.h" +#include "mobility-model.h" #include "constant-velocity-helper.h" namespace ns3 { diff --git a/src/mobility/mobility-model.h b/src/mobility/mobility-model.h index 1d58baf9e..6fd268c37 100644 --- a/src/mobility/mobility-model.h +++ b/src/mobility/mobility-model.h @@ -20,8 +20,7 @@ #ifndef MOBILITY_MODEL_H #define MOBILITY_MODEL_H -#include "vector.h" - +#include "ns3/vector.h" #include "ns3/object.h" #include "ns3/traced-callback.h" diff --git a/src/mobility/position-allocator.h b/src/mobility/position-allocator.h index e9756896c..da6f49f0b 100644 --- a/src/mobility/position-allocator.h +++ b/src/mobility/position-allocator.h @@ -22,7 +22,7 @@ #include "ns3/object.h" #include "ns3/random-variable.h" -#include "vector.h" +#include "ns3/vector.h" namespace ns3 { diff --git a/src/mobility/rectangle.cc b/src/mobility/rectangle.cc index 6a0c5e221..ee5e29f0f 100644 --- a/src/mobility/rectangle.cc +++ b/src/mobility/rectangle.cc @@ -18,7 +18,7 @@ * Author: Mathieu Lacage */ #include "rectangle.h" -#include "vector.h" +#include "ns3/vector.h" #include "ns3/assert.h" #include "ns3/fatal-error.h" #include diff --git a/src/mobility/rectangle.h b/src/mobility/rectangle.h index fcc8fc1cb..90d147736 100644 --- a/src/mobility/rectangle.h +++ b/src/mobility/rectangle.h @@ -22,11 +22,10 @@ #include "ns3/attribute.h" #include "ns3/attribute-helper.h" +#include "ns3/vector.h" namespace ns3 { -class Vector; - /** * \brief a 2d rectangle */ diff --git a/src/mobility/vector.h b/src/mobility/vector.h deleted file mode 100644 index e3e3191aa..000000000 --- a/src/mobility/vector.h +++ /dev/null @@ -1,81 +0,0 @@ -/* -*- Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil; -*- */ -/* - * Copyright (c) 2007 INRIA - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License version 2 as - * published by the Free Software Foundation; - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - * - * Author: Mathieu Lacage - */ -#ifndef VECTOR_H -#define VECTOR_H - -#include "ns3/attribute.h" -#include "ns3/attribute-helper.h" - -namespace ns3 { - -/** - * \brief a 3d cartesian position vector - * - * Unit is meters. - */ -class Vector -{ -public: - /** - * \param _x x coordinate of vector vector - * \param _y y coordinate of vector vector - * \param _z z coordinate of vector vector - * - * Create vector vector (_x, _y, _z) - */ - Vector (double _x, double _y, double _z); - /** - * Create vector vector (0.0, 0.0, 0.0) - */ - Vector (); - /** - * x coordinate of vector vector - */ - double x; - /** - * y coordinate of vector vector - */ - double y; - /** - * z coordinate of vector vector - */ - double z; -}; - -/** - * \param a one point - * \param b another point - * \returns the cartesian distance between a and b. - */ -double CalculateDistance (const Vector &a, const Vector &b); - -/** - * \class ns3::VectorValue - * \brief hold objects of type ns3::Vector - */ - -ATTRIBUTE_HELPER_HEADER (Vector); - -std::ostream &operator << (std::ostream &os, const Vector &vector); -std::istream &operator >> (std::istream &is, Vector &vector); - -} // namespace ns3 - -#endif /* VECTOR_H */ diff --git a/src/mobility/wscript b/src/mobility/wscript index ad368ebbf..6bcfd2e5c 100644 --- a/src/mobility/wscript +++ b/src/mobility/wscript @@ -3,7 +3,6 @@ def build(bld): mobility = bld.create_ns3_module('mobility', ['core', 'simulator']) mobility.source = [ - 'vector.cc', 'hierarchical-mobility-model.cc', 'mobility-model.cc', 'position-allocator.cc', @@ -20,7 +19,6 @@ def build(bld): headers = bld.new_task_gen('ns3header') headers.module = 'mobility' headers.source = [ - 'vector.h', 'hierarchical-mobility-model.h', 'mobility-model.h', 'position-allocator.h',