#include <MProfile.h>
Collaboration diagram for TAO_MProfile:
Public Member Functions | |
TAO_MProfile (CORBA::ULong sz=0) | |
TAO_MProfile (const TAO_MProfile &mprofiles) | |
TAO_MProfile & | operator= (const TAO_MProfile &mprofiles) |
Assigment operator. | |
~TAO_MProfile (void) | |
int | set (CORBA::ULong sz) |
int | set (const TAO_MProfile &mprofile) |
int | grow (CORBA::ULong sz) |
TAO_Profile * | get_cnext (void) |
Treat as a circular list. | |
TAO_Profile * | get_next (void) |
Get next profile in list, return 0 at end of list. | |
TAO_Profile * | get_cprev (void) |
Assume a circular list of profiles. | |
TAO_Profile * | get_prev (void) |
Get previous profile, stop at beginning of list and return 0. | |
TAO_Profile * | get_current_profile (void) |
TAO_Profile * | get_profile (TAO_PHandle handle) |
Return a pointer to the profile referenced by handle void. | |
TAO_PHandle | get_current_handle (void) |
Returns the index for the current profile. | |
TAO_PHandle | get_current_handle (void) const |
Returns the index for the current profile. | |
CORBA::ULong | profile_count (void) const |
Returns the number of profiles stored in the list (last_+1). | |
CORBA::ULong | size (void) const |
const TAO_Profile * | get_profile (CORBA::ULong slot) const |
void | rewind (void) |
Sets the current slot back to 0. | |
int | add_profile (TAO_Profile *pfile) |
int | give_profile (TAO_Profile *pfile, int share=0) |
int | add_profiles (TAO_MProfile *pfiles) |
int | remove_profile (const TAO_Profile *pfile) |
remove from this MProfile any profiles which also appear in pfiles. | |
int | remove_profiles (const TAO_MProfile *pfiles) |
remove from this MProfile any profiles which also appear in pfiles. | |
void | forward_from (TAO_MProfile *mprofiles) |
TAO_MProfile * | forward_from (void) |
Returns a pointer to the profile which was forwarded. | |
CORBA::Boolean | is_equivalent (const TAO_MProfile *rhs) |
CORBA::ULong | hash (CORBA::ULong max) |
void | policy_list (CORBA::PolicyList *policy_list) |
CORBA::PolicyList * | policy_list () |
Protected Member Functions | |
void | create_policy_list () |
void | init_policy_list () |
Initialize the policy list, demarsharling the policy. | |
TAO_Profile ** | pfiles (void) const |
Protected Attributes | |
CORBA::PolicyList * | policy_list_ |
CORBA::Boolean | is_policy_list_initialized_ |
TAO_SYNCH_RECURSIVE_MUTEX | mutex_ |
Private Member Functions | |
void | cleanup (void) |
Helper method to implement the destructor. | |
int | give_shared_profile (TAO_Profile *pfile) |
Private Attributes | |
TAO_MProfile * | forward_from_ |
TAO_Profile ** | pfiles_ |
Actual list of profiles. | |
TAO_PHandle | current_ |
Points to the next profile to be used. 0 ... size_. | |
TAO_PHandle | size_ |
Max size of array. | |
TAO_PHandle | last_ |
Index plus 1 of last valid entry! May be < size_. | |
Friends | |
class | TAO_Profile |
Stores the policy list for the profile of this MProfile. |
Multiple profiles can be treated either as a circular queue or a linear array of profiles. It is assumed that locking will only be required when a profile list is associated with a TAO_Stub. Thus when the TAO_Stub accepts ownership of an MProfile it also assumes responsibility for controling access (i.e. locking).
Definition at line 58 of file MProfile.h.
|
Definition at line 9 of file MProfile.i. References set().
00010 : policy_list_ (0), 00011 is_policy_list_initialized_ (0), 00012 forward_from_(0), 00013 pfiles_ (0), 00014 current_ (0), 00015 size_ (0), 00016 last_ (0) 00017 { 00018 this->set (sz); 00019 } |
|
**NOTE: IF mprofiles->last_ > 0, THEN this->size_ will be set to mprofiles->last_. Otherwise this->size_ - mprofiles->size_. Furthermore, current_ is set back to 0! i.e. rewound. The reference count on any profiles in mprofiles is increment when their references (i.e. pointers) are copied. Definition at line 22 of file MProfile.i. References set().
00023 : policy_list_ (0), 00024 is_policy_list_initialized_ (0), 00025 forward_from_(0), 00026 pfiles_ (0), 00027 current_ (0), 00028 size_ (0), 00029 last_ (0) 00030 { 00031 this->set (mprofiles); 00032 } |
|
Destructor: decrements reference count on all references profiles! Definition at line 24 of file MProfile.cpp. References ACE_CATCHANY, ACE_DECLARE_NEW_CORBA_ENV, ACE_ENDTRY, ACE_ENV_SINGLE_ARG_PARAMETER, ACE_TRY, ACE_TRY_CHECK, cleanup(), CORBA::Policy::destroy(), TAO::unbounded_object_reference_sequence< Policy, Policy_var >::length(), policy_list_, and CORBA::Policy_ptr.
00025 { 00026 if (this->policy_list_ != 0) 00027 { 00028 ACE_DECLARE_NEW_CORBA_ENV; 00029 const CORBA::ULong len = this->policy_list_->length (); 00030 for (CORBA::ULong i = 0; i < len; ++i) 00031 { 00032 ACE_TRY 00033 { 00034 CORBA::Policy_ptr policy = (*this->policy_list_)[i]; 00035 policy->destroy (ACE_ENV_SINGLE_ARG_PARAMETER); 00036 ACE_TRY_CHECK; 00037 } 00038 ACE_CATCHANY 00039 { 00040 // Ignore all exceptions to allow other policies to be 00041 // destroyed. 00042 } 00043 ACE_ENDTRY; 00044 } 00045 00046 delete this->policy_list_; 00047 } 00048 00049 this->cleanup (); 00050 } |
|
Return the index of this entry or -1 if it can not be added. reference count on profile in incremented! Definition at line 182 of file MProfile.cpp. References ACE_ERROR_RETURN, ACE_TEXT, grow(), last_, LM_ERROR, and pfiles_. Referenced by add_profiles().
00183 { 00184 // skip by the used slots 00185 if (last_ == size_) // full! 00186 { 00187 if (this->grow (this->size_ + 1) < 0) 00188 return -1; 00189 } 00190 00191 pfiles_[last_++] = pfile; 00192 00193 if (pfile && pfile->_incr_refcnt () == 0) 00194 ACE_ERROR_RETURN ((LM_ERROR, 00195 ACE_TEXT ("(%P|%t) Unable to increment reference ") 00196 ACE_TEXT ("count in add_profile!\n")), 00197 -1); 00198 00199 return last_ - 1; 00200 } |
|
append the profiles in pfiles to this object. The count will be incremented on the individual profile objects. Definition at line 203 of file MProfile.cpp. References add_profile(), grow(), last_, pfiles_, and TAO_PHandle.
00204 { 00205 // this->size_ == total number of profiles we can hold 00206 // this->last_ == the index of the last profile 00207 CORBA::ULong space = this->size_ - this->last_; 00208 00209 if (space < pfiles->last_) 00210 { 00211 // we need to grow! 00212 if (this->grow (this->last_ + pfiles->last_) < 0) 00213 return -1; 00214 } 00215 00216 // copy over profiles 00217 for (TAO_PHandle h = 0; h < pfiles->last_; ++h) 00218 { 00219 if (this->add_profile (pfiles->pfiles_[h]) < 0) 00220 return -1; 00221 } 00222 return 0; 00223 } |
|
Helper method to implement the destructor.
Definition at line 53 of file MProfile.cpp. References TAO_Profile::_decr_refcnt(), last_, pfiles_, and TAO_PHandle. Referenced by set(), and ~TAO_MProfile().
00054 { 00055 if (this->pfiles_ != 0) 00056 { 00057 for (TAO_PHandle i = 0; i < this->last_; ++i) 00058 if (this->pfiles_[i]) 00059 this->pfiles_[i]->_decr_refcnt (); 00060 delete [] this->pfiles_; 00061 this->pfiles_ = 0; 00062 } 00063 00064 this->current_ = 0; 00065 this->size_ = 0; 00066 this->last_ = 0; 00067 } |
|
This method handle the dynamic allocation of the data member . Definition at line 315 of file MProfile.cpp. References ACE_NEW_THROW_EX. Referenced by policy_list().
00316 { 00317 ACE_NEW_THROW_EX (this->policy_list_, 00318 CORBA::PolicyList, 00319 CORBA::NO_MEMORY (0, 00320 CORBA::COMPLETED_NO) 00321 ); 00322 } |
|
Returns a pointer to the profile which was forwarded.
Definition at line 167 of file MProfile.i. References forward_from_.
00168 { 00169 return this->forward_from_; 00170 } |
|
Set a pointer to the MProfile whose 'current' TAO_Profile was forwarded This object is the set of forwarding profiles. Definition at line 160 of file MProfile.i. References forward_from_. Referenced by TAO_Stub::forward_back_one().
00161 { 00162 this->forward_from_ = from; 00163 } |
|
Treat as a circular list.
Definition at line 47 of file MProfile.i. References last_, and pfiles_.
|
|
Assume a circular list of profiles.
Definition at line 72 of file MProfile.i. References last_, and pfiles_.
|
|
Returns the index for the current profile.
Definition at line 131 of file MProfile.i.
|
|
Returns the index for the current profile.
Definition at line 122 of file MProfile.i.
|
|
Return a pointer to the current profile, will not increment reference pointer. Definition at line 110 of file MProfile.i. References last_, and pfiles_. Referenced by TAO_Stub::forward_back_one(), and init_policy_list().
|
|
Get next profile in list, return 0 at end of list.
Definition at line 62 of file MProfile.i. References last_, and pfiles_. Referenced by TAO_Stub::next_forward_profile(), TAO_Stub::next_profile_i(), and TAO_Stub::reset_base().
|
|
Get previous profile, stop at beginning of list and return 0.
Definition at line 87 of file MProfile.i. References last_, and pfiles_.
|
|
Return the profile at position . If is out of range it returns 0. Definition at line 185 of file MProfile.i. References last_, and pfiles_.
|
|
Return a pointer to the profile referenced by handle void.
Definition at line 101 of file MProfile.i. References last_, pfiles_, and TAO_PHandle. Referenced by TAO_Stub::create_ior_info(), TAO_IIOP_Acceptor::create_shared_profile(), TAO_ORB_Core::create_stub_object(), TAO_Stub::get_profile_ior_info(), TAO_Acceptor_Registry::is_collocated(), TAO_Stub::marshal(), TAO_Stub::object_key(), and CORBA::ORB::object_to_string().
|
|
Return the index of this entry or -1 if it can not be added. this object assumes ownership of this profile!! Definition at line 145 of file MProfile.i. References give_shared_profile(), last_, and pfiles_. Referenced by TAO_IIOP_Acceptor::create_new_profile(), TAO_IIOP_Acceptor::create_shared_profile(), give_shared_profile(), operator>>(), TAO_CORBALOC_Parser::parse_string(), and CORBA::Object::tao_object_initialize().
|
|
A helper to give_profile to be used when share is true. This method is used primarily to help the corbaloc parser create a single profile with multiple endpoints rather than constructing multiple profiles with 1 endpoint per. Definition at line 368 of file MProfile.cpp. References TAO_Profile::_decr_refcnt(), TAO_Profile::add_generic_endpoint(), TAO_Profile::compare_key(), TAO_Profile::endpoint(), give_profile(), last_, pfiles_, and TAO_Profile::tag(). Referenced by give_profile().
00369 { 00370 for (unsigned i = 0; i < this->last_; i++) 00371 if (pfile->tag() == this->pfiles_[i]->tag() && 00372 pfile->compare_key(this->pfiles_[i])) 00373 { 00374 this->pfiles_[i]->add_generic_endpoint(pfile->endpoint()); 00375 pfile->_decr_refcnt(); 00376 return i; 00377 } 00378 return this->give_profile(pfile,0); 00379 } |
|
increase the number of profiles this object can hold. NOT THREAD SAFE Definition at line 153 of file MProfile.cpp. References ACE_NEW_RETURN, pfiles_, and TAO_PHandle. Referenced by add_profile(), add_profiles(), and TAO_IIOP_Acceptor::create_new_profile().
00154 { 00155 if (sz <= this->size_) 00156 return 0; 00157 00158 // get the additional space 00159 TAO_Profile **new_pfiles = 0; 00160 TAO_Profile **old_pfiles = 0; 00161 ACE_NEW_RETURN (new_pfiles, 00162 TAO_Profile *[sz], 00163 -1); 00164 00165 old_pfiles = this->pfiles_; 00166 00167 // got it, now copy profiles 00168 for (TAO_PHandle h = 0; h < this->size_; ++h) 00169 { 00170 new_pfiles[h] = old_pfiles[h]; 00171 old_pfiles[h] = 0; 00172 } 00173 00174 this->pfiles_ = new_pfiles; 00175 this->size_ = sz; 00176 delete [] old_pfiles; 00177 00178 return 0; 00179 } |
|
use all registered profiles. The hash() method is called on each profile and the results are averaged together. NON-THREAD SAFE. Definition at line 292 of file MProfile.cpp. References ACE_CHECK_RETURN, ACE_ENV_ARG_PARAMETER, TAO_Profile::hash(), last_, pfiles_, and TAO_PHandle. Referenced by TAO_Stub::hash().
00294 { 00295 CORBA::ULong hashval = 0; 00296 00297 if (this->last_ == 0) 00298 return 0; 00299 00300 for (TAO_PHandle h = 0; h < this->last_ ; ++h) 00301 { 00302 hashval += pfiles_[h]->hash (max 00303 ACE_ENV_ARG_PARAMETER); 00304 ACE_CHECK_RETURN (0); 00305 } 00306 00307 // The above hash function return an ULong between 0 and max here we 00308 // simply take the average value and round. 00309 //return hashval / this->last_; 00310 // Changed to a mod value instead of an average. 00311 return hashval % max; 00312 } |
|
Initialize the policy list, demarsharling the policy.
Definition at line 325 of file MProfile.cpp. References ACE_CHECK, ACE_ENV_ARG_PARAMETER, get_current_profile(), TAO_Profile::get_policies(), and is_policy_list_initialized_. Referenced by policy_list().
00326 { 00327 // The first time this method is called 00328 // it causes the initialization of the policies 00329 // for the current profile. 00330 00331 this->get_current_profile ()->get_policies (*this->policy_list_ 00332 ACE_ENV_ARG_PARAMETER); 00333 ACE_CHECK; 00334 00335 this->is_policy_list_initialized_ = 1; 00336 } |
|
Returns true of there is at least one profile in first which is_equivalent with at least one profile in second. NON-THREAD SAFE, relies on some other entity to guarentee the profiles will not change during the call. Definition at line 278 of file MProfile.cpp. References TAO_Profile::is_equivalent(), last_, pfiles_, and TAO_PHandle.
00279 { 00280 // Two profile lists are equivalent iff at least one of the profiles 00281 // from the first list is_equivalent to at least one of the profiles 00282 // from the second list!! 00283 for (TAO_PHandle h1 = 0; h1 < this->last_; ++h1) 00284 for (TAO_PHandle h2 = 0; h2 < rhs->last_; ++h2) 00285 if (this->pfiles_[h1]->is_equivalent (rhs->pfiles_[h2])) 00286 return 1; 00287 00288 return 0; 00289 } |
|
Assigment operator.
Definition at line 35 of file MProfile.i. References set().
00036 { 00037 if (this == &rhs) 00038 return *this; 00039 00040 this->set (rhs); 00041 return *this; 00042 } |
|
Return the complete list of profiles, this object retains ownership! Definition at line 193 of file MProfile.i. References pfiles_.
00194 { 00195 return this->pfiles_; 00196 } |
|
Gets the policies list associated with the profiles owned by the TAO_MProfile. Definition at line 339 of file MProfile.cpp. References ACE_CHECK_RETURN, ACE_ENV_SINGLE_ARG_PARAMETER, ACE_GUARD_RETURN, ACE_NEW_THROW_EX, create_policy_list(), init_policy_list(), is_policy_list_initialized_, policy_list_, and TAO_SYNCH_RECURSIVE_MUTEX.
00340 { 00341 if (!this->is_policy_list_initialized_) 00342 { 00343 ACE_GUARD_RETURN (TAO_SYNCH_RECURSIVE_MUTEX, 00344 guard, 00345 this->mutex_, 00346 0); 00347 00348 if (this->policy_list_ == 0) 00349 { 00350 this->create_policy_list (ACE_ENV_SINGLE_ARG_PARAMETER); 00351 ACE_CHECK_RETURN (0); 00352 00353 this->init_policy_list (ACE_ENV_SINGLE_ARG_PARAMETER); 00354 ACE_CHECK_RETURN (0); 00355 } 00356 } 00357 CORBA::PolicyList *ret_val = 0; 00358 ACE_NEW_THROW_EX (ret_val, 00359 CORBA::PolicyList (*this->policy_list_), 00360 CORBA::NO_MEMORY (0, 00361 CORBA::COMPLETED_NO)); 00362 ACE_CHECK_RETURN (0); 00363 00364 return ret_val; 00365 } |
|
Sets the policies list associated with the profiles owned by the TAO_MProfile. Definition at line 199 of file MProfile.i. References policy_list_. Referenced by TAO_ORB_Core::create_stub_object().
00200 { 00201 this->policy_list_ = policy_list; 00202 } |
|
Returns the number of profiles stored in the list (last_+1).
Definition at line 173 of file MProfile.i. References last_. Referenced by TAO_Stub::create_ior_info(), TAO_IIOP_Acceptor::create_new_profile(), TAO_IIOP_Acceptor::create_shared_profile(), TAO_ORB_Core::create_stub_object(), TAO_Stub::get_profile_ior_info(), TAO_Acceptor_Registry::is_collocated(), TAO_Stub::marshal(), CORBA::ORB::object_to_string(), operator>>(), and CORBA::Object::tao_object_initialize().
00174 { 00175 return this->last_; 00176 } |
|
remove from this MProfile any profiles which also appear in pfiles.
Definition at line 238 of file MProfile.cpp. References TAO_Profile::_decr_refcnt(), TAO_Profile::is_equivalent(), last_, pfiles_, and TAO_PHandle. Referenced by remove_profiles().
00239 { 00240 TAO_PHandle h; 00241 int found = 0; 00242 for (h = 0; h < this->last_; ++h) 00243 { 00244 if (this->pfiles_[h]->is_equivalent (pfile)) 00245 { // remove it! 00246 TAO_Profile *old = this->pfiles_[h]; 00247 this->pfiles_[h] = 0; 00248 old->_decr_refcnt (); 00249 // shift other profiles up one 00250 // note, if h == last_ - 1 then do nothing. 00251 for (TAO_PHandle inner = h; inner < this->last_ - 1; ++inner) 00252 { 00253 this->pfiles_[inner] = this->pfiles_[inner + 1]; 00254 } 00255 // subtract 1 from last_ to indicate we have one fewer profiles 00256 this->last_--; 00257 found = 1; 00258 break; 00259 } 00260 } 00261 if ( found == 0) 00262 return -1; // profile not found. 00263 return 0; 00264 } |
|
remove from this MProfile any profiles which also appear in pfiles.
Definition at line 267 of file MProfile.cpp. References last_, pfiles_, remove_profile(), and TAO_PHandle.
00268 { 00269 for (TAO_PHandle h = 0; h < pfiles->last_; ++h) 00270 { 00271 if (this->remove_profile (pfiles->pfiles_[h]) < 0) 00272 return -1; 00273 } 00274 return 0; 00275 } |
|
Sets the current slot back to 0.
Definition at line 140 of file MProfile.i. Referenced by TAO_Stub::next_profile_i(), and TAO_Stub::reset_base().
00141 { 00142 current_ = 0; 00143 } |
|
Inits this to the values of mprofile. NOTE: We use mprofile->last_ instead of mprofile->size_ to set this->size_. This is so we can use set () to trim a profile list!! NOT THREAD SAFE Definition at line 125 of file MProfile.cpp. References TAO_Profile::_incr_refcnt(), last_, pfiles_, set(), and TAO_PHandle.
00126 { 00127 // NOTE: We use mprofile->last_ instead of mprofile->size_ to set 00128 // this->size_. This is so we can use set () to trim a profile 00129 // list!! 00130 00131 this->set (mprofile.last_); 00132 00133 // set indexes ... 00134 this->last_ = mprofile.last_; 00135 00136 // These are set in set (ULong); 00137 // this->current_ = 0; 00138 // this->forward_from_ = 0; 00139 00140 // Now reference all profiles. 00141 for (TAO_PHandle h = 0; h < this->last_; ++h) 00142 { 00143 this->pfiles_[h] = mprofile.pfiles_[h]; 00144 if (this->pfiles_[h] != 0) 00145 this->pfiles_[h]->_incr_refcnt (); 00146 } 00147 00148 return 1; 00149 } |
|
Inits MProfile to hold sz TAO_Profiles. NOT THREAD SAFE Definition at line 70 of file MProfile.cpp. References TAO_Profile::_decr_refcnt(), ACE_NEW_RETURN, cleanup(), last_, pfiles_, and TAO_PHandle. Referenced by TAO_Stub::base_profiles(), operator=(), set(), and TAO_MProfile().
00071 { 00072 if (sz == 0) 00073 { 00074 this->cleanup (); 00075 return 0; 00076 } 00077 00078 // See if we already have an existing profile list or if we need to 00079 // get ridof what we have. 00080 if (this->size_ != 0) 00081 { 00082 // Release all of our profiles. 00083 00084 for (TAO_PHandle h = 0; 00085 h < this->size_; 00086 ++h) 00087 if (this->pfiles_[h]) 00088 { 00089 this->pfiles_[h]->_decr_refcnt (); 00090 this->pfiles_[h] = 0; 00091 } 00092 00093 // Next see if we can reuse our profile list memory 00094 if (this->size_ < sz) 00095 { 00096 // we cant reuse memory since the current array is too small! 00097 delete [] this->pfiles_; 00098 00099 ACE_NEW_RETURN (this->pfiles_, 00100 TAO_Profile *[sz], 00101 -1); 00102 this->size_ = sz; 00103 } 00104 // else , leave this->size and this->pfiles alone! 00105 } 00106 else 00107 { 00108 // first time, initialize! 00109 ACE_NEW_RETURN (this->pfiles_, 00110 TAO_Profile *[sz], 00111 -1); 00112 this->size_ = sz; 00113 } 00114 00115 this->last_ = 0; 00116 this->current_ = 0; 00117 00118 for (TAO_PHandle i = 0; i != this->size_; ++i) 00119 this->pfiles_[i] = 0; 00120 00121 return this->size_; 00122 } |
|
return the maximum number of profiles that can be stored in this container, (size_+1) Definition at line 179 of file MProfile.i. Referenced by TAO_IIOP_Acceptor::create_new_profile().
00180 { 00181 return this->size_; 00182 } |
|
Stores the policy list for the profile of this MProfile.
Definition at line 201 of file MProfile.h. |
|
Points to the next profile to be used. 0 ... size_.
Definition at line 242 of file MProfile.h. |
|
Used for chaning references when the current profile is forwarded. Note, this will only be valid for an MProfile which contains a list of forward_profiles for some initial or base profile. This is a backward reference to the profile list which received the relocate message. The actual profile what was forwarded will be forward_from_->get_current_profile () Definition at line 236 of file MProfile.h. Referenced by forward_from(). |
|
Definition at line 204 of file MProfile.h. Referenced by init_policy_list(), and policy_list(). |
|
Index plus 1 of last valid entry! May be < size_.
Definition at line 248 of file MProfile.h. Referenced by add_profile(), add_profiles(), cleanup(), get_cnext(), get_cprev(), get_current_profile(), get_next(), get_prev(), get_profile(), give_profile(), give_shared_profile(), hash(), is_equivalent(), profile_count(), remove_profile(), remove_profiles(), and set(). |
|
Mutex used to make sure that only one policy list is created. Definition at line 208 of file MProfile.h. |
|
Actual list of profiles.
Definition at line 239 of file MProfile.h. Referenced by add_profile(), add_profiles(), cleanup(), get_cnext(), get_cprev(), get_current_profile(), get_next(), get_prev(), get_profile(), give_profile(), give_shared_profile(), grow(), hash(), is_equivalent(), pfiles(), remove_profile(), remove_profiles(), and set(). |
|
Definition at line 202 of file MProfile.h. Referenced by policy_list(), and ~TAO_MProfile(). |
|
Max size of array.
Definition at line 245 of file MProfile.h. |