Main Page | Namespace List | Class Hierarchy | Class List | Directories | File List | Namespace Members | Class 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-2005 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_OMNIORB3
00032 #  include <omniORB3/CORBA.h>
00033 #endif
00034 
00035 #ifdef HAVE_OMNIORB4
00036 #  include <omniORB4/CORBA.h>
00037 #endif
00038 
00039 //
00040 // Debug definitions for servants.
00041 //
00042 
00043 #if OMNIEVENTS__DEBUG_ALL
00044 #  define OMNIEVENTS__DEBUG_REF_COUNTS 1
00045 #  define OMNIEVENTS__DEBUG_SERVANT 1
00046 #else
00047 
00049 #  define OMNIEVENTS__DEBUG_REF_COUNTS 0
00050 
00052 #  define OMNIEVENTS__DEBUG_SERVANT 0
00053 #endif
00054 
00055 #if OMNIEVENTS__DEBUG_REF_COUNTS
00056 #  define OMNIEVENTS__DEBUG_REF_COUNTS__DECL void _add_ref();void _remove_ref();
00057 #  define OMNIEVENTS__DEBUG_REF_COUNTS__DEFN(C) \
00058    void C::_add_ref() { \
00059      DB(20,#C "::_add_ref()") \
00060      PortableServer::RefCountServantBase::_add_ref(); \
00061    } \
00062    void C::_remove_ref() { \
00063      DB(20,#C "::_remove_ref()") \
00064      PortableServer::RefCountServantBase::_remove_ref(); \
00065    }
00066 #else
00067 
00068 #  define OMNIEVENTS__DEBUG_REF_COUNTS__DECL
00069 
00070 #  define OMNIEVENTS__DEBUG_REF_COUNTS__DEFN(C)
00071 #endif
00072 
00073 
00074 namespace OmniEvents {
00075 
00082 CORBA::Object_ptr
00083 createReference(PortableServer::POA_ptr poa, const char* repositoryId);
00084 
00094 template<class T>
00095 typename T::_ptr_type
00096 createNarrowedReference(PortableServer::POA_ptr poa, const char* repositoryId)
00097 {
00098   CORBA::Object_var obj =createReference(poa,repositoryId);
00099 #ifdef HAVE_OMNIORB4
00100   return T::_unchecked_narrow(obj.in());
00101 #else
00102   return T::_narrow(obj.in());
00103 #endif
00104 }
00105 
00107 char* newUniqueId();
00108 
00109 
00113 class Servant : public virtual PortableServer::ServantBase
00114 {
00115 public:
00116   virtual PortableServer::POA_ptr _default_POA();
00117   virtual ~Servant();
00118 
00119 #if OMNIEVENTS__DEBUG_SERVANT
00120   static int _objectCount;
00121 #endif
00122 
00123 protected:
00124   Servant(PortableServer::POA_ptr poa);
00125 
00127   void activateObjectWithId(const char* oidStr);
00129   void deactivateObject();
00130 
00131   PortableServer::POA_var _poa;
00132 
00133 private:
00135   Servant();
00136 };
00137 
00138 }; // end namespace OmniEvents
00139 
00140 #endif // OMNIEVENTS__SERVANT_H

Generated on Fri Aug 26 20:56:14 2005 for OmniEvents by  doxygen 1.4.3-20050530