CSCI 3081 - Drone Delivery System
Public Member Functions | List of all members
csci3081::Package Class Reference

A representation of a Package, inherited from EntityBase It stores the Package's name, ID, version, position, direction, and dynamic mode. More...

#include <package.h>

Inheritance diagram for csci3081::Package:
Inheritance graph

Public Member Functions

 Package (const picojson::object &detail)
 
 Package (Package &package)
 Copy Constructor. This creates a new instance of Package that has the same content as the Package argument. More...
 
void SetOwner (Customer *)
 This links a customer object to the package object if the package has not already had a customer. More...
 
CustomerGetOwner ()
 This returns a customer object of the package object if there is one, return NULL otherwise.
 
void SetPosition (std::vector< float > agr)
 This function uses to set the new position of the package. However, package only moves in simulation if its dynamic attribute is set to true. More...
 
void SetCarrier (IEntity *)
 This links a carrier Entity object (drone, truck, robot, etc) to the package object if the package has not already had a one. More...
 
IEntityGetCarrier ()
 This returns the pointer that points to the carrier carrying the package if there is one; return NULL otherwise.
 
void SetDynamic (bool n)
 This changes the dynamic of the drone. Note that for the drone to move on the simulation, dynamic of the drone must be set to true. More...
 
void Deliver ()
 This sets the deliverd attribute of the package to true, signaling that the package has already been delivered. Change the carrier of the package to NULL. Change the position of the package to out of the camera of the simulation to "teleport" out of the scene when delivered.
 
bool IsDelivered ()
 This returns a TRUE if the package has been delivered, FALSE otherwise.
 
void GetStatus ()
 Overwritten GetStatus from ASubject. This function creates the arguments required by Notify function and makes call to Notify function. This function should be called when path is added to the package is schedule to deliver, en route (picked up) or delivered.
 
void Update (float dt)
 This is an inherited method from EntityBase to use for DeliverySimulation. This updates the position of the package on the simulation if the position changes and its dynamic is set to true.
 
- Public Member Functions inherited from csci3081::EntityBase
const picojson::object & GetDetails ()
 
int GetId () const
 
const std::string & GetName ()
 
const std::vector< float > & GetPosition () const
 
const std::vector< float > & GetDirection () const
 
float GetRadius () const
 
int GetVersion () const
 
bool IsDynamic () const
 
float DistanceBetween (IEntity *another)
 
bool IsWithin (IEntity *another)
 
std::string GetType ()
 
- Public Member Functions inherited from entity_project::IEntity
virtual ~IEntity ()
 The destructor.
 
- Public Member Functions inherited from csci3081::ASubject
void Attach (entity_project::IEntityObserver *observer)
 Adds an observer to the list of observers for this subject. More...
 
void Detach (entity_project::IEntityObserver *observer)
 Deletes an observer from the list of observers for this subject. More...
 
std::vector< entity_project::IEntityObserver * > GetList ()
 Getter function for the list of observers (mostly used in testing) More...
 
void Notify (picojson::value &event, const entity_project::IEntity &entity)
 Sends out Notification to the observer watching this subject. More...
 

Additional Inherited Members

- Protected Attributes inherited from csci3081::EntityBase
std::string name
 
int ID
 
std::vector< float > position
 
std::vector< float > direction
 
bool dynamic
 
int version
 
float radius
 
std::string type
 
picojson::object details
 
- Protected Attributes inherited from csci3081::ASubject
std::vector< entity_project::IEntityObserver * > list
 List of pointers to the observers for this subject.
 

Detailed Description

A representation of a Package, inherited from EntityBase It stores the Package's name, ID, version, position, direction, and dynamic mode.

Constructor & Destructor Documentation

◆ Package() [1/2]

csci3081::Package::Package ( const picojson::object &  detail)

Constructor, creates a Package object param[in] detail a picojson::object object that has the detail of the package including name, position, direction, and radius

◆ Package() [2/2]

csci3081::Package::Package ( Package package)

Copy Constructor. This creates a new instance of Package that has the same content as the Package argument.

Parameters
[in]packagePackage instance that wants to be copied

Member Function Documentation

◆ SetCarrier()

void csci3081::Package::SetCarrier ( IEntity ve)

This links a carrier Entity object (drone, truck, robot, etc) to the package object if the package has not already had a one.

Parameters
[in]oa IEntity pointer

◆ SetDynamic()

void csci3081::Package::SetDynamic ( bool  n)

This changes the dynamic of the drone. Note that for the drone to move on the simulation, dynamic of the drone must be set to true.

Parameters
[in]nTrue if the drone is actively moving in the simulation False otherwise

◆ SetOwner()

void csci3081::Package::SetOwner ( Customer o)

This links a customer object to the package object if the package has not already had a customer.

Parameters
[in]oa Customer pointer

◆ SetPosition()

void csci3081::Package::SetPosition ( std::vector< float >  agr)

This function uses to set the new position of the package. However, package only moves in simulation if its dynamic attribute is set to true.

Parameters
agra std::vector<float> that has the new position of the package

The documentation for this class was generated from the following files: