Main Page | Namespace List | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Namespace Members | Class Members | File Members | Related Pages

netnodeinterface.h

Go to the documentation of this file.
00001 /*
00002                              This file is part of the Opie Project
00003 
00004                              Copyright (C) 2005 Holger Hans Peter Freyther <freyther@handhelds.org>
00005               =.
00006             .=l.
00007            .>+-=
00008  _;:,     .>    :=|.         This program is free software; you can
00009 .> <`_,   >  .   <=          redistribute it and/or  modify it under
00010 :`=1 )Y*s>-.--   :           the terms of the GNU Library General Public
00011 .="- .-=="i,     .._         License as published by the Free Software
00012  - .   .-<_>     .<>         Foundation; either version 2 of the License,
00013      ._= =}       :          or (at your option) any later version.
00014     .%`+i>       _;_.
00015     .i_,=:_.      -<s.       This program is distributed in the hope that
00016      +  .  -:.       =       it will be useful,  but WITHOUT ANY WARRANTY;
00017     : ..    .:,     . . .    without even the implied warranty of
00018     =_        +     =;=|`    MERCHANTABILITY or FITNESS FOR A
00019   _.=:.       :    :=>`:     PARTICULAR PURPOSE. See the GNU
00020 ..}^=.=       =       ;      Library General Public License for more
00021 ++=   -.     .`     .:       details.
00022  :     =  ...= . :.=-
00023  -.   .:....=;==+<;          You should have received a copy of the GNU
00024   -_. . .   )=.  =           Library General Public License along with
00025     --        :-=`           this library; see the file COPYING.LIB.
00026                              If not, write to the Free Software Foundation,
00027                              Inc., 59 Temple Place - Suite 330,
00028                              Boston, MA 02111-1307, USA.
00029 
00030 */
00031 
00032 #ifndef ANET_NODE_INTERFACE_H
00033 #define ANET_NODE_INTERFACE_H
00034 
00035 #include <opie2/oapplicationfactory.h>
00036 #include <qpe/qcom.h>
00037 
00038 // {A215A785-FB73-4F74-84B0-053BCC77DB87}
00039 #ifndef IID_NetworkSettings2
00040 
00041 #define IID_NetworkSettings2 QUuid( 0xa215a785, 0xfb73, 0x4f74, 0x84, 0xb0, 0x05, 0x3b, 0xcc, 0x77, 0xdb, 0x87)
00042 
00043 #endif
00044 
00045 
00046 
00050 template <class Node >
00051 struct NS2PrivateFactory {
00052 
00053     inline static void createPlugins( QList<ANetNode> & PNN) {
00054         PNN.append( new Node());
00055     }
00056 
00057 };
00058 
00059 /*
00060  * Stop recursion here
00061  */
00062 template <>
00063 struct NS2PrivateFactory<Opie::Core::NullType> {
00064 
00065     inline static void createPlugins( QList<ANetNode> &) {
00066 
00067     }
00068 
00069 };
00070 
00071 template <class Node, class Tail>
00072 struct NS2PrivateFactory<Opie::Core::Typelist<Node, Tail> > {
00073 
00074     inline static void createPlugins( QList<ANetNode> & PNN ) {
00075         NS2PrivateFactory<Node>::createPlugins(PNN);
00076         NS2PrivateFactory<Tail>::createPlugins(PNN);
00077     }
00078 
00079 };
00080 
00081 class NetNodeInterface : public QUnknownInterface {
00082 
00083 public :
00084 
00085       virtual QRESULT queryInterface( const QUuid& uuid, 
00086                               QUnknownInterface **iface ) = 0;
00087 
00088       virtual void create_plugin( QList<ANetNode> & PNN ) = 0;
00089 };
00090 
00091 template<class Node>
00092 struct NetNodeInterface_T : public NetNodeInterface {
00093 
00094     QRESULT queryInterface(const QUuid& uuid, QUnknownInterface **iface) {
00095         *iface = 0;
00096 
00097         if( uuid == IID_QUnknown ) 
00098           *iface = this;
00099         else if( uuid == IID_NetworkSettings2 ) 
00100           *iface = this;
00101         else 
00102           return QS_FALSE;
00103 
00104         (*iface)->addRef();
00105 
00106         return QS_OK;
00107 
00108     }
00109 
00110     void create_plugin( QList<ANetNode> & PNN ) {
00111 
00112         PNN.append( new Node());
00113 
00114     }
00115 
00116     Q_REFCOUNT
00117 };
00118 
00119 template<class Node, class Tail>
00120 struct NetNodeInterface_T<Opie::Core::Typelist<Node, Tail> >
00121     : public NetNodeInterface {
00122 
00123     QRESULT queryInterface( const QUuid& uuid, 
00124                             QUnknownInterface **iface) {
00125 
00126         *iface = 0;
00127 
00128         if( uuid == IID_QUnknown ) *iface = this;
00129         else if( uuid == IID_NetworkSettings2 ) *iface = this;
00130         else return QS_FALSE;
00131 
00132         (*iface)->addRef();
00133         return QS_OK;
00134 
00135     }
00136 
00137     void create_plugin( QList<ANetNode> & PNN ) {
00138         NS2PrivateFactory<Opie::Core::Typelist<Node,Tail> >::createPlugins( PNN );
00139     }
00140 
00141     Q_REFCOUNT
00142 
00143 };
00144 
00145 #define OPIE_NS2_PLUGIN( factory ) \
00146           Q_EXPORT_INTERFACE() { Q_CREATE_INSTANCE( factory) }
00147 
00148 #endif
00149 

Generated on Sat Nov 5 16:17:54 2005 for OPIE by  doxygen 1.4.2