Main Page | Class Hierarchy | Alphabetical List | Class List | File List | Class Members

pana_ingress.h

00001 /* BEGIN_COPYRIGHT                                                        */
00002 /*                                                                        */
00003 /* Open Diameter: Open-source software for the Diameter and               */
00004 /*                Diameter related protocols                              */
00005 /*                                                                        */
00006 /* Copyright (C) 2002-2004 Open Diameter Project                          */
00007 /*                                                                        */
00008 /* This library is free software; you can redistribute it and/or modify   */
00009 /* it under the terms of the GNU Lesser General Public License as         */
00010 /* published by the Free Software Foundation; either version 2.1 of the   */
00011 /* License, or (at your option) any later version.                        */
00012 /*                                                                        */
00013 /* This library is distributed in the hope that it will be useful,        */
00014 /* but WITHOUT ANY WARRANTY; without even the implied warranty of         */
00015 /* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU      */
00016 /* Lesser General Public License for more details.                        */
00017 /*                                                                        */
00018 /* You should have received a copy of the GNU Lesser General Public       */
00019 /* License along with this library; if not, write to the Free Software    */
00020 /* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307    */
00021 /* USA.                                                                   */
00022 /*                                                                        */
00023 /* In addition, when you copy and redistribute some or the entire part of */
00024 /* the source code of this software with or without modification, you     */
00025 /* MUST include this copyright notice in each copy.                       */
00026 /*                                                                        */
00027 /* If you make any changes that are appeared to be useful, please send    */
00028 /* sources that include the changed part to                               */
00029 /* diameter-developers@lists.sourceforge.net so that we can reflect your  */
00030 /* changes to one unified version of this software.                       */
00031 /*                                                                        */
00032 /* END_COPYRIGHT                                                          */
00033 
00034 #ifndef __PANA_INGRESS_H__
00035 #define __PANA_INGRESS_H__
00036 
00037 #include "pana_message.h"
00038 #include "pana_io.h"
00039 #include "framework.h"
00040 #include "pana_memory_manager.h"
00041 #include "callback_patterns.h"
00042 
00046 class PANA_EXPORT PANA_IngressJob : public AAA_Job
00047 {
00048    public:
00049       PANA_IngressJob(AAA_GroupedJob &g, const char *name = "") : 
00050               m_Group(g), m_MsgHandler(0), 
00051               m_ErrHandler(0),
00052               m_Name(name) { 
00053       }
00054       virtual int Schedule(AAA_Job* job, unsigned int backlogSize=1) { 
00055         return m_Group.Schedule(job);
00056       }
00057       virtual int Schedule() {
00058         return m_Group.Schedule(this);
00059       }
00060       void RegisterHandler(AAA_CbFunction1<PANA_Message&> &h) { 
00061         m_MsgHandler = h.clone(); 
00062       }
00063       void RegisterHandler(AAA_CbFunction1<int> &h) { 
00064         m_ErrHandler = h.clone(); 
00065       }
00066       void RemoveHandler() { 
00067         delete m_MsgHandler; m_MsgHandler = NULL;
00068         delete m_ErrHandler; m_ErrHandler = NULL; 
00069       }
00070       std::string &Name() {
00071         return m_Name;
00072       }
00073 
00074    protected:
00075       AAA_GroupedJob &m_Group;
00076       AAA_CbFunction1<PANA_Message&> *m_MsgHandler;
00077       AAA_CbFunction1<int> *m_ErrHandler;
00078       std::string m_Name;
00079 };
00080 
00084 class PANA_EXPORT PANA_IngressMsgDelivery : public PANA_IngressJob
00085 {
00086    public:
00087       PANA_IngressMsgDelivery(AAA_GroupedJob &g,
00088                               PANA_Message &msg,
00089                               const char *name = "") :
00090          PANA_IngressJob(g, name), m_Message(msg) { }
00091      virtual ~PANA_IngressMsgDelivery() { }
00092 
00093       virtual int Serve();
00094 
00095    private:
00096       PANA_Message &m_Message;
00097 };
00098 
00102 class PANA_EXPORT PANA_IngressMsgParser : public PANA_IngressJob
00103 {
00104    public:
00105       PANA_IngressMsgParser(AAA_GroupedJob &g,
00106                             PANA_MessageBuffer &msg,
00107                             ACE_UINT32 port,
00108                             PANA_DeviceIdContainer &dev,
00109                             const char *name = "") :
00110          PANA_IngressJob(g, name),
00111          m_SrcPort(port),
00112          m_Message(msg),
00113          m_SrcDevices(dev) { }
00114      virtual ~PANA_IngressMsgParser() { }
00115 
00116       virtual int Serve();
00117 
00118    private:
00119       ACE_UINT32 m_SrcPort;
00120       PANA_MessageBuffer &m_Message;
00121       PANA_DeviceIdContainer &m_SrcDevices;
00122 };
00123 
00127 class PANA_EXPORT PANA_IngressReceiver : public PANA_IngressJob
00128 {
00129    public:
00130       PANA_IngressReceiver(AAA_GroupedJob &g, 
00131                            PANA_IO &t,
00132                            const char *name = "") :
00133              PANA_IngressJob(g, name),
00134                          m_IO(t),
00135                          m_Signalled(false) { }
00136 
00137       virtual int Serve();
00138           virtual void Wait() {           
00139                   while (m_Signalled) {
00140               ACE_Time_Value tm(0, 100);
00141                           ACE_OS::sleep(tm);
00142                   }
00143           }
00144 
00145    protected:
00146       PANA_IO &m_IO;
00147           bool m_Signalled;
00148 };
00149 
00150 #endif // __PANA_INGRESS_H__

Generated on Fri Jun 25 19:18:29 2004 for PANA by doxygen 1.3.5