00001 /* -*- Mode:C++ -*- */ 00002 /* 00003 * Copyright (c) 2006 Regents of the SIGNET lab, University of Padova. 00004 * All rights reserved. 00005 * 00006 * Redistribution and use in source and binary forms, with or without 00007 * modification, are permitted provided that the following conditions 00008 * are met: 00009 * 1. Redistributions of source code must retain the above copyright 00010 * notice, this list of conditions and the following disclaimer. 00011 * 2. Redistributions in binary form must reproduce the above copyright 00012 * notice, this list of conditions and the following disclaimer in the 00013 * documentation and/or other materials provided with the distribution. 00014 * 3. Neither the name of the University of Padova (SIGNET lab) nor the 00015 * names of its contributors may be used to endorse or promote products 00016 * derived from this software without specific prior written permission. 00017 * 00018 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 00019 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED 00020 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 00021 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR 00022 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 00023 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 00024 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; 00025 * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 00026 * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR 00027 * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF 00028 * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 00029 */ 00030 00031 00039 #ifndef _PLUGIN_ 00040 #define _PLUGIN_ 00041 00042 #include <object.h> 00043 #include <bin.h> 00048 #define MAX_TAG_LENGTH 10 00049 00050 00051 00052 class ClSAP; 00061 class PlugIn : public NsObject { 00062 public: 00066 PlugIn(); 00070 virtual ~PlugIn(); 00071 00097 virtual int command(int argc, const char*const* argv); 00098 00099 00132 virtual int recvAsyncClMsg(ClMessage* m); 00133 00134 00135 00148 virtual int recvSyncClMsg(ClMessage* m); 00149 00150 00151 00152 00162 void recv(Packet* p, Handler* callback = 0); 00169 int getId(); 00176 void setId(int val); 00183 int getTag(char* buf, int size); 00184 00191 const char* getTag() {return tag_;} 00198 Position* getPosition(); 00199 00206 void setLayer(int val); 00213 int getLayer(); 00214 protected: 00215 00216 00226 void sendAsyncClMsg(ClMessage* m, double delay = 0); 00227 00228 00229 00238 void sendSynchronousCl(ClMessage* m); 00239 00240 void sendSyncClMsg(ClMessage* m); 00241 00242 00243 00253 void drop(ClMessage* m, const char* reason = "---"); 00254 00256 Bin* binPtr_; 00257 00259 char tag_[MAX_TAG_LENGTH]; 00260 00261 00262 private: 00264 int uid_; 00266 ClSAP* clsap_; 00267 00268 protected: 00270 int uLayerId_; 00271 00272 00273 00274 00275 /****************************** 00276 * Deprecated Methods 00277 * 00278 */ 00279 00280 protected: 00281 00288 void sendCl(ClMessage* m, double delay=0); 00289 00290 public: 00298 virtual int crLayCommand(ClMessage* m); 00299 00307 virtual int crLaySynchronousCommand(ClMessage* m); 00308 00309 }; 00310 #endif