![]() |
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. 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 #ifndef WNS_LDK_CLASSIFIER_HPP 00029 #define WNS_LDK_CLASSIFIER_HPP 00030 00031 #include <WNS/ldk/CommandTypeSpecifier.hpp> 00032 #include <WNS/ldk/HasReceptor.hpp> 00033 #include <WNS/ldk/HasConnector.hpp> 00034 #include <WNS/ldk/HasDeliverer.hpp> 00035 #include <WNS/ldk/Processor.hpp> 00036 00037 #include <WNS/ldk/ldk.hpp> 00038 00039 NAMESPACE_BEGIN(wns) 00040 NAMESPACE_BEGIN(ldk) 00041 00042 typedef long ClassificationID; 00043 00044 class ClassifierCommand 00045 : public wns::ldk::Command 00046 { 00047 public: 00048 enum { Invalid = -1 }; 00049 00050 struct Local { 00051 }; 00052 Local local; 00053 00054 struct Peer { 00055 ClassificationID id; 00056 }; 00057 Peer peer; 00058 struct Magic { 00059 int bsId; 00060 }; 00061 Magic magic; 00062 }; 00063 00067 template <class ClassificationPolicy> 00068 class Classifier 00069 : public wns::ldk::CommandTypeSpecifier<ClassifierCommand>, 00070 public wns::ldk::HasReceptor<>, 00071 public wns::ldk::HasConnector<>, 00072 public wns::ldk::HasDeliverer<>, 00073 public wns::ldk::Processor< Classifier<ClassificationPolicy> >, 00074 public ClassificationPolicy, 00075 public Cloneable< Classifier<ClassificationPolicy> > 00076 00077 { 00078 public: 00079 Classifier( wns::ldk::fun::FUN* fuNet, const wns::pyconfig::View& ) 00080 : wns::ldk::CommandTypeSpecifier<ClassifierCommand>(fuNet), 00081 ClassificationPolicy(fuNet) 00082 {} 00083 00085 virtual void processIncoming(const CompoundPtr& compound) 00086 { 00087 ClassifierCommand* command = 0; 00088 00089 if (getFUN()->getProxy()->commandIsActivated( compound->getCommandPool(), this)) 00090 command = getCommand( compound->getCommandPool() ); 00091 else 00092 command = activateCommand( compound->getCommandPool() ); 00093 00094 command->peer.id = ClassificationPolicy::classify( compound ); 00095 } 00096 00098 virtual void processOutgoing(const CompoundPtr& compound) 00099 { 00100 ClassifierCommand* command = 0; 00101 00102 if(getFUN()->getProxy()->commandIsActivated( compound->getCommandPool(), this)) 00103 command = getCommand( compound->getCommandPool() ); 00104 else 00105 command = activateCommand( compound->getCommandPool() ); 00106 00107 command->peer.id = ClassificationPolicy::classify( compound ); 00108 } 00109 00110 typedef wns::ldk::FUNConfigCreator< Classifier<ClassificationPolicy> > ClassifierCreator; 00111 typedef wns::StaticFactory<ClassifierCreator> ClassifierFactory; 00112 }; 00113 00114 NAMESPACE_END 00115 NAMESPACE_END 00116 00117 #endif 00118 00119
1.5.5