User Manual, Developers Guide and API Documentation

CompoundCollector.hpp

Go to the documentation of this file.
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. 5, 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 #ifndef WNS_LDK_FCF_COMPOUNDCOLLECTOR_H
00028 #define WNS_LDK_FCF_COMPOUNDCOLLECTOR_H
00029 
00030 #include <WNS/Cloneable.hpp>
00031 #include <WNS/ldk/ldk.hpp>
00032 #include <WNS/ldk/HasDeliverer.hpp>
00033 #include <WNS/ldk/HasConnector.hpp>
00034 #include <WNS/ldk/HasReceptor.hpp>
00035 #include <WNS/ldk/FunctionalUnit.hpp>
00036 #include <WNS/ldk/Command.hpp>
00037 #include <WNS/ldk/CommandTypeSpecifier.hpp>
00038 #include <WNS/ldk/Compound.hpp>
00039 #include <WNS/events/CanTimeout.hpp>
00040 #include <WNS/ldk/fcf/FrameBuilder.hpp>
00041 
00042 #include <vector>
00043 
00044 namespace wns { namespace ldk { namespace fcf {
00045 
00046     class FrameBuilder;
00047     class TimingNode;
00057     class CompoundCollectorInterface
00058     {
00059     public:
00060         virtual ~CompoundCollectorInterface() {}
00061 
00065         virtual void startCollection(int) = 0;
00066 
00070         virtual void finishCollection() = 0;
00071 
00075         virtual void start(int) = 0;
00076 
00080         virtual void stop() = 0;
00084         virtual int getMode() const = 0;
00085 
00086 
00087         virtual void setFrameBuilder(FrameBuilder*) = 0;
00088 
00097         virtual simTimeType getCurrentDuration() const = 0;
00098 
00102         virtual simTimeType getMaximumDuration() const = 0;
00103 
00104         virtual void setMaximumDuration( simTimeType duration ) = 0;
00105 
00106     };
00107 
00108 
00116     class CompoundCollector :
00117         public virtual CompoundCollectorInterface,
00118         public virtual wns::ldk::FunctionalUnit,
00119         public virtual PythonicOutput
00120     {
00121     public:
00122         enum Mode
00123         {
00124             Sending,
00125             Receiving,
00126             Pausing
00127         };
00128 
00129         static const char* mode2String(int mode) {
00130             switch (mode) {
00131             case Sending:
00132                 return "Sending";
00133             case Receiving:
00134                 return "Receiving";
00135             case Pausing:
00136                 return "Pausing";
00137             }
00138             return "Unknown";
00139         }
00140 
00141         CompoundCollector( const wns::pyconfig::View& config) :
00142             mode(0),
00143             started(false),
00144             maxDuration(0.0),
00145             frameBuilder(0),
00146             timingNode(0)
00147         {
00148             frameBuilderName = config.get<std::string>("frameBuilderName");
00149         }
00150 
00151         simTimeType getMaximumDuration() const { return maxDuration; }
00152 
00153         FrameBuilder* getFrameBuilder() const { return frameBuilder; }
00154 
00155         void setFrameBuilder( FrameBuilder* _frameBuilder )
00156         { frameBuilder = _frameBuilder; }
00157 
00158 
00159         int getMode() const
00160         {
00161             return mode;
00162         }
00163 
00164 
00165         void startCollection(int _mode)
00166         {
00167             mode = _mode;
00168             doStartCollection(_mode);
00169         }
00170 
00171 
00172         void start(int _mode)
00173         {
00174             assure(_mode == getMode(), "compound collector starting with wrong mode" );
00175             doStart(_mode);
00176             started = true;
00177         }
00178 
00179         void stop()
00180         {
00181             assure(started, "Stop called for inactive compound collector.");
00182             doStop();
00183             started = false;
00184         }
00185 
00186         virtual void doStartCollection(int) = 0;
00187         virtual void doStart(int) = 0;
00188         virtual void doStop() {};
00189 
00190         virtual void doWakeup()
00191         {
00192             throw wns::Exception("Invalid wakeup call in CompoundCollector");
00193         }
00194 
00195 
00196     protected:
00197         int mode;
00198 
00199     private:
00200 
00201         void setMaximumDuration( simTimeType duration )
00202         { maxDuration = duration; }
00203 
00204         void setTimingNode( TimingNode* _timingNode )
00205         { timingNode = _timingNode; }
00206 
00207         bool started;
00208         simTimeType maxDuration;
00209         FrameBuilder* frameBuilder;
00210         std::string frameBuilderName;
00211         TimingNode* timingNode;
00212 
00213         friend class PhaseDescriptor;
00214     };
00215 
00216 }
00217 }
00218 }
00219 #endif
00220 
00221 

Generated on Tue May 22 03:31:38 2012 for openWNS by  doxygen 1.5.5