bbtk::Object Class Reference

#include <bbtkObject.h>

Inheritance diagram for bbtk::Object:

Inheritance graph
[legend]

List of all members.

Classes

struct  Deleter
 Default objects deleter : removes object from list on deletion. More...

Public Types

typedef boost::shared_ptr< ObjectPointer
typedef boost::weak_ptr< ObjectWeakPointer

Public Member Functions

 Object ()
virtual ~Object ()
virtual std::string GetObjectName () const
virtual std::string GetObjectInfo () const
virtual size_t GetObjectSize () const
virtual size_t GetObjectInternalSize () const
virtual size_t GetObjectRecursiveSize () const
long GetUseCount ()

Static Public Member Functions

static void InsertInObjectList (Pointer)
static void RemoveFromObjectList (WeakPointer)
static void InsertInPackageList (Pointer)
static void ReleasePackages ()
static void PrintObjectListInfo (const std::string &name)
static void PrintObjectInfo (const Pointer &o)
static long GetObjectsCount ()

Protected Member Functions

void LockThis ()
void UnLockThis ()
template<class U >
boost::shared_ptr< U > GetThisPointer () const

Static Protected Member Functions

template<class U >
static boost::shared_ptr< U > MakePointer (U *s, bool lock=false)
template<class U , class D >
static boost::shared_ptr< U > MakePointer (U *s, const D &del, bool lock=false)

Private Types

typedef std::set
< boost::weak_ptr< Object > > 
ObjectListType

Private Attributes

WeakPointer mThisPointer
Pointer mThisPointerLocked

Static Private Attributes

static ObjectListType mgObjectList
static ObjectListType mgPackageList


Detailed Description

Definition at line 49 of file bbtkObject.h.


Member Typedef Documentation

typedef std::set<boost::weak_ptr<Object> > bbtk::Object::ObjectListType [private]

Definition at line 136 of file bbtkObject.h.

typedef boost::shared_ptr<Object> bbtk::Object::Pointer

typedef boost::weak_ptr<Object> bbtk::Object::WeakPointer


Constructor & Destructor Documentation

bbtk::Object::Object (  ) 

Definition at line 46 of file bbtkObject.cxx.

00047   { 
00048   }

bbtk::Object::~Object (  )  [virtual]

Definition at line 53 of file bbtkObject.cxx.

00054   { 
00055   }


Member Function Documentation

std::string bbtk::Object::GetObjectInfo (  )  const [virtual]

virtual size_t bbtk::Object::GetObjectInternalSize (  )  const [inline, virtual]

std::string bbtk::Object::GetObjectName (  )  const [virtual]

virtual size_t bbtk::Object::GetObjectRecursiveSize (  )  const [inline, virtual]

static long bbtk::Object::GetObjectsCount (  )  [inline, static]

Definition at line 75 of file bbtkObject.h.

Referenced by bbtk::StaticInitTime::~StaticInitTime().

00075 { return mgObjectList.size(); }

Here is the caller graph for this function:

virtual size_t bbtk::Object::GetObjectSize (  )  const [inline, virtual]

template<class U >
boost::shared_ptr<U> bbtk::Object::GetThisPointer (  )  const [inline, protected]

Definition at line 92 of file bbtkObject.h.

00093     {
00094       return boost::dynamic_pointer_cast<U>(mThisPointer.lock());
00095     }

long bbtk::Object::GetUseCount (  )  [inline]

Definition at line 63 of file bbtkObject.h.

00063 { return mThisPointer.use_count(); }

void bbtk::Object::InsertInObjectList ( Pointer  p  )  [static]

Definition at line 59 of file bbtkObject.cxx.

References bbtkDebugMessage, and mgObjectList.

Referenced by MakePointer().

00060   { 
00061     bbtkDebugMessage("object",9,"##> Object::InsertInObjectList(\""
00062                      <<p->GetObjectName()<<"\" ["<<p<<"])"<<std::endl);
00063     boost::weak_ptr<Object> w(p);
00064     mgObjectList.insert(w); 
00065   }

Here is the caller graph for this function:

void bbtk::Object::InsertInPackageList ( Pointer  p  )  [static]

Definition at line 69 of file bbtkObject.cxx.

References bbtkDebugMessage, and mgPackageList.

00070   { 
00071     bbtkDebugMessage("object",9,"##> Object::InsertInPackageList(\""
00072                      <<p->GetObjectName()<<"\" ["<<p<<"])"<<std::endl);
00073     boost::weak_ptr<Object> w(p);
00074     mgPackageList.insert(w); 
00075   }

void bbtk::Object::LockThis (  )  [inline, protected]

Definition at line 88 of file bbtkObject.h.

00088 { mThisPointerLocked = mThisPointer.lock(); }   

template<class U , class D >
static boost::shared_ptr<U> bbtk::Object::MakePointer ( U *  s,
const D &  del,
bool  lock = false 
) [inline, static, protected]

Definition at line 115 of file bbtkObject.h.

References InsertInObjectList().

00118     {                                                                   
00119       if (s->mThisPointer.lock())                                       
00120         {                                                               
00121           boost::shared_ptr<U> p = s->GetThisPointer<U>();
00122           if (!lock) s->mThisPointerLocked.reset();
00123           return p;
00124         }                                                               
00125       boost::shared_ptr<U> p = boost::shared_ptr<U>(s,del);
00126       static_cast<D*>                                   
00127         (p._internal_get_deleter(typeid(D)))            
00128         ->mPointer = p;                                                 
00129       s->mThisPointer = p;                                              
00130       Object::InsertInObjectList(p);                                    
00131       if (lock) s->LockThis();                                          
00132       return p;                                                 
00133     }                                                                   

Here is the call graph for this function:

template<class U >
static boost::shared_ptr<U> bbtk::Object::MakePointer ( U *  s,
bool  lock = false 
) [inline, static, protected]

Definition at line 97 of file bbtkObject.h.

References InsertInObjectList().

Referenced by bbtk::ComplexBlackBoxDescriptor::ComplexBlackBoxDescriptor(), bbtk::Executer::Executer(), bbtk::Interpreter::Init(), bbtk::Transcriptor::New(), bbtk::Package::New(), bbtk::InterpreterVirtual::New(), bbtk::Interpreter::New(), bbtk::Factory::New(), bbtk::Executer::New(), and bbtk::ComplexBlackBoxDescriptor::New().

00098     {                                                                   
00099       if (s->mThisPointer.lock())                                       
00100         {                                                               
00101           boost::shared_ptr<U> p = s->GetThisPointer<U>();
00102           if (!lock) s->mThisPointerLocked.reset();
00103           return p;
00104         }                                                               
00105       boost::shared_ptr<U> p = boost::shared_ptr<U>(s,Object::Deleter());
00106       static_cast<Object::Deleter*>                                     
00107         (p._internal_get_deleter(typeid(Object::Deleter)))              
00108         ->mPointer = p;                                                 
00109       s->mThisPointer = p;                                              
00110       Object::InsertInObjectList(p);                                    
00111       if (lock) s->LockThis();                                          
00112       return p;                                                 
00113     }                                                                   

Here is the call graph for this function:

Here is the caller graph for this function:

void bbtk::Object::PrintObjectInfo ( const Pointer o  )  [static]

Definition at line 180 of file bbtkObject.cxx.

Referenced by PrintObjectListInfo().

00181   {
00182     std::cout << "* [" << p << "] \t" 
00183               << p.use_count()-1 << " r \t"
00184               << p->GetObjectRecursiveSize() << " ("
00185               << p->GetObjectSize() << ") b \t"
00186               << p->GetObjectName() 
00187               << std::endl;
00188     std::cout << p->GetObjectInfo();
00189   }

Here is the caller graph for this function:

void bbtk::Object::PrintObjectListInfo ( const std::string &  name  )  [static]

Definition at line 105 of file bbtkObject.cxx.

References bbtk::i, mgObjectList, and PrintObjectInfo().

Referenced by bbtk::Interpreter::commandDebug().

00106   {
00107     
00108     std::cout 
00109       << "=============== Living bbtk::Object pointers ========="<<std::endl;
00110 
00111     long n = 0;
00112     long u = 0;
00113     size_t m = 0;
00114     ObjectListType::iterator i;
00115     for (i = mgObjectList.begin();
00116          i!=mgObjectList.end();
00117          ++i)
00118       {
00119         if (i->use_count() == 0) 
00120           {
00121             u++;
00122           }
00123         else 
00124           { 
00125             Object::Pointer p(i->lock());
00126             if (p->GetObjectName().find(name) != std::string::npos ) 
00127               {
00128                 std::cout << n << "/" << mgObjectList.size() << " ";
00129                 PrintObjectInfo(p);
00130                 m += p->GetObjectSize();
00131                 n++;
00132               }
00133           }
00134       }
00135     std::cout 
00136       << "------------------------------------------------------"<<std::endl; 
00137 
00138     std::cout << " Total : "<<n<<" objects - "<<m<<" b"<<std::endl;
00139     if (u==1)
00140       {
00141         std::cout<<"* Note : "<<u
00142                  <<" object in list has 0 ref count, "
00143                  <<"i.e. are no more accessible by bbtk but did not properly destroyed because another ref counting system is holding them !"<<std::endl;
00144       }
00145     else if (u>1)
00146       {
00147         std::cout<<"* Note : "<<u
00148                  <<" objects in list have 0 ref count, "
00149                  <<"i.e. are no more accessible by bbtk but did not properly destroyed because another ref counting system is holding them !"<<std::endl;
00150       }
00151     std::cout
00152       << "============ EO Living bbtk::Object pointers ========="<<std::endl;
00153         
00154   }

Here is the call graph for this function:

Here is the caller graph for this function:

void bbtk::Object::ReleasePackages (  )  [static]

Definition at line 222 of file bbtkObject.cxx.

References bbtkDebugMessage, bbtk::i, mgPackageList, and bbtk::Package::Release().

Referenced by bbtk::StaticInitTime::~StaticInitTime().

00223   {
00224     bbtkDebugMessage("object",1,"##> Object::ReleasePackages()"<<std::endl);
00225     // Release package pointers
00226     ObjectListType::iterator i;
00227     for (i = mgPackageList.begin();
00228          i!= mgPackageList.end();
00229          ++i)
00230       {
00231         if (i->use_count() != 0) 
00232           { 
00233             bbtkDebugMessage("object",1,"##> Releasing package '"<<
00234                              i->lock()->GetThisPointer<Package>()->GetName()
00235                              <<"'"<<std::endl);
00236             //      Object::Pointer p(i->lock());
00237             Package::WeakPointer w(i->lock()->GetThisPointer<Package>());
00238             Package::Release(w);
00239             /*
00240             if (p->GetObjectName().find(name) != std::string::npos ) 
00241               {
00242                 std::cout << n << "/" << mgObjectList.size() << " ";
00243                 PrintObjectInfo(p);
00244                 m += p->GetObjectSize();
00245                 n++;
00246               }
00247             */
00248           }
00249       }  
00250 
00251   }

Here is the call graph for this function:

Here is the caller graph for this function:

void bbtk::Object::RemoveFromObjectList ( WeakPointer  p  )  [static]

Definition at line 80 of file bbtkObject.cxx.

References bbtkDebugMessage, and mgObjectList.

Referenced by bbtk::Object::Deleter::operator()().

00081   { 
00082     bbtkDebugMessage("object",9,"##> Object::RemoveFromObjectList()"
00083                      <<std::endl);
00084     mgObjectList.erase(p);
00085 
00086   }

Here is the caller graph for this function:

void bbtk::Object::UnLockThis (  )  [inline, protected]

Definition at line 89 of file bbtkObject.h.

00089 { mThisPointerLocked = Pointer(); }


Member Data Documentation

Definition at line 137 of file bbtkObject.h.

Referenced by InsertInObjectList(), PrintObjectListInfo(), and RemoveFromObjectList().

Definition at line 138 of file bbtkObject.h.

Referenced by InsertInPackageList(), and ReleasePackages().

Definition at line 139 of file bbtkObject.h.

Definition at line 140 of file bbtkObject.h.


The documentation for this class was generated from the following files:

Generated on Thu May 31 14:14:54 2012 for BBTK by  doxygen 1.5.7.1