summaryrefslogtreecommitdiff
path: root/TAO
diff options
context:
space:
mode:
authorschmidt <douglascraigschmidt@users.noreply.github.com>1999-02-05 16:22:14 +0000
committerschmidt <douglascraigschmidt@users.noreply.github.com>1999-02-05 16:22:14 +0000
commitd0c0f5936b61a04f1798fb3b22c10192e5bc5a71 (patch)
tree7c04e540baa6805094e633c2c3aa9b641fdaede4 /TAO
parent28ba79481b99278e36d75d44a82745c953cda8a3 (diff)
downloadATCD-d0c0f5936b61a04f1798fb3b22c10192e5bc5a71.tar.gz
.
Diffstat (limited to 'TAO')
-rw-r--r--TAO/tao/MProfile.cpp166
-rw-r--r--TAO/tao/MProfile.h75
2 files changed, 125 insertions, 116 deletions
diff --git a/TAO/tao/MProfile.cpp b/TAO/tao/MProfile.cpp
index 1658014787e..b2cf9cf398e 100644
--- a/TAO/tao/MProfile.cpp
+++ b/TAO/tao/MProfile.cpp
@@ -1,18 +1,6 @@
// This may look like C, but it's really -*- C++ -*-
// $Id$
-// ============================================================================
-//
-// = LIBRARY
-//
-// = FILENAME
-//
-// = DESCRIPTION
-//
-// = AUTHOR
-//
-// ============================================================================
-#include <tao/corba.h>
TAO_MProfile::TAO_MProfile (CORBA::ULong sz)
: fwded_mprofile_(0),
@@ -21,9 +9,7 @@ TAO_MProfile::TAO_MProfile (CORBA::ULong sz)
size_ (sz),
last_ (0)
{
-
this->set (sz);
-
}
TAO_MProfile::TAO_MProfile (TAO_MProfile *mprofiles)
@@ -33,9 +19,7 @@ TAO_MProfile::TAO_MProfile (TAO_MProfile *mprofiles)
size_ (0),
last_ (0)
{
-
this->set (mprofiles);
-
}
int
@@ -44,37 +28,46 @@ TAO_MProfile::set (CORBA::ULong sz)
// first release all of our profiles.
if (this->pfiles_)
{
+ // @@ Fred, please don't put spaces in front of the ';' here.
for (PHandle h = 0 ; h < this->size_ ; h++ )
- {
- if (this->pfiles_[h]) {
- this->pfiles_[h]->_decr_refcnt ();
- this->pfiles_[h] = 0;
+ {
+ if (this->pfiles_[h])
+ {
+ this->pfiles_[h]->_decr_refcnt ();
+ this->pfiles_[h] = 0;
+ }
}
- }
- // next see if we can reuse our profile list memory
- // Since this->pfiles_ != 0, size_ > 0! So if
- // sz == 0 then memory is deallocated.
+ // Next see if we can reuse our profile list memory Since
+ // this->pfiles_ != 0, size_ > 0! So if sz == 0 then memory is
+ // deallocated.
if (this->size_ != sz)
- {
- // we cant!
- delete [] this->pfiles_;
-
- if (this->size_ == sz)
{
- this->pfiles_ = new TAO_Profile_ptr [this->size_];
- ACE_OS::memset (this->pfiles_,0, sizeof(TAO_Profile_ptr)*this->size_);
+ // we cant!
+ delete [] this->pfiles_;
+
+ if (this->size_ == sz)
+ {
+ // @@ Fred, please always use ACE_NEW_RETURN() or ACE_NEW()
+ // when you allocate memory.
+ this->pfiles_ = new TAO_Profile_ptr [this->size_];
+ ACE_OS::memset (this->pfiles_,
+ 0,
+ sizeof (TAO_Profile_ptr) *this->size_);
+ }
+ else // do not allocate any memory!
+ this->pfiles_ = 0;
}
- else // do not allocate any memory!
- this->pfiles_ = 0;
- }
}
else
{
if (this->size_ == sz)
{
+ // @@ Fred, same here.
pfiles_ = new TAO_Profile_ptr [this->size_];
- ACE_OS::memset (this->pfiles_,0, sizeof(TAO_Profile_ptr)*this->size_);
+ ACE_OS::memset (this->pfiles_,
+ 0,
+ sizeof (TAO_Profile_ptr) *this->size_);
}
else
pfiles_ = 0;
@@ -90,23 +83,23 @@ TAO_MProfile::set (CORBA::ULong sz)
int
TAO_MProfile::set (TAO_MProfile *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!!
+ // 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!!
if (! mprofile)
- return this->set ((CORBA::ULong)0);
+ return this->set ((CORBA::ULong) 0);
this->set (mprofile->last_);
- // set indexes ...
+ // set indexes ...
this->last_ = mprofile->last_;
- // these ate set in set (ULong);
+ // these are set in set (ULong);
// this->current_ = 0;
// this->fwded_mprofile_ = 0;
- // now reference all profiles.
+ // Now reference all profiles.
for (PHandle h = 0 ; h < this->size_ ; h++ )
{
if (mprofile->pfiles_[h])
@@ -125,15 +118,13 @@ TAO_MProfile::set (TAO_MProfile *mprofile)
}
TAO_MProfile::~TAO_MProfile (void)
-{
+ {
if (this->pfiles_)
- {
- for ( PHandle h = 0 ; h < size_ ; h++ )
- {
- if (this->pfiles_[h])
- this->pfiles_[h]->_decr_refcnt ();
- }
- }
+ // @@ Fred, please make sure you use consistent style in your for
+ // loop (i.e., remove certain spaces...).
+ for ( PHandle h = 0 ; h < size_ ; h++ )
+ if (this->pfiles_[h])
+ this->pfiles_[h]->_decr_refcnt ();
delete [] pfiles_;
pfiles_ = 0;
@@ -141,43 +132,53 @@ TAO_MProfile::~TAO_MProfile (void)
}
// cyclic get next. It will simply cycle through the complete list.
+
TAO_Profile *
TAO_MProfile::get_cnext (void)
{
- return (last_ == 0) ? 0 : ((current_ < last_) ? pfiles_ [current_++] :
- pfiles_ [(current_=1,0)]);
+ // @@ Fred, this express is too complicated. Please rewrite it use
+ // if/else.
+ return last_ == 0 ? 0 : ((current_ < last_) ? pfiles_ [current_++] :
+ pfiles_ [(current_ = 1, 0)]);
}
-// this will return the next element until either null is found or the
+// This will return the next element until either null is found or the
// end of list. It then continues to return NULL until rewind.
+
TAO_Profile *
TAO_MProfile::get_next (void)
{
- return (last_ == 0) ? 0 : ((current_ == last_) ? 0 : pfiles_ [current_++]);
+ // @@ Fred, same comment here.
+ return last_ == 0 ? 0 : ((current_ == last_) ? 0 : pfiles_ [current_++]);
}
TAO_Profile *
TAO_MProfile::get_cprev (void)
{
- return (last_ == 0) ? 0 :
- ((last_ == 1) ? pfiles_ [current_=0] :
- ((current_ > 1) ? pfiles_ [(--current_ - 1)] :
- pfiles_ [(current_=last_, last_-1)]));
+ // @@ Fred, same comment here...
+ return last_ == 0 ? 0 :
+ (last_ == 1 ? pfiles_ [current_=0] :
+ (current_ > 1 ? pfiles_ [(--current_ - 1)] :
+ // @@ Fred, please don't use assignment within
+ // expressions.
+ pfiles_ [(current_ = last_, last_ - 1)]));
}
TAO_Profile *
TAO_MProfile::get_prev (void)
{
- return (last_ == 0) ? 0 :
- ((current_ > 1) ? pfiles_ [--current_ - 1] :
- (TAO_Profile *)(current_=0,0));
+ // @@ Same comment here.
+ return last_ == 0 ? 0 :
+ (current_ > 1 ? pfiles_ [--current_ - 1] :
+ (TAO_Profile *)(current_ = 0, 0));
}
// does not affect the current_ setting!
TAO_Profile *
TAO_MProfile::get_profile (PHandle handle)
{
- return (handle >= 0 && handle < last_) ? pfiles_ [handle] : 0;
+ // @@ Same comment here.
+ return handle >= 0 && handle < last_ ? pfiles_ [handle] : 0;
}
TAO_Profile *
@@ -185,13 +186,16 @@ TAO_MProfile::get_current_profile (void)
{
if (last_ == 0)
return 0;
- return (current_ == 0) ? pfiles_ [current_] : pfiles_ [current_-1];
+ else
+ // @@ Fred, same comment here.
+ return current_ == 0 ? pfiles_ [current_] : pfiles_ [current_-1];
}
PHandle
TAO_MProfile::get_current_handle (void)
{
- return (current_ > 0) ? (current_ - 1) : 0;
+ // @@ Fred, same comment here.
+ return current_ > 0 ? (current_ - 1) : 0;
// the last profile returned!
}
@@ -211,12 +215,9 @@ TAO_MProfile::add_profile (TAO_Profile *pfile)
pfiles_ [last_++] = pfile;
if (pfile && pfile->_incr_refcnt () == 0)
- {
- ACE_ERROR_RETURN ((LM_ERROR,
- "(%P|%t) Unable to increment reference count in add_profile!\n"),
- -1);
- }
-
+ ACE_ERROR_RETURN ((LM_ERROR,
+ "(%P|%t) Unable to increment reference count in add_profile!\n"),
+ -1);
return last_ - 1;
}
@@ -258,13 +259,9 @@ TAO_MProfile::is_equivalent (TAO_MProfile *first,
int second_cnt = second->profile_count ();
for (PHandle h1 = 0; h1 < first_cnt;h1++)
- {
- for (PHandle h2 = 0; h2 < second_cnt; h2++ )
- {
- if (pfiles1[h1]->is_equivalent (pfiles2[h2], env))
- return 1;
- }
- }
+ for (PHandle h2 = 0; h2 < second_cnt; h2++ )
+ if (pfiles1[h1]->is_equivalent (pfiles2[h2], env))
+ return 1;
return 0;
}
@@ -272,18 +269,15 @@ TAO_MProfile::is_equivalent (TAO_MProfile *first,
CORBA::ULong
TAO_MProfile::hash (CORBA::ULong max, CORBA::Environment &env)
{
+ CORBA::ULong hashval = 0;
- CORBA::ULong hashval=0;
-
- if (last_ == 0) return 0;
+ if (last_ == 0)
+ return 0;
for (PHandle h=0; h < last_ ; h++)
- {
- hashval += pfiles_[h]->hash (max, env);
- }
+ hashval += pfiles_[h]->hash (max, env);
- // the above hash function return an ULong between 0 and max
- // here we simply take the average value and round
+ // The above hash function return an ULong between 0 and max here we
+ // simply take the average value and round
return hashval / last_;
-
}
diff --git a/TAO/tao/MProfile.h b/TAO/tao/MProfile.h
index baf71860fce..251c649125c 100644
--- a/TAO/tao/MProfile.h
+++ b/TAO/tao/MProfile.h
@@ -13,7 +13,7 @@
// Keep track of profile lists
//
// = AUTHOR
-// Fred Kuhns
+// Fred Kuhns <fredk@cs.wustl.edu>
//
// ============================================================================
@@ -21,92 +21,107 @@
#define TAO_MPROFILE_H
typedef TAO_Profile * TAO_Profile_ptr;
+// @@ Fred, please don't create global typedefs that aren't prefixed
+// by TAO_.
typedef CORBA::ULong PHandle;
class TAO_MProfile
{
+ // @@ Fred, please use the = TITLE and = DESCRIPTION format here...
// this class implements the basic interface for supporting multiple
// profiles. This can be treated either as a circular queue or a
// linear array of profiles.
// @@ FRED: For now this list is not locked, BUT it needs to be!
public:
+ // = Initalization and termination methods.
+ // @@ Fred, please make sure to capitalize the first letter of each
+ // sentence in your comments.
TAO_MProfile (CORBA::ULong sz);
// ctor.
+
TAO_MProfile (TAO_MProfile *mprofiles);
// **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.
+ // The reference count on any profiles in mprofiles is increment
+ // when their references (i.e. pointers) are copied.
int set (CORBA::ULong sz);
int set (TAO_MProfile *mprofile);
- // 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!!
+ // 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!!
TAO_Profile_ptr get_cnext (void);
- // treat as a circular list.
+ // Treat as a circular list.
+
TAO_Profile_ptr get_next (void);
- // get next profile in list, return 0 at end of list.
+ // Get next profile in list, return 0 at end of list.
TAO_Profile_ptr get_cprev (void);
- // assume a circular list of profiles.
+ // Assume a circular list of profiles.
+
TAO_Profile_ptr get_prev (void);
- // get previous profile, stop at beginning of list and return 0
+ // Get previous profile, stop at beginning of list and return 0
TAO_Profile_ptr get_current_profile (void);
+ // @@ Fred, please document.
TAO_Profile_ptr get_profile (PHandle handle);
- // return a pointer to the profile referenced by handle
- // void rem_profile (PHandle handle);
- // let's wait.
+ // Return a pointer to the profile referenced by handle void
+
+ // rem_profile (PHandle handle); let's wait.
PHandle get_current_handle (void);
- // returns the index for the current profile.
+ // Returns the index for the current profile.
CORBA::ULong profile_count (void);
- // returns the number of profiles stored in the list (last_)
+ // Returns the number of profiles stored in the list (last_).
void rewind (void);
- // sets the current index back to 0
+ // Sets the current index back to 0.
int add_profile (TAO_Profile_ptr pfile);
- // return the index of this entry or -1 if it can not be added.
+ // Return the index of this entry or -1 if it can not be added.
// reference count on profile in incremented!
void fwded_mprofile (TAO_MProfile *mprofiles);
+ // Set a pointer to the profile which was forwarded. NOTE, the
+ // forwarding profile *MUST* be set at object creation. And it can
+ // not be altered once it's set!
+
TAO_MProfile *fwded_mprofile (void);
- // returns a pointer to the profile which was forwarded.
- // NOTE, the forwarding profile *MUST* be set at object
- // creation. And it can not be altered once set!
+ // Returns a pointer to the profile which was forwarded.
CORBA::Boolean is_equivalent (TAO_MProfile *first,
TAO_MProfile *second,
CORBA::Environment &env);
- // returns true of there is at least one profile in first
- // which is_equivalent with at least one profile in second.
- // @@ FRED: The lost should be locked for this!
+ // Returns true of there is at least one profile in first which
+ // is_equivalent with at least one profile in second. @@ FRED: The
+ // lost should be locked for this!
CORBA::ULong hash (CORBA::ULong max, CORBA::Environment &env);
- // @@ FRED: The lost should be locked for this!
-
+ // @@ FRED: The list should be locked for this!
~TAO_MProfile (void);
- // deletes this object and decrements reference count on all
+ // Deletes this object and decrements reference count on all
// references profiles!
protected:
TAO_Profile_ptr *pfiles (void) const;
+ // @@ Fred, please add comments.
private:
+ // @@ Fred, please add comments.
TAO_MProfile *fwded_mprofile_;
TAO_Profile_ptr *pfiles_;
- PHandle current_; // 0 ... size_
- PHandle size_; // Max size of array
- PHandle last_; // Index plus 1 of last valid entry!
+ PHandle current_;
+ // 0 ... size_
+ PHandle size_;
+ // Max size of array
+ PHandle last_;
+ // Index plus 1 of last valid entry!
};
#endif // TAO_MPROFILE_H