OmniEvents
Mapper.h
Go to the documentation of this file.
1// Package : omniMapper
2// Mapper.h Author : Duncan Grisby (dpg1)
3//
4// Copyright (C) 2000 AT&T Laboratories Cambridge
5// Copyright (C) 2004 Alex Tingle
6//
7// This file is part of omniEvents. It is based upon omniMapper.
8//
9// omniEvents is free software; you can redistribute it and/or
10// modify it under the terms of the GNU Lesser General Public
11// License as published by the Free Software Foundation; either
12// version 2.1 of the License, or (at your option) any later version.
13//
14// omniEvents is distributed in the hope that it will be useful,
15// but WITHOUT ANY WARRANTY; without even the implied warranty of
16// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17// Lesser General Public License for more details.
18//
19// You should have received a copy of the GNU Lesser General Public
20// License along with this library; if not, write to the Free Software
21// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
22//
23
24#include "Servant.h"
25#include "Orb.h"
26#include <string.h>
27
28namespace OmniEvents {
29
33class Mapper :
34 public Servant,
35 public PortableServer::RefCountServantBase
36{
37public:
38
39 Mapper(const char* id, CORBA::Object_ptr obj)
40 : Servant(Orb::inst()._omniINSPOA.in()),
41 id_( CORBA::string_dup(id) ),
42 obj_( CORBA::Object::_duplicate(obj) )
43 {
44 DB(1,"Initialising Mapper `"<<id<<"'.")
46 _remove_ref();
47 }
48 ~Mapper() { DB(20,"~Mapper()") }
50 CORBA::Boolean _is_a(const char* id) { do_redir(); return 1; }
51
52#ifdef HAVE_OMNIORB4
53 CORBA::Boolean _dispatch(omniCallHandle&) { do_redir(); return 1; }
54#else
55 CORBA::Boolean _dispatch(GIOP_S& ) { do_redir(); return 1; }
56#endif
57
58 void do_redir()
59 {
60 DB(20,"Mapping `"<<id_.in()<<"'")
61#ifdef HAVE_OMNIORB4
62 throw omniORB::LOCATION_FORWARD(CORBA::Object::_duplicate(obj_),0);
63#else
64 throw omniORB::LOCATION_FORWARD(CORBA::Object::_duplicate(obj_) );
65#endif
66 }
67
68 string id() const {return string(id_.in());}
69
70private:
71 CORBA::String_var id_;
72 CORBA::Object_var obj_;
73};
74
75}; // end namespace OmniEvents
#define DB(l, x)
Definition Orb.h:49
A dummy servant that installs itself into the INSPOA and redirects all calls to the real destination.
Definition Mapper.h:36
CORBA::Object_var obj_
Definition Mapper.h:72
CORBA::Boolean _is_a(const char *id)
Definition Mapper.h:50
Mapper(const char *id, CORBA::Object_ptr obj)
Definition Mapper.h:39
CORBA::Boolean _dispatch(GIOP_S &)
Definition Mapper.h:55
string id() const
Definition Mapper.h:68
CORBA::String_var id_
Definition Mapper.h:71
void do_redir()
Definition Mapper.h:58
Singleton class that owns the ORB and various initial references.
Definition Orb.h:70
Base class for servants.
Definition Servant.h:114
void activateObjectWithId(const char *oidStr)
Calls activate_object_with_id() to activate this servant in its POA.
Definition Servant.cc:125
void deactivateObject()
Calls deactivate_object() to deactivate this servant in its POA.
Definition Servant.cc:160