1 // -*- Mode: C++; -*-
2 // Package : omniORB2
3 // giopBiDir.h Created on: 17/7/2001
4 // Author : Sai Lai Lo (sll)
5 //
6 // Copyright (C) 2005-2013 Apasphere Ltd
7 // Copyright (C) 2001 AT&T Laboratories Cambridge
8 //
9 // This file is part of the omniORB library
10 //
11 // The omniORB library is free software; you can redistribute it and/or
12 // modify it under the terms of the GNU Lesser General Public
13 // License as published by the Free Software Foundation; either
14 // version 2.1 of the License, or (at your option) any later version.
15 //
16 // This library is distributed in the hope that it will be useful,
17 // but WITHOUT ANY WARRANTY; without even the implied warranty of
18 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
19 // Lesser General Public License for more details.
20 //
21 // You should have received a copy of the GNU Lesser General Public
22 // License along with this library. If not, see http://www.gnu.org/licenses/
23 //
24 //
25 // Description:
26 // *** PROPRIETARY INTERFACE ***
27 //
28
29 #ifndef __GIOPBIDIR_H__
30 #define __GIOPBIDIR_H__
31
32 #include <giopRope.h>
33
34 #ifdef _core_attr
35 # error "A local CPP macro _core_attr has already been defined."
36 #endif
37
38 #if defined(_OMNIORB_LIBRARY)
39 # define _core_attr
40 #else
41 # define _core_attr _OMNIORB_NTDLL_IMPORT
42 #endif
43
OMNI_NAMESPACE_BEGIN(omni)44 OMNI_NAMESPACE_BEGIN(omni)
45
46 ////////////////////////////////////////////////////////////////////////
47 ////////////////////////////////////////////////////////////////////////
48 class BiDirInfo : public omniIOR::IORExtraInfo {
49 public:
50 BiDirInfo(char* s) :
51 OMNIORB_BASE_CTOR(omniIOR::)IORExtraInfo(IOP::TAG_OMNIORB_BIDIR),
52 sendfrom(s) {}
53
54 CORBA::String_var sendfrom;
55
56 ~BiDirInfo() {}
57
58 private:
59 BiDirInfo();
60 BiDirInfo(const BiDirInfo&);
61 BiDirInfo& operator=(const BiDirInfo&);
62 };
63
64 ////////////////////////////////////////////////////////////////////////
65 ////////////////////////////////////////////////////////////////////////
66 class BiDirServerRope : public giopRope {
67 public:
68
69 static int selectRope(const giopAddressList&, omniIOR::IORInfo*, Rope*&);
70 // Look into the IORInfo, if bidirectional giop is suitable for this ior
71 // (i.e. the IOP component TAG_OMNIORB_BIDIR exists and its GIOP version
72 // is >= 1.2), search the list and return the BiDirServerRope whose
73 // redirection addresses matches one of the addresses in the
74 // giopAddressList. The ref count of the returned rope is incremented by
75 // 1. If a rope is found, returns 1. Otherwise returns 0.
76 //
77 // Thread Safety preconditions:
78 // Caller *must* hold omniTransportLock.
79
80 static BiDirServerRope* addRope(giopStrand*, const giopAddressList&);
81 // Add a BiDirServerRope for the bidirectional strand if one has not
82 // been created already. Add the list of redirection addresses to
83 // this rope. Return the rope instance. Notice that the reference
84 // count of the rope is unchanged.
85 //
86 // Thread Safety preconditions:
87 // Caller *must* hold omniTransportLock.
88
89
90 BiDirServerRope(giopStrand*,giopAddress*);
91
92 IOP_C* acquireClient(const omniIOR*,
93 const CORBA::Octet* key,
94 CORBA::ULong keysize,
95 omniCallDescriptor*); // override giopRope
96
97 static _core_attr RopeLink ropes;
98 // All ropes created by addRope are linked together by this list.
99
100 virtual void decrRefCount();
101
102 virtual ~BiDirServerRope();
103
104 protected:
105 virtual void realIncrRefCount();
106
107 private:
108
109 CORBA::String_var pd_sendfrom;
110 giopAddressList pd_redirect_addresses;
111
112 CORBA::Boolean match(const char* sendfrom,
113 const giopAddressList& addrlist) const;
114
115 BiDirServerRope();
116 BiDirServerRope(const BiDirServerRope&);
117 BiDirServerRope& operator=(const BiDirServerRope&);
118 };
119
120 ////////////////////////////////////////////////////////////////////////
121 ////////////////////////////////////////////////////////////////////////
122 class BiDirClientRope : public giopRope {
123 public:
124
125 BiDirClientRope(const giopAddressList& addrlist, omniIOR::IORInfo* info);
126
127 IOP_C* acquireClient(const omniIOR* ior,
128 const CORBA::Octet* key,
129 CORBA::ULong keysize,
130 omniCallDescriptor* cd); // override giopRope
131 protected:
132 void filterAndSortAddressList();
133
134 private:
135 omni_tracedmutex pd_lock;
136
137 BiDirClientRope();
138 BiDirClientRope(const BiDirClientRope&);
139 BiDirClientRope& operator=(const BiDirClientRope&);
140 };
141
142 OMNI_NAMESPACE_END(omni)
143
144 #undef _core_attr
145
146 #endif // __GIOPBIDIR_H__
147