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

Servant.h

Go to the documentation of this file.
00001 //                            Package   : omniEvents
00002 // Servant.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__SERVANT_H
00025 #define OMNIEVENTS__SERVANT_H
00026 
00027 #ifdef HAVE_CONFIG_H
00028 #  include "config.h"
00029 #endif
00030 
00031 #ifdef HAVE_IOSTREAM
00032 #  include <iostream>
00033 #else
00034 #  include <iostream.h>
00035 #endif
00036 
00037 #include <string>
00038 #include <omniORB4/CORBA.h>
00039 
00040 using namespace std;
00041 
00042 
00043 namespace OmniEvents {
00044 
00051 CORBA::Object_ptr
00052 createReference(PortableServer::POA_ptr poa, const char* repositoryId);
00053 
00063 template<class T>
00064 typename T::_ptr_type
00065 createNarrowedReference(PortableServer::POA_ptr poa, const char* repositoryId)
00066 {
00067   CORBA::Object_var obj =createReference(poa,repositoryId);
00068   return T::_unchecked_narrow(obj.in());
00069 }
00070 
00072 char* newUniqueId();
00073 
00074 
00078 class Servant : public virtual PortableServer::ServantBase
00079 {
00080 public:
00081   virtual PortableServer::POA_ptr _default_POA();
00082   virtual ~Servant();
00083 
00084 protected:
00085   Servant(PortableServer::POA_ptr poa);
00086 
00088   void activateObjectWithId(const char* oidStr);
00090   void deactivateObject();
00091 
00092   PortableServer::POA_var _poa;
00093   
00095   class Output
00096   {
00097     ostream& _os;
00098     mutable string _indent;
00099   public:
00100     Output(ostream& os, string indent):_os(os),_indent(indent){}
00101     Output(const Output& v):_os(v._os),_indent(v._indent){v._indent="";}
00102     ~Output(){if(!_indent.empty())_os<<_indent<<"}\n";}
00103   };
00105   Output basicOutput(
00106     ostream& os, const char* name, int indent,
00107     PortableServer::ServantBase* servant,
00108     CORBA::Object_ptr target=CORBA::Object::_nil()
00109   );
00110 
00111 private:
00113   Servant();
00114 };
00115 
00116 }; // end namespace OmniEvents
00117 
00118 #endif // OMNIEVENTS__SERVANT_H

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