OmniEvents
ProxyPushSupplier.h
Go to the documentation of this file.
1 // Package : omniEvents
2 // ProxyPushSupplier.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__PROXYPUSHSUPPLIER_H
25 #define OMNIEVENTS__PROXYPUSHSUPPLIER_H
26 
27 #ifdef HAVE_CONFIG_H
28 # include "config.h"
29 #endif
30 
31 #ifdef HAVE_IOSTREAM
32 # include <iostream>
33 #else
34 # include <iostream.h>
35 #endif
36 
37 #include "Callback.h"
38 #include "EventQueue.h"
39 #include "ProxyManager.h"
40 
41 #include "CosEventChannelAdmin.hh"
42 
43 #ifdef HAVE_STD_IOSTREAM
44 using namespace std;
45 #endif
46 
47 namespace OmniEvents {
48 
50 : public ProxyManager,
51  public omni_thread
52 {
53 public: // CORBA interface methods
54  PortableServer::Servant incarnate(
55  const PortableServer::ObjectId& oid,
56  PortableServer::POA_ptr poa
57  );
59  void etherealize(
60  const PortableServer::ObjectId& oid,
61  PortableServer::POA_ptr adapter,
62  PortableServer::Servant serv,
63  CORBA::Boolean cleanup_in_progress,
64  CORBA::Boolean remaining_activations
65  );
66 public:
67  ProxyPushSupplierManager(PortableServer::POA_ptr parentPoa,EventQueue& q);
69  CosEventChannelAdmin::ProxyPushSupplier_ptr createObject();
70 
72  void disconnect();
73 
74  void* run_undetached(void*);
75  void _add_ref();
76  void _remove_ref();
77 
78  omni_mutex _lock;
79  omni_condition _condition;
80 
86  {
90  public:
92  inline ~PauseThenWake();
93  };
94 
95 private:
97  int _refCount;
98 };
99 
100 
102 : public virtual POA_CosEventChannelAdmin::ProxyPushSupplier,
103  public Proxy,
104  public EventQueue::Reader,
105  public Callback
106 {
107 public: // CORBA interface methods
108  void connect_push_consumer(CosEventComm::PushConsumer_ptr pushConsumer);
109  void disconnect_push_supplier();
110 public:
111  ProxyPushSupplier_i(PortableServer::POA_ptr poa, EventQueue& q);
114 
118  inline void trigger(bool& busy, bool& waiting);
119 
121  void callback(CORBA::Request_ptr req);
122  void reincarnate(const string& oid, const PersistNode& node);
123  void output(ostream &os);
124 private:
125  CosEventComm::PushConsumer_var _target;
127 };
128 
129 
130 //
131 // Inline Implementations.
132 //
133 
134 inline ProxyPushSupplierManager::PauseThenWake::PauseThenWake(
136 ):_p(p)
137 {
138  if(_p)
139  _p->_lock.lock();
140 }
141 
143 {
144  if(_p)
145  {
146  _p->_lock.unlock();
147  _p->_condition.signal(); // Wake up the thread if it's asleep.
148  }
149 }
150 
151 
152 }; // end namespace OmniEvents
153 
154 #endif // OMNIEVENTS__PROXYPUSHSUPPLIER_H
#define OMNIEVENTS__DEBUG_REF_COUNTS__DECL
Declares debug versions of _add/remove_ref().
Definition: Servant.h:68
Interface for classes that wish to receive callbacks from deferred requests.
Definition: Callback.h:46
The EventQueue is a circular buffer, that contains _size-1 events.
Definition: EventQueue.h:57
Base class for ServantActivator classes that manage Proxy servants.
Definition: ProxyManager.h:60
Base class for three of the four Proxy servants.
Definition: ProxyManager.h:107
Helper class that locks ProxyPushSupplier upon construction, and wakes it up on destruction.
PauseThenWake(const PauseThenWake &)
Dummy, no implementation.
CosEventComm::PushConsumer_var _target
bool _targetIsProxy
TRUE if _target is a ProxyPushConsumer.