![]() |
User Manual, Developers Guide and API Documentation |
![]() |
00001 /******************************************************************************* 00002 * This file is part of openWNS (open Wireless Network Simulator) 00003 * _____________________________________________________________________________ 00004 * 00005 * Copyright (C) 2004-2007 00006 * Chair of Communication Networks (ComNets) 00007 * Kopernikusstr. 16, D-52074 Aachen, Germany 00008 * phone: ++49-241-80-27910, 00009 * fax: ++49-241-80-22242 00010 * email: info@openwns.org 00011 * www: http://www.openwns.org 00012 * _____________________________________________________________________________ 00013 * 00014 * openWNS is free software; you can redistribute it and/or modify it under the 00015 * terms of the GNU Lesser General Public License version 2 as published by the 00016 * Free Software Foundation; 00017 * 00018 * openWNS is distributed in the hope that it will be useful, but WITHOUT ANY 00019 * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR 00020 * A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more 00021 * details. 00022 * 00023 * You should have received a copy of the GNU Lesser General Public License 00024 * along with this program. If not, see <http://www.gnu.org/licenses/>. 00025 * 00026 ******************************************************************************/ 00027 00028 #ifndef WNS_EVENTS_SCHEDULER_INTERFACE_HPP 00029 #define WNS_EVENTS_SCHEDULER_INTERFACE_HPP 00030 00031 #include <WNS/events/scheduler/ICommand.hpp> 00032 #include <WNS/events/scheduler/IEvent.hpp> 00033 #include <WNS/events/scheduler/Callable.hpp> 00034 #include <WNS/events/scheduler/INotification.hpp> 00035 #include <WNS/simulator/Time.hpp> 00036 #include <WNS/StaticFactory.hpp> 00037 #include <WNS/NonCopyable.hpp> 00038 #include <WNS/SubjectInterface.hpp> 00039 00040 namespace wns { namespace events { namespace scheduler { 00041 00061 class Interface : 00062 virtual public SubjectInterface<IObserver>, 00063 private NonCopyable 00064 { 00065 public: 00076 wns::simulator::Time 00077 getTime() const; 00079 00085 00092 IEventPtr 00093 scheduleNow(const Callable& callable) 00094 { 00095 this->sendScheduleNowNotification(); 00096 return this->doScheduleNow(callable); 00097 } 00098 00106 IEventPtr 00107 scheduleDelay(const Callable& callable, wns::simulator::Time delay) 00108 { 00109 this->sendScheduleDelayNotification(); 00110 return this->doSchedule(callable, this->getTime() + delay); 00111 } 00112 00119 IEventPtr 00120 schedule(const Callable& callable, wns::simulator::Time at) 00121 { 00122 this->sendScheduleNotification(); 00123 return this->doSchedule(callable, at); 00124 } 00125 00129 ICommandPtr 00130 queueCommand(const Callable& callable) 00131 { 00132 return this->doQueueCommand(callable); 00133 } 00134 00138 void 00139 dequeueCommand(const ICommandPtr& command); 00141 00147 00151 void 00152 cancelEvent(const IEventPtr& event); 00154 00163 void 00164 reset(); 00165 00169 bool 00170 processOneEvent(); 00172 00181 void 00182 start(); 00183 00187 void 00188 stop(); 00189 00193 void 00194 stopAt(const wns::simulator::Time& time); 00195 00199 size_t 00200 size() const; 00202 00206 virtual 00207 ~Interface(); 00208 00209 protected: 00210 00217 Interface(); 00218 00219 private: 00220 // NVI (non-virtual interface) - For explanation of the methods see 00221 // above 00222 virtual wns::simulator::Time 00223 doGetTime() const = 0; 00224 00225 virtual IEventPtr 00226 doSchedule(const Callable& callable, wns::simulator::Time at) = 0; 00227 00228 virtual IEventPtr 00229 doScheduleNow(const Callable& callable) = 0; 00230 00231 virtual ICommandPtr 00232 doQueueCommand(const Callable& callable) = 0; 00233 00234 virtual void 00235 doDequeueCommand(const ICommandPtr& command) = 0; 00236 00237 virtual void 00238 doCancelEvent(const IEventPtr& event) = 0; 00239 00240 virtual void 00241 doReset() = 0; 00242 00243 virtual bool 00244 doProcessOneEvent() = 0; 00245 00246 virtual void 00247 doStart() = 0; 00248 00249 virtual void 00250 doStop() = 0; 00251 00252 // this implementation works for all schedulers 00253 // a sub-class might override this method for custom-/optimization 00254 virtual void 00255 doStopAt(const wns::simulator::Time& time); 00256 00257 virtual size_t 00258 doSize() const = 0; 00259 00260 // end NVI 00261 00262 00266 //{@ 00267 virtual void 00268 sendProcessOneEventNotification() = 0; 00269 00270 virtual void 00271 sendCancelEventNotification() = 0; 00272 00273 virtual void 00274 sendScheduleNotification() = 0; 00275 00276 virtual void 00277 sendScheduleDelayNotification() = 0; 00278 00279 virtual void 00280 sendScheduleNowNotification() = 0; 00282 }; 00283 00284 typedef wns::Creator<wns::events::scheduler::Interface> Creator; 00285 typedef StaticFactory<wns::events::scheduler::Creator> Factory; 00286 00287 } // scheduler 00288 } // events 00289 } // wns 00290 00373 #endif // NOT defined WNS_EVENTS_SCHEDULER_INTERFACE_HPP
1.5.5