//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// 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 RAY_CAST_PROPAGATION_LOSS_MODEL_H
#define RAY_CAST_PROPAGATION_LOSS_MODEL_H

#include <ns3/propagation-loss-model.h>
#include <ns3/propagation-environment.h>
#include <string>

namespace ns3 {
	/**
	 * \ingroup propagation
	 *
	 * \brief a propagation model for RaLaNS.
	 * Can be used with the with RaLaNS to see networks in ns3
	 */
	class RaLaNSPropagationLossModel : public PropagationLossModel
	{
		public:
			/**
			 * \brief Get the type ID.
			 * \return the object TypeId
			 */
			static TypeId GetTypeId (void);

			RaLaNSPropagationLossModel();

			~RaLaNSPropagationLossModel();

			/**
			 * \brief Sets the data
			 *
			 * sets the data, which should be generated with RaLaNS. The file has to be a txt file
			 */
			void SetMap( std::string filename );

			/**
			 * \brief get location of data
			 *
			 * \return the location of the input file as a string
			 */
			std::string GetMap( void );
		private:

			/**
			 * \brief set one of the headers
			 *
			 * sets either the transmitter header, which is the first line in the file
			 * or the receiver header, which is the 2nd line in the file
			 */
			void setHeader(std::string headerStringWithSpaces, std::vector< std::vector<double> > &header);
			/**
			 * \brief sets Point header
			 *
			 * function will be called if one of the headers is a point. The point will be set
			 */
			void setPoint(std::vector<double> pointVec, std::vector< std::vector<double> > &header);
			/**
			 * \brief sets Line header
			 *
			 * function will be called if one of the headers is a line. The line will be set
			 */
			void setLine(std::vector<double> lineVec, std::vector< std::vector<double> > &header);

			/**
			 * \brief sets Area header
			 *
			 * function will be called if one of the headers is a area. The area will be set
			 */
			void setArea(std::vector<double> areaVec, std::vector< std::vector<double> > &header);

			void setCubic(std::vector<double> cubigVec, std::vector< std::vector<double> > &header);

			void setList(std::vector<double> listVec, std::vector< std::vector<double> > &header);

			void printTransmitters();
			void printReceivers();

			std::vector<std::vector<double> > signals;//!< contains signals from transmitters to receivers
			std::vector<std::vector<double> > transmitters;//!< contains all transmitters with their 3D position
			std::vector<std::vector<double> > receivers;//!< contains all receivers with their 3D position

			int yLen;//!< number of elements in y dimension
			int zLen;//!< number of elements in z dimension

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

			virtual int64_t DoAssignStreams (int64_t stream);

			std::string filename;//!< location of the data
	};


}

#endif /* RAY_CAST_PROPAGATION_LOSS_MODEL_H */

