module.h

Go to the documentation of this file.
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 
00041 #ifndef MODULE_H
00042 #define MODULE_H
00043 
00044 
00045 #include "plugin.h"
00046 
00047 
00048 
00060 class Module : public PlugIn {
00061 public:
00065         Module();
00069         virtual ~Module();
00070         
00090         virtual int command(int argc, const char*const* argv);
00091 
00101         virtual void recv(Packet* p, Handler* callback);
00111         virtual void recv(Packet *p, int idSrc);
00120         virtual void recv(Packet *p)=0;
00121 
00129         int getUpLaySAPnum();
00139         SAP* getUpLaySAP(int i);
00147         int getDownLaySAPnum();
00157         SAP* getDownLaySAP(int i);
00167         void swapUpLaySAP(int i, int j);
00177         void swapDownLaySAP(int i, int j);
00178 
00179 protected:
00180 
00188         void addUpSAP(SAP* sap);
00189 
00197         void addDownSAP(SAP* sap);
00198 
00209         void sendUp(Packet* p, double delay=0);
00210 
00221         void sendDown(Packet* p,  double delay=0);
00222 
00233         void sendUp(int moduleId, Packet* p, double delay=0);
00234 
00245         void sendDown(int moduleId, Packet* p,  double delay=0);
00246 
00247 
00248 
00249 
00250 
00261         void sendAsyncClMsgUp(ClMessage* m, double delay=0);
00262 
00263 
00274         void sendAsyncClMsgDown(ClMessage* m, double delay=0);
00275 
00276 
00286         void sendSyncClMsgDown(ClMessage* m);
00287 
00288 
00297         void sendSyncClMsgUp(ClMessage* m);
00298 
00299 
00300 
00311         void drop(Packet* p, int depth, const char* reason = "---");
00312         
00322         virtual Packet *copy(Packet *p);
00323 
00324 private:
00326         SAP** upLayerSAP_;
00328         int upLaySAPnum_;
00330         SAP** downLayerSAP_;
00332         int downLaySAPnum_;
00333         
00334         
00335 protected:
00336 
00337   /**********************
00338    * Deprecated methods 
00339    * 
00340    */
00341 
00348         void sendUp(ClMessage* m, double delay=0);
00349 
00359         void sendUp(int moduleId, ClMessage* m, double delay=0);
00360 
00367         void sendDown(ClMessage* m, double delay=0);
00368 
00377         void sendDown(int moduleId, ClMessage* p,  double delay=0);
00378 
00384         void sendSynchronousDown(ClMessage* m);
00385 
00391         void sendSynchronousUp(ClMessage* m);
00392 
00400         void sendSynchronousUp(int moduleId, ClMessage* m);
00401 
00409         void sendSynchronousDown(int moduleId, ClMessage* m);
00410 
00411 
00412 
00413 
00414 
00415 };
00416 
00417 #endif /* MODULE_H */

Generated on Wed Nov 26 15:47:28 2008 for NS-MIRACLE library by  doxygen 1.5.2