diff options
author | boris <boris@ae88bc3d-4319-0410-8dbf-d08b4c9d3795> | 2006-09-13 18:37:39 +0000 |
---|---|---|
committer | boris <boris@ae88bc3d-4319-0410-8dbf-d08b4c9d3795> | 2006-09-13 18:37:39 +0000 |
commit | ee36b4f8812e0c18feb2e177bfd164a0b776ecc4 (patch) | |
tree | 04fee0c484f1895120fceaf68631b49ef85397c7 | |
parent | ca91d931d7ecdc32d55eda20d11c51529f5c29b0 (diff) | |
download | ATCD-ee36b4f8812e0c18feb2e177bfd164a0b776ecc4.tar.gz |
ChangeLogTag: Wed Sep 13 18:25:37 UTC 2006 Boris Kolpackov <boris@codesynthesis.com>
-rw-r--r-- | ACE/ace/Bound_Ptr.h | 37 | ||||
-rw-r--r-- | ACE/protocols/ace/RMCast/Reassemble.cpp | 4 |
2 files changed, 40 insertions, 1 deletions
diff --git a/ACE/ace/Bound_Ptr.h b/ACE/ace/Bound_Ptr.h index f5eabd68a56..619e0c4eb87 100644 --- a/ACE/ace/Bound_Ptr.h +++ b/ACE/ace/Bound_Ptr.h @@ -7,6 +7,7 @@ * $Id$ * * @author Christopher Kohlhoff <chris@kohlhoff.com> + * @author Boris Kolpackov <boris@codesynthesis.com> */ //============================================================================= @@ -125,6 +126,19 @@ public: /// Constructor binds <this> and <r> to the same object. ACE_Strong_Bound_Ptr (const ACE_Weak_Bound_Ptr<X, ACE_LOCK> &r); + /// Copy constructor binds <this> and <r> to the same object if + /// Y* can be implicitly converted to X*. + template <class Y> + ACE_Strong_Bound_Ptr (const ACE_Strong_Bound_Ptr<Y, ACE_LOCK> &r) + : counter_ (r.counter_), + ptr_ (dynamic_cast<X*>(r.ptr_)) + { + // This ctor is temporarily defined here to increase our chances + // of being accepted by broken compilers. + // + COUNTER::attach_strong (this->counter_); + } + /// Destructor. ~ACE_Strong_Bound_Ptr (void); @@ -134,6 +148,29 @@ public: /// Assignment operator that binds <this> and <r> to the same object. void operator = (const ACE_Weak_Bound_Ptr<X, ACE_LOCK> &r); + /// Assignment operator that binds <this> and <r> to the same object + /// if Y* can be implicitly converted to X*. + template <class Y> + ACE_Weak_Bound_Ptr<X, ACE_LOCK>& + operator= (const ACE_Strong_Bound_Ptr<Y, ACE_LOCK> &r) + { + // This operator is temporarily defined here to increase our chances + // of being accepted by broken compilers. + // + + // This will work if &r == this, by first increasing the ref count + + COUNTER *new_counter = r.counter_; + X* new_ptr = dynamic_cast<X*> (r.ptr_); + COUNTER::attach_strong (new_counter); + if (COUNTER::detach_strong (this->counter_) == 0) + delete this->ptr_; + this->counter_ = new_counter; + this->ptr_ = new_ptr; + + return *this; + } + /// Equality operator that returns @c true if both /// ACE_Strong_Bound_Ptr instances point to the same underlying /// object. diff --git a/ACE/protocols/ace/RMCast/Reassemble.cpp b/ACE/protocols/ace/RMCast/Reassemble.cpp index aa5354a40be..ee1837d7ac3 100644 --- a/ACE/protocols/ace/RMCast/Reassemble.cpp +++ b/ACE/protocols/ace/RMCast/Reassemble.cpp @@ -100,7 +100,9 @@ namespace ACE_RMCast * hierarchically compatible, and do this funky cast to get * the result we want. */ - new_msg->add (*(reinterpret_cast<Profile_ptr*> (&new_data))); + //new_msg->add (*(reinterpret_cast<Profile_ptr*> (&new_data))); + + new_msg->add (Profile_ptr (new_data)); map_.unbind (from); |