OmniEvents
|
00001 // Package : omniMapper 00002 // Mapper.h Author : Duncan Grisby (dpg1) 00003 // 00004 // Copyright (C) 2000 AT&T Laboratories Cambridge 00005 // Copyright (C) 2004 Alex Tingle 00006 // 00007 // This file is part of omniEvents. It is based upon omniMapper. 00008 // 00009 // omniEvents is free software; you can redistribute it and/or 00010 // modify it under the terms of the GNU Lesser General Public 00011 // License as published by the Free Software Foundation; either 00012 // version 2.1 of the License, or (at your option) any later version. 00013 // 00014 // omniEvents is distributed in the hope that it will be useful, 00015 // but WITHOUT ANY WARRANTY; without even the implied warranty of 00016 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 00017 // Lesser General Public License for more details. 00018 // 00019 // You should have received a copy of the GNU Lesser General Public 00020 // License along with this library; if not, write to the Free Software 00021 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 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 }; // end namespace OmniEvents