User Manual, Developers Guide and API Documentation

Listener.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. 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 CONSTANZE_LISTENER_HPP
00029 #define CONSTANZE_LISTENER_HPP
00030 
00031 #include <CONSTANZE/ConstanzePDU.hpp>
00032 #include <CONSTANZE/Binding.hpp>
00033 #include <CONSTANZE/Measurement.hpp>
00034 #include <WNS/osi/PDU.hpp>
00035 #include <WNS/logger/Logger.hpp>
00036 #include <WNS/probe/bus/ContextCollector.hpp>
00037 
00038 namespace constanze
00039 {
00041     class OneLiner :
00042         public wns::probe::bus::ContextProvider
00043     {
00044         std::string key_;
00045         std::string value_;
00046         mutable bool newValue_;
00047     public:
00048         OneLiner(const std::string& key) : key_(key), value_(), newValue_(false) {}
00049 
00050         virtual void
00051         set(const std::string& value)
00052             {
00053                 newValue_ = true;
00054                 value_ = value;
00055             }
00056 
00057         const std::string&
00058         getKey() const
00059             {
00060                 return key_;
00061             }
00062     private:
00063         virtual void
00064         doVisit(wns::probe::bus::IContext& c) const
00065         {
00066             if (newValue_ == true)
00067                 {
00068                     c.insertString(key_, value_);
00069                     newValue_ = false;
00070                 }
00071         }
00072     };
00073 
00074 
00076     class Listener
00077       // : public Probe
00078     {
00079     public:
00080         Listener( const wns::pyconfig::View& _pyco, wns::node::component::Interface* component);
00081 
00082         ~Listener();
00083 
00085         void
00086         onData(const wns::osi::PDUPtr& _data);
00087 
00088         void
00089         registerBinding(constanze::Binding* _binding);
00090 
00091         virtual std::string printAddress() const;
00092 
00093         friend std::ostream&
00094         operator <<(std::ostream& os, const Listener& l)
00095         {
00096             os << l.printAddress();
00097             return os;
00098         }
00099 
00100     private:
00102         wns::pyconfig::View pyco;
00103 
00105         wns::logger::Logger log;
00106 
00108         std::string domainName;
00109 
00111         constanze::Binding* binding;
00112 
00116         Measurement* measurement;
00117 
00121         int stateLevel;
00122 
00126         double windowSize;
00127 
00131         bool doMMPPestimation;
00132 
00135         std::vector<int> *observationVector;
00136 
00138         wns::probe::bus::ContextCollectorPtr sizeProbe;
00139         wns::probe::bus::ContextCollectorPtr bitsRateProbe;
00140         wns::probe::bus::ContextCollectorPtr packetRateProbe;
00141         wns::probe::bus::ContextCollectorPtr bitsWindowedRateProbe;
00142         wns::probe::bus::ContextCollectorPtr packetWindowedRateProbe;
00143         wns::probe::bus::ContextCollectorPtr delayProbe;
00144 
00146         OneLiner bitsWindowedResult;
00147         OneLiner packetWindowedResult;
00148 
00150         long unsigned int packetCounter;
00152         long unsigned int bitCounter;
00154         long unsigned int windowedPacketCounter;
00156         long unsigned int windowedBitCounter;
00158         simTimeType currentWindowEnd;
00159     };
00160 }
00161 
00162 #endif // NOT defined CONSTANZE_LISTENER_HPP
00163 
00164 /*
00165   Local Variables:
00166   mode: c++
00167   fill-column: 80
00168   c-basic-offset: 8
00169   c-comment-only-line-offset: 0
00170   c-tab-always-indent: t
00171   indent-tabs-mode: t
00172   tab-width: 8
00173   End:
00174 */

Generated on Thu May 24 03:32:15 2012 for openWNS by  doxygen 1.5.5