OmniEvents
ProxyPushConsumer.h
Go to the documentation of this file.
1 // Package : omniEvents
2 // ProxyPushConsumer.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__PROXYPUSHCONSUMER_H
25 #define OMNIEVENTS__PROXYPUSHCONSUMER_H
26 
27 #ifdef HAVE_CONFIG_H
28 # include "config.h"
29 #endif
30 
31 #include <string>
32 #include <map>
33 #include <list>
34 
35 #ifdef HAVE_IOSTREAM
36 # include <iostream>
37 #else
38 # include <iostream.h>
39 #endif
40 
41 #include "Callback.h"
42 #include "Servant.h"
43 
44 #include "CosEventChannelAdmin.hh"
45 
46 #ifdef HAVE_STD_IOSTREAM
47 using namespace std;
48 #endif
49 
50 namespace OmniEvents {
51 
52 class PersistNode;
53 class ConsumerAdmin_i;
54 
61 : public virtual POA_CosEventChannelAdmin::ProxyPushConsumer,
62  public Servant
63 {
64 public: // CORBA interface methods
68  void connect_push_supplier(CosEventComm::PushSupplier_ptr pushSupplier);
69 
73  void disconnect_push_consumer();
74 
76  void push(const CORBA::Any& event);
77 
78 public:
80  PortableServer::POA_ptr parentPoa,
81  list<CORBA::Any*>& q,
82  ConsumerAdmin_i& consumerAdmin
83  );
84  virtual ~ProxyPushConsumer_i();
85 
86  void trigger() {_useLocalQueue=false;}
87 
94  CosEventChannelAdmin::ProxyPushConsumer_ptr createObject();
95 
97  void disconnect();
98 
100  void reincarnate(const PersistNode& node);
102  void output(ostream& os) const;
103 
104 private:
105  string currentObjectId() const;
106  struct Connection : public Callback
107  {
108  const char* _channelName;
109  string _oidstr;
110  CosEventComm::PushSupplier_var _target;
112 
114  Connection(
115  const char* channelName,
116  const string& oidstr,
117  CosEventComm::PushSupplier_ptr pushSupplier,
118  bool isProxy=false
119  );
120  virtual ~Connection();
123  void callback(CORBA::Request_ptr req);
125  void output(ostream& os) const;
126  private:
127  Connection();
128 #if OMNIEVENTS__DEBUG_SERVANT
129  static int _objectCount;
130 #endif
131  };
132 
133  typedef map<string,Connection*> Connections_t;
135  CORBA::String_var _channelName;
137  list<CORBA::Any*>& _queue;
139 };
140 
141 }; // end namespace OmniEvents
142 
143 #endif // OMNIEVENTS__PROXYPUSHCONSUMER_H
OmniEvents::ProxyPushConsumer_i::Connection
Definition: ProxyPushConsumer.h:106
OmniEvents::ProxyPushConsumer_i::Connection::_targetIsProxy
bool _targetIsProxy
TRUE if _target is a ProxyPushSupplier.
Definition: ProxyPushConsumer.h:111
OmniEvents::ProxyPushConsumer_i::_connections
Connections_t _connections
Definition: ProxyPushConsumer.h:134
OmniEvents::ProxyPushConsumer_i
Default servant for ProxyPushConsumer objects.
Definition: ProxyPushConsumer.h:60
Callback.h
OmniEvents::ProxyPushConsumer_i::_queue
list< CORBA::Any * > & _queue
Definition: ProxyPushConsumer.h:137
OmniEvents::ProxyPushConsumer_i::Connection::_channelName
const char * _channelName
Definition: ProxyPushConsumer.h:108
OmniEvents::ProxyPushConsumer_i::_consumerAdmin
ConsumerAdmin_i & _consumerAdmin
Definition: ProxyPushConsumer.h:136
config.h
OmniEvents::Callback
Interface for classes that wish to receive callbacks from deferred requests.
Definition: Callback.h:43
OmniEvents::PersistNode
Definition: PersistNode.h:48
OmniEvents::ProxyPushConsumer_i::Connection::_oidstr
string _oidstr
Definition: ProxyPushConsumer.h:109
Servant.h
OmniEvents
Definition: Callback.h:39
OmniEvents::ProxyPushConsumer_i::trigger
void trigger()
Definition: ProxyPushConsumer.h:86
OmniEvents::ProxyPushConsumer_i::Connections_t
map< string, Connection * > Connections_t
Definition: ProxyPushConsumer.h:133
OMNIEVENTS__DEBUG_REF_COUNTS__DECL
#define OMNIEVENTS__DEBUG_REF_COUNTS__DECL
Declares debug versions of _add/remove_ref().
Definition: Servant.h:68
OmniEvents::ProxyPushConsumer_i::_channelName
CORBA::String_var _channelName
Definition: ProxyPushConsumer.h:135
OmniEvents::ProxyPushConsumer_i::_useLocalQueue
bool _useLocalQueue
Switch between RT/chunked modes.
Definition: ProxyPushConsumer.h:138
OmniEvents::ProxyPushConsumer_i::Connection::_target
CosEventComm::PushSupplier_var _target
Definition: ProxyPushConsumer.h:110
OmniEvents::ConsumerAdmin_i
Definition: ConsumerAdmin.h:54
OmniEvents::Servant
Base class for servants.
Definition: Servant.h:113