1 // -*- Mode: C++; -*-
2 //                            Package   : omniORB2
3 // omniTransport.h            Created on: 05/01/2001
4 //                            Author    : Sai Lai Lo (sll)
5 //
6 //    Copyright (C) 2001 AT&T Laboratories Cambridge
7 //
8 //    This file is part of the omniORB library
9 //
10 //    The omniORB library is free software; you can redistribute it and/or
11 //    modify it under the terms of the GNU Lesser General Public
12 //    License as published by the Free Software Foundation; either
13 //    version 2.1 of the License, or (at your option) any later version.
14 //
15 //    This library is distributed in the hope that it will be useful,
16 //    but WITHOUT ANY WARRANTY; without even the implied warranty of
17 //    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
18 //    Lesser General Public License for more details.
19 //
20 //    You should have received a copy of the GNU Lesser General Public
21 //    License along with this library. If not, see http://www.gnu.org/licenses/
22 //
23 //
24 // Description:
25 //	*** PROPRIETARY INTERFACE ***
26 //
27 
28 #ifndef __OMNITRANSPORT_H__
29 #define __OMNITRANSPORT_H__
30 
31 class omniCallDescriptor;
32 
33 #ifdef _core_attr
34 # error "A local CPP macro _core_attr has already been defined."
35 #endif
36 
37 #if defined(_OMNIORB_LIBRARY)
38 #     define _core_attr
39 #else
40 #     define _core_attr _OMNIORB_NTDLL_IMPORT
41 #endif
42 
43 OMNI_NAMESPACE_BEGIN(omni)
44 
45 // A Rope is an abstraction through which a client can connect to a
46 // remote address space.
47 //
48 // A rope creates network connections to the remote address on demand.
49 // At any time, there can be 0 to n number of network connections associated
50 // with each rope.
51 //
52 // Each network connection is represented by a Strand.
53 
54 extern _core_attr omni_tracedmutex* omniTransportLock;
55 
56 class IOP_C;
57 class IOP_S;
58 class Rope;
59 class Strand;
60 
61 ////////////////////////////////////////////////////////////////////////
62 ////////////////////////////////////////////////////////////////////////
63 class StrandList {
64 public:
65   StrandList* next;
66   StrandList* prev;
67 
StrandList()68   StrandList() {
69 		next = this;
70 		prev = this;
71 	}
72 
73   void insert(StrandList& head);
74   void remove();
75   static _CORBA_Boolean is_empty(StrandList& head);
76 
77 private:
78   StrandList(const StrandList&);
79   StrandList& operator=(const StrandList&);
80 };
81 
82 
83 ////////////////////////////////////////////////////////////////////////
84 ////////////////////////////////////////////////////////////////////////
85 class RopeLink {
86 public:
87   RopeLink* next;
88   RopeLink* prev;
89 
RopeLink()90   RopeLink() {
91 		next = this;
92 		prev = this;
93 	}
94 
95   void insert(RopeLink& head);
96   void remove();
97   static _CORBA_Boolean is_empty(RopeLink& head);
98 
99 private:
100   RopeLink(const RopeLink&);
101   RopeLink& operator=(const RopeLink&);
102 };
103 
104 ////////////////////////////////////////////////////////////////////////
105 ////////////////////////////////////////////////////////////////////////
106 class Rope {
107 public:
108 
Rope()109   Rope() {}
110 
~Rope()111   virtual ~Rope() {}
112 
113   virtual IOP_C* acquireClient(const omniIOR*,
114 			       const _CORBA_Octet*,_CORBA_ULong,
115 			       omniCallDescriptor*) = 0;
116   virtual void releaseClient(IOP_C*) = 0;
117 
118   virtual void incrRefCount() = 0;
119   virtual void decrRefCount() = 0;
120 
121   virtual void disconnect() = 0;
122 
123   friend class Strand;
124 
125 protected:
126   RopeLink pd_strands; // this is a list of strands that connects to the same
127                        // remote address space.
128 
129 private:
130   Rope(const Rope&);
131   Rope& operator=(const Rope&);
132 };
133 
134 ////////////////////////////////////////////////////////////////////////
135 ////////////////////////////////////////////////////////////////////////
136 class Strand : public RopeLink, public StrandList {
137 public:
138 
Strand()139   Strand() {}
~Strand()140   virtual ~Strand() {}
141 
142 private:
143   Strand(const Strand&);
144   Strand& operator=(const Strand&);
145 };
146 
147 OMNI_NAMESPACE_END(omni)
148 
149 #undef _core_attr
150 
151 #endif // __OMNITRANSPORT_H__
152