/** * SimulX -- the Wireless Network Simulator * Copyright (C) 2003-2006 * ULP - LSIIT Networks and Protocols Research Team * GET / ENST Bretagne - RSM department * * This file is part of SimulX * * SimulX is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */#ifndef SIMULX_EVENT_H#define SIMULX_EVENT_H/** * @file EVENT.h * @brief This file defines the Event interface which is used * by the scheduler. * @author Labo4G */#include <iostream>#include <string>#include <sstream>#include <tinyxml.h>#include "handler.h"#include "trace.h"#include "serializable.h"#include "core_exception.h"class Handler;class EventException : public CoreException{};class Event : virtual public Serializable{ private: static int total; /**< total number of event */ double eid; /**< uniquely identifies the event */ int hid; /**< identifiant of the handler */ Handler* handler; /**< instance of the handler to */ double time; /**< time represents the moment where the handler must be call */ public: // -------------- Constructor /** * @brief empty constructor */ Event(); /** * @brief constructor * @param Handler* handler that will be called * @param double time, time where the event is process */ Event(Handler* handler, double time); /** * @brief constructor * @param int hid, id of the handler that will be called * @param double time, time where the event is process */ Event(int hid, double time); /** * @brief Copy constructor * @param Event* event */ Event(Event* event); /** * @brief deserialization constructor * @param the serialized object */ Event(TiXmlElement* event); /** * @brief Destructor */ virtual ~Event(); // -------------- Accessor Handler* getHandler(); int getHid(); double getId(); double getTime(); // -------------- Setters void setHandler(Handler* handler); void setHandler(int hid); void setTime(double time); // -------------- Method /** * @brief these methods compare two instance of the object * Event. the comparison is made thanks to the time attribute */ bool operator<(const Event& event); bool operator<=(const Event& event); bool operator==(const Event& event); bool operator>(const Event& event); bool operator>=(const Event& event); /** * @brief serialize the object to keep a trace * the format is : * <Event hid="hid" time="time" /> */ virtual std::string toXML(); };class EventFactory:public Factory{ public: EventFactory(std::string key); Event* create(TiXmlElement* elem);};#endif