OmniEvents
Servant.h
Go to the documentation of this file.
1// Package : omniEvents
2// Servant.h Created : 2003/12/04
3// Author : Alex Tingle
4//
5// Copyright (C) 2003-2005 Alex Tingle.
6//
7// This file is part of the omniEvents application.
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#ifndef OMNIEVENTS__SERVANT_H
25#define OMNIEVENTS__SERVANT_H
26
27#ifdef HAVE_CONFIG_H
28# include "config.h"
29#endif
30
31#ifdef HAVE_OMNIORB3
32# include <omniORB3/CORBA.h>
33#endif
34
35#ifdef HAVE_OMNIORB4
36# include <omniORB4/CORBA.h>
37#endif
38
39//
40// Debug definitions for servants.
41//
42
43#if OMNIEVENTS__DEBUG_ALL
44# define OMNIEVENTS__DEBUG_REF_COUNTS 1
45# define OMNIEVENTS__DEBUG_SERVANT 1
46#else
49# define OMNIEVENTS__DEBUG_REF_COUNTS 0
52# define OMNIEVENTS__DEBUG_SERVANT 0
53#endif
54
55#if OMNIEVENTS__DEBUG_REF_COUNTS
56# define OMNIEVENTS__DEBUG_REF_COUNTS__DECL void _add_ref();void _remove_ref();
57# define OMNIEVENTS__DEBUG_REF_COUNTS__DEFN(C) \
58 void C::_add_ref() { \
59 DB(20,#C "::_add_ref()") \
60 PortableServer::RefCountServantBase::_add_ref(); \
61 } \
62 void C::_remove_ref() { \
63 DB(20,#C "::_remove_ref()") \
64 PortableServer::RefCountServantBase::_remove_ref(); \
65 }
66#else
68# define OMNIEVENTS__DEBUG_REF_COUNTS__DECL
70# define OMNIEVENTS__DEBUG_REF_COUNTS__DEFN(C)
71#endif
72
73
74namespace OmniEvents {
75
82CORBA::Object_ptr
83createReference(PortableServer::POA_ptr poa, const char* repositoryId);
84
94template<class T>
95typename T::_ptr_type
96createNarrowedReference(PortableServer::POA_ptr poa, const char* repositoryId)
97{
98 CORBA::Object_var obj =createReference(poa,repositoryId);
99#ifdef HAVE_OMNIORB4
100 return T::_unchecked_narrow(obj.in());
101#else
102 return T::_narrow(obj.in());
103#endif
104}
105
107char* newUniqueId();
108
109
113class Servant : public virtual PortableServer::ServantBase
114{
115public:
116 virtual PortableServer::POA_ptr _default_POA();
117 virtual ~Servant();
118
119#if OMNIEVENTS__DEBUG_SERVANT
120 static int _objectCount;
121#endif
122
123protected:
124 Servant(PortableServer::POA_ptr poa);
125
127 void activateObjectWithId(const char* oidStr);
129 void deactivateObject();
130
131 PortableServer::POA_var _poa;
132
133private:
136};
137
138}; // end namespace OmniEvents
139
140#endif // OMNIEVENTS__SERVANT_H
CORBA::Object_ptr createReference(PortableServer::POA_ptr poa, const char *repositoryId)
Helper method called by createNarrowedReference().
Definition Servant.cc:54
T::_ptr_type createNarrowedReference(PortableServer::POA_ptr poa, const char *repositoryId)
Helper method that creates a new CORBA object and then narrows it to the appropriate type.
Definition Servant.h:96
char * newUniqueId()
Generates a unique object ID string, based upon the current PID and time.
Definition Servant.cc:71
Base class for servants.
Definition Servant.h:114
virtual ~Servant()
Definition Servant.cc:110
virtual PortableServer::POA_ptr _default_POA()
Definition Servant.cc:119
PortableServer::POA_var _poa
Definition Servant.h:131
void activateObjectWithId(const char *oidStr)
Calls activate_object_with_id() to activate this servant in its POA.
Definition Servant.cc:125
Servant()
No default constructor.
void deactivateObject()
Calls deactivate_object() to deactivate this servant in its POA.
Definition Servant.cc:160