00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024 #include "Servant.h"
00025 #include "Orb.h"
00026 #include <string.h>
00027
00028 namespace OmniEvents {
00029
00033 class Mapper :
00034 public Servant,
00035 public PortableServer::RefCountServantBase
00036 {
00037 public:
00038
00039 Mapper(const char* id, CORBA::Object_ptr obj)
00040 : Servant(Orb::inst()._omniINSPOA.in()),
00041 id_( CORBA::string_dup(id) ),
00042 obj_( CORBA::Object::_duplicate(obj) )
00043 {
00044 DB(1,"Initialising Mapper `"<<id<<"'.")
00045 activateObjectWithId(id);
00046 _remove_ref();
00047 }
00048 ~Mapper() { DB(20,"~Mapper()") }
00049 void destroy() { deactivateObject(); }
00050 CORBA::Boolean _is_a(const char* id) { do_redir(); return 1; }
00051
00052 #ifdef HAVE_OMNIORB4
00053 CORBA::Boolean _dispatch(omniCallHandle&) { do_redir(); return 1; }
00054 #else
00055 CORBA::Boolean _dispatch(GIOP_S& ) { do_redir(); return 1; }
00056 #endif
00057
00058 void do_redir()
00059 {
00060 DB(20,"Mapping `"<<id_.in()<<"'")
00061 #ifdef HAVE_OMNIORB4
00062 throw omniORB::LOCATION_FORWARD(CORBA::Object::_duplicate(obj_),0);
00063 #else
00064 throw omniORB::LOCATION_FORWARD(CORBA::Object::_duplicate(obj_) );
00065 #endif
00066 }
00067
00068 string id() const {return string(id_.in());}
00069
00070 private:
00071 CORBA::String_var id_;
00072 CORBA::Object_var obj_;
00073 };
00074
00075 };