MProfile.inl

Go to the documentation of this file.
00001 // -*- C++ -*-
00002 //
00003 // $Id: MProfile.inl 81429 2008-04-24 18:49:54Z johnnyw $
00004 
00005 
00006 TAO_BEGIN_VERSIONED_NAMESPACE_DECL
00007 
00008 ACE_INLINE
00009 TAO_MProfile::TAO_MProfile (CORBA::ULong sz)
00010   :  policy_list_ (0),
00011      is_policy_list_initialized_ (false),
00012      forward_from_(0),
00013      pfiles_ (0),
00014      current_ (0),
00015      size_ (0),
00016      last_ (0)
00017 {
00018   this->set (sz);
00019 }
00020 
00021 ACE_INLINE
00022 TAO_MProfile::TAO_MProfile (const TAO_MProfile &mprofiles)
00023   :  policy_list_ (0),
00024      is_policy_list_initialized_ (false),
00025      forward_from_(0),
00026      pfiles_ (0),
00027      current_ (0),
00028      size_ (0),
00029      last_ (0)
00030 {
00031   this->set (mprofiles);
00032 }
00033 
00034 ACE_INLINE TAO_MProfile&
00035 TAO_MProfile::operator= (const TAO_MProfile& rhs)
00036 {
00037   if (this == &rhs)
00038     return *this;
00039 
00040   this->set (rhs);
00041   return *this;
00042 }
00043 
00044 // Cyclic get next.  It will simply cycle through the complete list.
00045 
00046 ACE_INLINE TAO_Profile *
00047 TAO_MProfile::get_cnext (void)
00048 {
00049   if (last_ == 0)
00050     return 0;
00051 
00052   if (current_ == last_)
00053     current_ = 0;
00054 
00055   return pfiles_[current_++];
00056 }
00057 
00058 // This will return the next element until either null is found or the
00059 // end of list.  It then continues to return NULL until rewind.
00060 
00061 ACE_INLINE TAO_Profile *
00062 TAO_MProfile::get_next (void)
00063 {
00064   // Nolist or EndOfList
00065   if (last_ == 0 || current_ == last_)
00066     return 0;
00067   else
00068     return pfiles_[current_++];
00069 }
00070 
00071 ACE_INLINE TAO_Profile *
00072 TAO_MProfile::get_cprev (void)
00073 {
00074   if (last_ == 0)
00075     return 0;
00076   else if (last_ == 1)
00077     current_=1;
00078   else if (current_ > 1)
00079     --current_;
00080   else // current_ == 0 or 1, 0 => list never read before and == 1
00081     current_ = last_;
00082 
00083   return pfiles_[current_ - 1];
00084 }
00085 
00086 ACE_INLINE TAO_Profile *
00087 TAO_MProfile::get_prev (void)
00088 {
00089   if (last_ == 0 || current_ <= 1)
00090     // No List of BeginningOfList
00091     return 0;
00092   if (current_ > 1)
00093     --current_;
00094 
00095   return pfiles_[current_ - 1];
00096 }
00097 
00098 // does not affect the current_ setting!
00099 
00100 ACE_INLINE TAO_Profile *
00101 TAO_MProfile::get_profile (TAO_PHandle handle)
00102 {
00103   if (handle < last_)
00104     return pfiles_[handle];
00105   else
00106     return 0;
00107 }
00108 
00109 ACE_INLINE TAO_Profile *
00110 TAO_MProfile::get_current_profile (void)
00111 {
00112   if (last_ == 0)
00113     return 0;
00114   if (current_ == 0)
00115     // means list has not been read before.
00116     current_ = 1;
00117 
00118   return pfiles_[current_ - 1];
00119 }
00120 
00121 ACE_INLINE TAO_PHandle
00122 TAO_MProfile::get_current_handle (void)
00123 {
00124   if (current_ > 0)
00125     return current_ - 1;
00126   else
00127     return 0;
00128 }
00129 
00130 ACE_INLINE TAO_PHandle
00131 TAO_MProfile::get_current_handle (void) const
00132 {
00133   if (current_ > 0)
00134     return current_ - 1;
00135   else
00136     return 0;
00137 }
00138 
00139 ACE_INLINE void
00140 TAO_MProfile::rewind (void)
00141 {
00142   current_ = 0;
00143 }
00144 
00145 ACE_INLINE int
00146 TAO_MProfile::give_profile (TAO_Profile *pfile, int share)
00147 {
00148   if (share)
00149     return this->give_shared_profile(pfile);
00150   // skip by the used slots
00151   if (last_ == size_) // full!
00152     return -1;
00153 
00154   pfiles_[last_++] = pfile;
00155 
00156   return last_ - 1;
00157 }
00158 
00159 ACE_INLINE
00160 void
00161 TAO_MProfile::forward_from (TAO_MProfile *from)
00162 {
00163   this->forward_from_ = from;
00164 }
00165 
00166 ACE_INLINE
00167 TAO_MProfile *
00168 TAO_MProfile::forward_from (void)
00169 {
00170   return this->forward_from_;
00171 }
00172 
00173 ACE_INLINE CORBA::ULong
00174 TAO_MProfile::profile_count (void) const
00175 {
00176   return this->last_;
00177 }
00178 
00179 ACE_INLINE CORBA::ULong
00180 TAO_MProfile::size (void) const
00181 {
00182   return this->size_;
00183 }
00184 
00185 ACE_INLINE const TAO_Profile*
00186 TAO_MProfile::get_profile (CORBA::ULong slot) const
00187 {
00188   if (slot >= this->last_)
00189     return 0;
00190   return this->pfiles_[slot];
00191 }
00192 
00193 ACE_INLINE TAO_Profile **
00194 TAO_MProfile::pfiles (void) const
00195 {
00196   return this->pfiles_;
00197 }
00198 
00199 ACE_INLINE void
00200 TAO_MProfile::policy_list (CORBA::PolicyList *policy_list)
00201 {
00202   this->policy_list_ = policy_list;
00203 }
00204 
00205 TAO_END_VERSIONED_NAMESPACE_DECL

Generated on Tue Feb 2 17:37:52 2010 for TAO by  doxygen 1.4.7