servantowner.h

Go to the documentation of this file.
00001 #ifndef _BONOBOMM_SERVERS_SERVANT_OWNER_H
00002 #define _BONOBOMM_SERVERS_SERVANT_OWNER_H
00003 
00004 /* $Id: servantowner.h,v 1.1 2003/11/17 22:15:29 bowens Exp $ */
00005 
00006 
00007 /* servantowner.h
00008  *
00009  * Copyright (C) 2003 The libbonobomm Development Team
00010  *
00011  * This library is free software; you can redistribute it and/or
00012  * modify it under the terms of the GNU Library General Public
00013  * License as published by the Free Software Foundation; either
00014  * version 2 of the License, or (at your option) any later version.
00015  *
00016  * This library is distributed in the hope that it will be useful,
00017  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00018  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00019  * Library General Public License for more details.
00020  *
00021  * You should have received a copy of the GNU Library General Public
00022  * License along with this library; if not, write to the Free
00023  * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
00024  */
00025 
00026 
00027 #include <bonobo/bonobo-main.h>
00028 #include <orbitcpp/orb-cpp/orbitcpp.h>
00029 
00030 
00031 
00032 namespace Gnome
00033 {
00034 
00035 namespace Bonobo
00036 {
00037 
00038 namespace Servers
00039 {
00040 
00041 // Encapsulate ownership of a single servant and automatically
00042 // deactivate in bonobo POA at end of lifetime.
00043 template <class S>
00044 class ServantOwner {
00045 protected:
00046         S m_servant;
00047 
00048         ~ServantOwner()
00049         {
00050                 _orbitcpp::CEnvironment env;
00051                 PortableServer_POA poa = bonobo_poa();
00052                                                                      
00053 
00054                 PortableServer_Servant servant =
00055                 m_servant._orbitcpp_get_c_servant();
00056                 PortableServer_ObjectId* oid =
00057                 PortableServer_POA_servant_to_id(poa, servant, env._orbitcpp_cobj());
00058                 env.propagate_poaex();
00059                 PortableServer_POA_deactivate_object(poa, oid,
00060                 env._orbitcpp_cobj());
00061                 env.propagate_poaex();
00062         }
00063 };
00064 
00065 } //namespace Servers
00066 } //namespace Bonobo
00067 } //namespace Gnome
00068 
00069         
00070 #endif //_BONOBOMM_SERVERS_UNKNOWN_CPPIMPL_H
00071 

Generated on Mon Oct 2 01:01:40 2006 for gnomemm2 by  doxygen 1.4.6