00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
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
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
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