This commit is contained in:
Mathieu Lacage
2007-07-19 11:31:17 +02:00
parent 7033df8c0c
commit de8d7725be
2 changed files with 85 additions and 0 deletions

View File

@@ -9,20 +9,42 @@ namespace ns3 {
class RandomVariable;
/**
* \brief choose a position at random.
*
* This is a pure abstract base class.
*/
class RandomPosition : public Object
{
public:
static const InterfaceId iid;
RandomPosition ();
virtual ~RandomPosition ();
/**
* \returns the next randomly-choosen position.
*/
virtual Position Get (void) const = 0;
};
/**
* \brief allocate random positions within a rectangle
* according to a pair of random variables.
*/
class RandomRectanglePosition : public RandomPosition
{
public:
static const ClassId cid;
/**
* Create a random position model based on the
* Bind default values.
*/
RandomRectanglePosition ();
/**
* \param x the random variable which is used to choose
* the x coordinates.
* \param y the random variable which is used to choose
* the y coordinates.
*/
RandomRectanglePosition (const RandomVariable &x,
const RandomVariable &y);
virtual ~RandomRectanglePosition ();
@@ -32,11 +54,31 @@ private:
RandomVariable *m_y;
};
/**
* \brief allocate random positions within a disc
* according to a pair of random variables.
*/
class RandomDiscPosition : public RandomPosition
{
public:
static const ClassId cid;
/**
* Create a random position model based on the
* Bind default values.
*/
RandomDiscPosition ();
/**
* \param theta the random variable used to pick
* the angle of the random position in polar
* coordinates.
* \param rho the random variable used to pick the
* radius of the random position in polar
* coordinates.
* \param x the x coordinate of the center of the
* polar coodinate system.
* \param y the y coordinate of the center of the
* polar coodinate system.
*/
RandomDiscPosition (const RandomVariable &theta,
const RandomVariable &rho,
double x, double y);

View File

@@ -29,20 +29,63 @@ namespace ns3 {
class RandomPosition;
/**
* \brief layout objects randomly in 3d space.
*
* This assigns an initial position to each object
* according to its position model and assigns
* an instance of a mobility model to each object
* according to its mobility model class id.
*/
class RandomTopology
{
public:
/**
* Create a default random topology based
* on Bind configuration.
*/
RandomTopology ();
/**
* \param positionModel model to set the initial position
* of each object.
* \param type of mobility model to attach to each object.
*
* Create a random topology based on the
* specified position and mobility models.
*/
RandomTopology (Ptr<RandomPosition> positionModel,
ClassId mobilityModel);
~RandomTopology ();
/**
* \param classId the type of mobility model attached to each
* input object if it does not have one already.
*/
void SetMobilityModel (ClassId classId);
/**
* \param positionModel the position model used to initialize
* the position of each object.
*/
void SetPositionModel (Ptr<RandomPosition> positionModel);
/**
* \param object the object to layout
*
* Assign an initial position and a mobility model
* to the object.
*/
void LayoutOne (Ptr<Object> object);
/**
* \param begin iterator which identifies the first
* object to configure.
* \param end iterator which identifies the last
* object to configure.
*
* Assign an initial position and a mobility model
* to the objects.
*/
template <typename T>
void Layout (const T &begin, const T &end);
private: