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:
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
#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
Default servant for ProxyPushConsumer objects.
bool _useLocalQueue
Switch between RT/chunked modes.
map< string, Connection * > Connections_t
bool _targetIsProxy
TRUE if _target is a ProxyPushSupplier.
CosEventComm::PushSupplier_var _target
Base class for servants.
Definition: Servant.h:114