//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// Copyright (c) 2015, University of Osnabrueck                                                                         //
//   All rights reserved.                                                                                               //
//                                                                                                                      //
//   Redistribution and use in source and binary forms, with or without modification, are permitted provided that the   //
//   following conditions are met:                                                                                      //
//                                                                                                                      //
//   1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following//
//       disclaimer.                                                                                                    //
//                                                                                                                      //
//   2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the       //
//       following disclaimer in the documentation and/or other materials provided with the distribution.               //
//                                                                                                                      //
//   THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, //
//   INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE  //
//   DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, //
//   SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR    //
//   SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,  //
//   WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE   //
//   USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.                                           //
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
#ifndef RALANS_PROPAGATION_LOSS_MODEL_H
#define RALANS_PROPAGATION_LOSS_MODEL_H

#include <ns3/propagation-loss-model.h>
#include <ns3/ralans-alone.h>
#include <ns3/propagation-environment.h>
#include <string>
#include <vector>
#include <ns3/boolean.h>

namespace ns3 {

	/**
	 * \ingroup propagation
	 *
	 * \brief a propagation model for RaLaNS.
	 * 
	 * Can be used with the RaLaNS to work with networks in ns3.
	 *
	 * This class is a sort of wrapper to use the RaLaNS Simulator with ns3. It mainly calls the function from
	 * RaLaNSAlone and does some ns3 specific settings.
	 */
	class RaLaNSPropagationLossModel : public PropagationLossModel
	{
		public:
			/**
			 * \brief Get the type ID.
			 *
			 * adds attributes for the mapfile and the threshold
			 *
			 * \return the object TypeId
			 */
			static TypeId GetTypeId (void);

			/**
			 * \brief Default constructor
			 *
			 * has no function
			 */
			RaLaNSPropagationLossModel();

			/**
			 * \brief Default destructor
			 *
			 * has no function
			 */
			~RaLaNSPropagationLossModel();

			/**
			 * \brief Sets the data
			 *
			 * For details look at RaLaNSAlone::SetFile.
			 * 
			 * \param filename the path to the data file. The file can be either a txt or a zip file.
			 */
			void SetFile( std::string filename );

			/**
			 * \brief get path to data file
			 *
			 * For details look at RaLaNSAlone::GetFile.
			 *
			 * \return the path of the data file as a string
			 */
			std::string GetFile( void ) const;

			/**
			 * \brief turns interpolation on or off
			 *
			 * For details look at RaLaNSAlone::SetInterpolate.
			 * 
			 * \param newInterpolate the new value for interpolate
			 */
			void SetInterpolate(bool interpolate);

			/**
			 * \brief get interpolate
			 *
			 * For details look at RaLaNSAlone::GetInterpolate.
			 *
			 * \return the value of the interpolate
			 */
			bool GetInterpolate() const;

			/**
			 * \brief Sets the badNum parameter
			 *
			 * For details look at RaLaNSAlone::SetBadNum.
			 * 
			 * \param badNum the new value for badNum
			 */
			void SetBadNum(int badNum);

			/**
			 * \brief get badNum
			 *
			 * For details look at RaLaNSAlone::GetBadNum.
			 *
			 * \return the value of the threshold
			 */
			int GetBadNum() const;

			/**
			 * \brief Sets noSignal
			 *
			 * For details look at RaLaNSAlone::SetNoSignal.
			 * 
			 * \param noSignal the new value for noSignal
			 */
			void SetNoSignal(double noSignal);

			/**
			 * \brief get noSignal
			 *
			 * For details look at RaLaNSAlone::GetNoSignal.
			 *
			 * \return the value of noSignal
			 */
			double GetNoSignal() const;

			/**
			 * \brief Sets the threshold
			 *
			 * For details look at RaLaNSAlone::SetThreshold.
			 * 
			 * \param newThreshold the new value for threshold
			 */
			void SetThreshold(double newThreshold);

			/**
			 * \brief get threshold
			 *
			 * For details look at RaLaNSAlone::GetThreshold.
			 *
			 * \return the value of the threshold
			 */
			double GetThreshold() const;

			/**
			 * \brief set listInterpolationNum
			 *
			 * For details look at RaLaNSAlone::SetListInterpolationNum
			 *
			 * \param listInterpolation the new value for listInterpolationNum
			 */
			void SetListInterpolationNum(int listInterpolationNum);

			/**
			 * \brief get listInterpolationNum
			 *
			 * For details look at RaLaNSAlone::GetListInterpolationNum
			 *
			 * \return the value of listInterpolationNum
			 */
			int GetListInterpolationNum() const;
		private:

			/**
			 * \brief Generates the data
			 *
			 * Generates the data from the current file
			 */
			void GenMap();

			virtual double DoCalcRxPower (  double txPowerDbm,
					Ptr<MobilityModel> a,
					Ptr<MobilityModel> b) const;

			/**
			 * \brief Not implemented
			 *
			 * Not implemented, will return 0
			 */
			virtual int64_t DoAssignStreams (int64_t stream);

			RaLaNSAlone raLaNSAlone;//!< the RaLaNS calculator

			std::vector<double> transformToVec(const Ptr<MobilityModel> &point) const;
	};
}

#endif /* RAY_CAST_PROPAGATION_LOSS_MODEL_H */

