Main Page   Namespace List   Class Hierarchy   Compound List   File List   Namespace Members   Compound Members   File Members  

Orb.h

Go to the documentation of this file.
00001 //                            Package   : omniEvents
00002 // Orb.h                      Created   : 2003/12/04
00003 //                            Author    : Alex Tingle
00004 //
00005 //    Copyright (C) 2003 Alex Tingle.
00006 //
00007 //    This file is part of the omniEvents application.
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 #ifndef OMNIEVENTS__ORB_H
00025 #define OMNIEVENTS__ORB_H
00026 
00027 #ifdef HAVE_CONFIG_H
00028 #  include "config.h"
00029 #endif
00030 
00031 #include <list>
00032 #include <omniORB4/CORBA.h>
00033 
00034 #ifdef HAVE_STD_STL
00035 using namespace std;
00036 #endif
00037 
00038 namespace OmniEvents {
00039 
00041 class Orb
00042 {
00043 private:
00044   static Orb _inst;
00045   list<CORBA::Request_var> _orphans;
00046 
00047 public:
00048   inline static Orb& inst()
00049   {
00050     return _inst;
00051   }
00052 
00053   CORBA::ORB_var               _orb;
00054   PortableServer::POA_var      _RootPOA;
00055   PortableServer::POA_var      _omniINSPOA;
00056   PortableServer::Current_ptr  _POACurrent;
00057   CosNaming::NamingContext_var _NameService;
00058 
00059   void init(int argc, char** argv);
00060   
00064   void run();
00065   
00071   void orphanRequest(CORBA::Request* req);
00072 };
00073 
00075 template<class T>
00076 typename T::_ptr_type string_to_(const char* oidStr)
00077 {
00078   CORBA::Object_var obj =Orb::inst()._orb->string_to_object(oidStr);
00079   if(CORBA::is_nil(obj.in()))
00080     throw CORBA::BAD_PARAM();
00081 
00082   typename T::_var_type result =T::_narrow(obj);
00083   if(CORBA::is_nil(result.in()))
00084     throw CORBA::BAD_PARAM();
00085 
00086   return result._retn();
00087 }
00088 
00089 }; // end namespace OmniEvents
00090 
00091 #endif // OMNIEVENTS__ORB_H

Generated on Fri Dec 12 10:53:02 2003 for OmniEvents by doxygen1.2.15