![]() |
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_COMMAND_HPP 00029 #define WNS_LDK_COMMAND_HPP 00030 00031 #include <WNS/simulator/Bit.hpp> 00032 #include <WNS/Assure.hpp> 00033 00034 #include <cstdlib> 00035 00036 namespace wns { namespace ldk { 00037 00051 class Command 00052 { 00053 friend class CommandProxy; 00054 00055 public: 00056 Command() : 00057 commited(false), 00058 commandPoolSize(0), 00059 payloadSize(0) 00060 {} 00061 00062 virtual 00063 ~Command() 00064 {} 00065 00066 virtual Bit 00067 getSize() const 00068 { 00069 return 0; 00070 } 00071 00072 private: 00073 bool sizeCommited() const 00074 { 00075 return commited; 00076 } 00077 00078 Bit getCommandPoolSize() const 00079 { 00080 assure(commited, "You may only retrieve the size of the command pool after committing!"); 00081 return commandPoolSize; 00082 } 00083 00084 void setCommandPoolSize(const Bit size) 00085 { 00086 assure(!commited, "You may not modify the size after commiting!"); 00087 commandPoolSize = size; 00088 } 00089 00090 Bit getPayloadSize() const 00091 { 00092 assure(commited, "You may only retrieve the size of the payload after committing!"); 00093 return payloadSize; 00094 } 00095 00096 void setPayloadSize(const Bit size) 00097 { 00098 assure(!commited, "You may not modify the size after commiting!"); 00099 payloadSize = size; 00100 } 00107 void commit() 00108 { 00109 assure(!commited, "You may not commit the size of the command twice!"); 00110 commited = true; 00111 } 00112 00113 bool commited; 00114 Bit commandPoolSize; 00115 Bit payloadSize; 00116 00117 }; 00118 00119 class EmptyCommand : 00120 public Command 00121 { 00122 public: 00123 EmptyCommand() : 00124 local(), 00125 peer(), 00126 magic() 00127 {} 00128 00133 struct {} local; 00134 00139 struct {} peer; 00140 00145 struct {} magic; 00146 }; 00147 00148 } // ldk 00149 } // wns 00150 00151 #endif // NOT defined WNS_LDK_COMMAND_HPP 00152 00153
1.5.5