User Manual, Developers Guide and API Documentation

InSequenceChecker.cpp

Go to the documentation of this file.
00001 /******************************************************************************
00002  * WNS (Wireless Network Simulator)                                           *
00003  * __________________________________________________________________________ *
00004  *                                                                            *
00005  * Copyright (C) 2004-2006                                                    *
00006  * Chair of Communication Networks (ComNets)                                  *
00007  * Kopernikusstr. 16, D-52074 Aachen, Germany                                 *
00008  * phone: ++49-241-80-27910 (phone), fax: ++49-241-80-22242                   *
00009  * email: wns@comnets.rwth-aachen.de                                          *
00010  * www: http://wns.comnets.rwth-aachen.de                                     *
00011  ******************************************************************************/
00012 
00013 #include <WNS/ldk/tools/InSequenceChecker.hpp>
00014 
00015 using namespace wns::ldk::tools;
00016 
00017 STATIC_FACTORY_REGISTER_WITH_CREATOR(InSequenceChecker,
00018                      wns::ldk::FunctionalUnit,
00019                      "wns.ldk.tools.InSequenceChecker",
00020                      wns::ldk::FUNConfigCreator);
00021 
00022 InSequenceChecker::InSequenceChecker(wns::ldk::fun::FUN* fun, const wns::pyconfig::View& config) :
00023     Processor<InSequenceChecker>(),
00024     CommandTypeSpecifier<InSequenceCheckerCommand>(fun),
00025     HasReceptor<>(),
00026     HasConnector<>(),
00027     HasDeliverer<>(),
00028     wns::Cloneable<InSequenceChecker>(),
00029     sequenceIDOutgoing(0),
00030     sequenceIDExpected(0),
00031     logger(config.get<wns::pyconfig::View>("logger"))
00032 {
00033 } // InSequenceChecker
00034 
00035 
00036 InSequenceChecker::~InSequenceChecker()
00037 {
00038 } // ~InSequenceChecker
00039 
00040 
00041 void
00042 InSequenceChecker::processOutgoing(const wns::ldk::CompoundPtr& compound)
00043 {
00044     InSequenceCheckerCommand* command = activateCommand(compound->getCommandPool());
00045 
00046     MESSAGE_BEGIN(VERBOSE, logger, m, "Tagging outgoing compound")
00047         m << " with id " << sequenceIDOutgoing;
00048     MESSAGE_END();
00049 
00050     command->magic.sequenceID = sequenceIDOutgoing;
00051     ++sequenceIDOutgoing;
00052 } // processOutgoing
00053 
00054 
00055 void
00056 InSequenceChecker::processIncoming(const wns::ldk::CompoundPtr& compound)
00057 {
00058     InSequenceCheckerCommand* command = getCommand(compound->getCommandPool());
00059 
00060     MESSAGE_BEGIN(VERBOSE, logger, m, "Received incoming compound")
00061         m << " with id " << command->magic.sequenceID;
00062     MESSAGE_END();
00063 
00064     if (command->magic.sequenceID != sequenceIDExpected)
00065     {
00066         std::stringstream ss;
00067 
00068         ss << "Received out-of-sequence compound. Received compound with id "
00069            << command->magic.sequenceID << " but expected id "
00070            << sequenceIDExpected << ".";
00071 
00072         throw wns::Exception(ss.str());
00073     }
00074 
00075     ++sequenceIDExpected;
00076 } // processIncoming
00077 
00078 
00079 

Generated on Thu May 24 03:31:44 2012 for openWNS by  doxygen 1.5.5