/[escript]/trunk/escript/src/DataAbstract.cpp
ViewVC logotype

Diff of /trunk/escript/src/DataAbstract.cpp

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 2435 by jfenwick, Mon Feb 16 05:08:29 2009 UTC revision 2436 by jfenwick, Mon May 25 05:05:00 2009 UTC
# Line 22  using namespace std; Line 22  using namespace std;
22    
23  namespace escript {  namespace escript {
24    
25    // The boost methods enable_shared_from_this return a shared_ptr managing the object
26    // when all you have is the object. It explicitly fails in the case where
27    // you haven't made a shared_ptr for this object yet.
28    // _Currently_ we need this behaviour, hence the exception squashing.
29    // An execption would be thrown in two circumstances:
30    //    1. The object doesn't have a shared_ptr attached yet.
31    //    2. All shared_ptrs have let go and the object is in the process of being destroyed.
32    // An attempt to getPtr() in the second case is doomed anyway.
33    //
34    // Use of something equivalent to boost_1_39's make_shared used elsewhere might remove
35    // the need for the hack.
36  DataAbstract_ptr DataAbstract::getPtr()  DataAbstract_ptr DataAbstract::getPtr()
37  {  {
38    if (_internal_weak_this.expired())    try
39    {    {
40      return DataAbstract_ptr(this);          return shared_from_this();
41    }    }
42    else    catch (boost::bad_weak_ptr p)    
43    {    {
44      return shared_from_this();        return DataAbstract_ptr(this);
45    }    }
46  }  }
47    
48  const_DataAbstract_ptr DataAbstract::getPtr() const  const_DataAbstract_ptr DataAbstract::getPtr() const
49  {  {
50    if (_internal_weak_this.expired())    try
51    {    {
52      return const_DataAbstract_ptr(this);        return shared_from_this();
53    }    }
54    else    catch (boost::bad_weak_ptr p)    
55    {    {
56      return shared_from_this();        return const_DataAbstract_ptr(this);
57    }    }
58  }  }
59    

Legend:
Removed from v.2435  
changed lines
  Added in v.2436

  ViewVC Help
Powered by ViewVC 1.1.26