User Manual, Developers Guide and API Documentation

OpcodeKey.cpp

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 
00028 #include <WNS/ldk/multiplexer/OpcodeKey.hpp>
00029 
00030 #include <WNS/ldk/multiplexer/OpcodeProvider.hpp>
00031 
00032 using namespace wns::ldk;
00033 using namespace wns::ldk::multiplexer;
00034 
00035 STATIC_FACTORY_REGISTER_WITH_CREATOR(OpcodeKeyBuilder, KeyBuilder, "multiplex.Opcode", FUNConfigCreator);
00036 
00037 
00038 OpcodeKey::OpcodeKey(const OpcodeKeyBuilder* builder, const CompoundPtr& compound)
00039 {
00040     OpcodeCommand* command = builder->friends.opcodeProvider->getCommand(compound->getCommandPool());
00041     opcode = command->peer.opcode;
00042 }
00043 
00044 
00045 bool
00046 OpcodeKey::operator<(const Key& _other) const
00047 {
00048     assure(dynamic_cast<const OpcodeKey*>(&_other), "Comparing Keys of different types.");
00049 
00050     const OpcodeKey* other = static_cast<const OpcodeKey*>(&_other);
00051     return opcode < other->opcode;
00052 } // <
00053 
00054 
00055 std::string
00056 OpcodeKey::str() const
00057 {
00058     std::stringstream ss;
00059     ss << "opcode:" << opcode;
00060     return ss.str();
00061 } // str
00062 
00063 
00064 OpcodeKeyBuilder::OpcodeKeyBuilder(const fun::FUN* _fuNet, const pyconfig::View& _config) :
00065         fuNet(_fuNet),
00066         config(_config)
00067 {
00068 }
00069 
00070 
00071 void
00072 OpcodeKeyBuilder::onFUNCreated()
00073 {
00074     friends.opcodeProvider = fuNet->findFriend<OpcodeProvider*>(config.get<std::string>("opcode"));
00075 } // onFUNCreated
00076 
00077 
00078 wns::ldk::ConstKeyPtr
00079 OpcodeKeyBuilder::operator() (const CompoundPtr& compound, int /* direction */) const
00080 {
00081     return ConstKeyPtr(new OpcodeKey(this, compound));
00082 }
00083 
00084 
00085 

Generated on Fri May 25 03:31:46 2012 for openWNS by  doxygen 1.5.5