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

pana_paa_factory.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_PAA_FACTORY_H__
00035 #define __PANA_PAA_FACTORY_H__
00036 
00037 #include "pana_node.h"
00038 #include "pana_session.h"
00039 #include "pana_paa_fsm.h"
00040 #include "pana_message.h"
00041 #include "callback_patterns.h"
00042 
00043 typedef PANA_SessionTree<PANA_PaaSession> PANA_PendingSessionDb;
00044 
00045 class PANA_EXPORT PANA_PaaSessionFactory : public PANA_PaaSessionChannel
00046 {
00047    public:
00048       PANA_PaaSessionFactory(PANA_Node &n) : PANA_PaaSessionChannel(n) { 
00049           
00050          AAA_SCSIAdapter1<PANA_PaaSessionFactory, 
00051                            void(PANA_PaaSessionFactory::*)(PANA_Message&),
00052                            PANA_Message&> 
00053                      msgHandler(*this, &PANA_PaaSessionFactory::Receive);
00054          AAA_SCSIAdapter1<PANA_PaaSessionFactory, 
00055                            void(PANA_PaaSessionFactory::*)(int), 
00056                            int> 
00057                      errHandler(*this, &PANA_PaaSessionFactory::Error);
00058 
00059          PANA_PaaSessionChannel::RegisterHandler(msgHandler);
00060          PANA_PaaSessionChannel::RegisterHandler(errHandler);
00061       }
00062       virtual PANA_PaaSessionFactory::~PANA_PaaSessionFactory() {
00063          PANA_PaaSessionChannel::RemoveHandler();
00064       }
00065       virtual PANA_PaaSession *Create() = 0;
00066 
00067    protected:
00068       virtual void Receive(PANA_Message &msg);
00069       virtual void Error(int err);
00070 
00071    private:
00072       virtual void ReceiveDiscover(PANA_Message &msg);
00073       virtual void SendStartRequest(PANA_Message &msg, 
00074                                     diameter_octetstring_t &cookie);
00075       virtual void ReceiveStartAnswer(PANA_Message &msg);
00076 
00077       PANA_PendingSessionDb m_PendingDb;
00078 };
00079 
00080 template<class PAA_SESSION, class ARG>
00081 class PANA_PaaSessionFactoryAdapter : public PANA_PaaSessionFactory
00082 {
00083    public:
00084       PANA_PaaSessionFactoryAdapter(ARG &arg) : m_arg(arg) { }
00085       PANA_PaaSession *Create() {
00086          return (new PAA_SESSION(m_Node, m_Udp, m_arg));
00087       }
00088    protected:
00089       ARG &m_arg;
00090 };
00091 
00092 #endif /* __PANA_PAA_FACTORY_H__ */
00093 

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