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 #ifndef __ObjrefImporterNeed_H_
00030 #define __ObjrefImporterNeed_H_
00031
00032 #include <debug.h>
00033 #include <DWARF/Service.h>
00034
00035 namespace DWARF {
00036
00037
00038
00039
00040
00041
00042
00043 template<class CORBAInterface> class ObjrefImporterNeed
00044 : public POA_DWARF::SvcProtObjrefImporter
00045 {
00046 public:
00047
00048 class Processor
00049 {
00050 public:
00051 virtual void onImport( typename CORBAInterface::_ptr_type pInterface,
00052 ObjrefImporterNeed<CORBAInterface>* pImporter ) = 0;
00053 };
00054
00055 protected:
00056 typename CORBAInterface::_var_type m_Interface;
00057 Processor* m_pProcessor;
00058
00059 public:
00060
00061 ObjrefImporterNeed( Processor* pProcessor = 0 )
00062 : m_pProcessor( pProcessor )
00063 {}
00064
00065
00066 bool hasInterface() const
00067 { return !CORBA::is_nil( m_Interface ); }
00068
00069
00070 const typename CORBAInterface::_var_type& getInterface() const
00071 { return m_Interface; }
00072
00073
00074 void setProcessor( Processor* pProcessor )
00075 { m_pProcessor = pProcessor; }
00076
00077
00078
00079 void importObjref( CORBA::Object_ptr o )
00080 {
00081 DEBUGSTREAM( 10, "Got an object reference" );
00082
00083 m_Interface = CORBAInterface::_narrow( o );
00084
00085 if ( !hasInterface() )
00086 { DEBUGSTREAM( 2, "Got objref of wrong type or _nil" ); }
00087 else
00088 if ( m_pProcessor )
00089 m_pProcessor->onImport( m_Interface, this );
00090 }
00091
00092
00093
00094 };
00095
00096 }
00097
00098 #endif //__ObjrefImporterNeed_H_