summaryrefslogtreecommitdiff
path: root/TAO/tao/IIOP_Object.i
blob: 253353844725f0e43c787843dcdc052efc4db710 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
// $Id$

ACE_INLINE
IIOP::Version::Version (CORBA::Octet maj, CORBA::Octet min)
  : major (maj),
    minor (min)
{
}

ACE_INLINE
IIOP::Profile::Profile (const char *h,
                        CORBA::UShort p,
                        const TAO_opaque &key,
                        const ACE_INET_Addr &addr)
  : host (0)
{
  this->set (h, p, key, addr);
}

ACE_INLINE
IIOP::Profile::Profile (void)
  : host (0),
    port (0)
{
}

ACE_INLINE
IIOP::Profile::Profile (const IIOP::Profile &src)
  : host (0)
{
  this->set (src.host,
             src.port,
             src.object_key,
             src.object_addr_);
}

ACE_INLINE
IIOP::Profile::~Profile (void)
{
  delete [] this->host;
}

ACE_INLINE IIOP::Profile &
IIOP::Profile::operator= (const IIOP::Profile &src)
{
  this->set (src.host,
             src.port,
             src.object_key,
             src.object_addr_);
  return *this;
}

ACE_INLINE int
IIOP::Profile::operator== (const IIOP::Profile &rhs)
{
  return 
    this->object_key == rhs.object_key && 
    this->port == rhs.port && 
    ACE_OS::strcmp (this->host, rhs.host) == 0 && 
    this->iiop_version.minor == rhs.iiop_version.minor && 
    this->iiop_version.major == rhs.iiop_version.major;
}

ACE_INLINE void
IIOP::Profile::reset_object_addr (void)
{
  this->object_addr_.set (this->port, this->host);
}

ACE_INLINE ACE_INET_Addr &
IIOP::Profile::object_addr (void)
{
  return this->object_addr_;
}

ACE_INLINE
IIOP_Object::~IIOP_Object (void)
{
  assert (this->refcount_ == 0);
  delete this->fwd_profile_;
  delete this->fwd_profile_lock_ptr_;
  
  // Cleanup hint
  if (this->handler_ != 0)
    this->handler_->cleanup_hint ();
}

ACE_INLINE
IIOP_Object::IIOP_Object (char *repository_id)
  : STUB_Object (repository_id),
    fwd_profile_ (0),
    fwd_profile_success_ (0),
    refcount_ (1),
    use_locate_request_ (0),
    first_locate_request_ (0),
    handler_ (0)
{
  this->fwd_profile_lock_ptr_ = 
    TAO_ORB_Core_instance ()->client_factory ()->create_iiop_profile_lock ();  
}

ACE_INLINE
IIOP_Object::IIOP_Object (char *repository_id,
                          const char *host,
                          CORBA::UShort port,
                          const TAO_opaque &object_key,
                          const ACE_INET_Addr &addr)
  : STUB_Object (repository_id),
    profile (host, port, object_key, addr),
    fwd_profile_ (0),
    fwd_profile_success_ (0),
    refcount_ (1),
    use_locate_request_ (0),
    first_locate_request_ (0),
    handler_ (0)
{
  this->fwd_profile_lock_ptr_ =  
    TAO_ORB_Core_instance ()->client_factory ()->create_iiop_profile_lock ();  
}


ACE_INLINE
IIOP::Profile *
IIOP_Object::get_fwd_profile_i (void)
{
  return this->fwd_profile_;
}

ACE_INLINE
IIOP::Profile *
IIOP_Object::get_fwd_profile (void)
{
  ACE_MT (ACE_GUARD_RETURN (ACE_Lock, 
                            guard, 
                            *this->fwd_profile_lock_ptr_, 
                            0));
  return this->get_fwd_profile_i ();
}


ACE_INLINE
IIOP::Profile *
IIOP_Object::set_fwd_profile (IIOP::Profile *new_profile)
{
  ACE_MT (ACE_GUARD_RETURN (ACE_Lock, 
                            guard, 
                            *this->fwd_profile_lock_ptr_, 
                            0));
  IIOP::Profile *old = this->fwd_profile_;
  if (new_profile != 0)
    {
      delete this->fwd_profile_;
      ACE_NEW_RETURN (this->fwd_profile_,
                      IIOP::Profile (),
                      0);
      *this->fwd_profile_ = *new_profile;
      // use the copy operator on IIOP_Profile
    }
  return old;
}

ACE_INLINE
ACE_Lock &
IIOP_Object::get_fwd_profile_lock (void)
{
  return *this->fwd_profile_lock_ptr_;
}

ACE_INLINE
void 
IIOP_Object::reset_first_locate_request (void)
{
  first_locate_request_ = 1;
}

ACE_INLINE
void 
IIOP_Object::use_locate_requests (CORBA::Boolean use_it)
{
  if (use_it)
    {
      this->first_locate_request_ = 1;
      this->use_locate_request_ = 1;
    }
  else 
    {
      // Don't use it.
      this->first_locate_request_ = 0;
      this->use_locate_request_ = 0;
    }   
} 

ACE_INLINE TAO_Client_Connection_Handler *&
IIOP_Object::handler (void)
{
  return this->handler_;
}

ACE_INLINE void 
IIOP_Object::reset_handler (void)
{
  this->handler_->cleanup_hint ();
  this->handler_ = 0;
}