#include <bbtkObject.h>
Classes | |
struct | Deleter |
Default objects deleter : removes object from list on deletion. More... | |
Public Types | |
typedef boost::shared_ptr< Object > | Pointer |
typedef boost::weak_ptr< Object > | WeakPointer |
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 |
Definition at line 49 of file bbtkObject.h.
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 |
Reimplemented in bbtk::BlackBox, bbtk::BlackBoxDescriptor, bbtk::ComplexBlackBox, bbtk::ComplexBlackBoxDescriptor, bbtk::Connection, bbtk::Executer, bbtk::Factory, bbtk::Interpreter, bbtk::InterpreterVirtual, bbtk::Package, bbtk::QtBlackBox, bbtk::QtBlackBoxDescriptor, bbtk::Transcriptor, bbtk::VirtualExec, bbtk::WidgetBlackBox< W >, bbtk::WidgetBlackBoxDescriptor< T >, bbtk::WxBlackBox, bbtk::WxBlackBoxDescriptor, bbtk::WidgetBlackBox< QWidget >, bbtk::WidgetBlackBox< wxWindow >, bbtk::WidgetBlackBoxDescriptor< QWidget >, and bbtk::WidgetBlackBoxDescriptor< wxWindow >.
Definition at line 52 of file bbtkObject.h.
typedef boost::weak_ptr<Object> bbtk::Object::WeakPointer |
Reimplemented in bbtk::BlackBox, bbtk::BlackBoxDescriptor, bbtk::ComplexBlackBox, bbtk::ComplexBlackBoxDescriptor, bbtk::Connection, bbtk::Executer, bbtk::Factory, bbtk::Interpreter, bbtk::InterpreterVirtual, bbtk::Package, bbtk::QtBlackBox, bbtk::QtBlackBoxDescriptor, bbtk::Transcriptor, bbtk::VirtualExec, bbtk::WidgetBlackBox< W >, bbtk::WidgetBlackBoxDescriptor< T >, bbtk::WxBlackBox, bbtk::WxBlackBoxDescriptor, bbtk::WidgetBlackBox< QWidget >, bbtk::WidgetBlackBox< wxWindow >, bbtk::WidgetBlackBoxDescriptor< QWidget >, and bbtk::WidgetBlackBoxDescriptor< wxWindow >.
Definition at line 53 of file bbtkObject.h.
bbtk::Object::Object | ( | ) |
bbtk::Object::~Object | ( | ) | [virtual] |
std::string bbtk::Object::GetObjectInfo | ( | ) | const [virtual] |
Reimplemented in bbtk::AtomicBlackBox, bbtk::ComplexBlackBox, bbtk::ComplexBlackBoxDescriptor, bbtk::Connection, bbtk::Executer, bbtk::Factory, bbtk::Interpreter, bbtk::InterpreterVirtual, bbtk::Package, and bbtk::Transcriptor.
Definition at line 98 of file bbtkObject.cxx.
virtual size_t bbtk::Object::GetObjectInternalSize | ( | ) | const [inline, virtual] |
Reimplemented in bbtk::ComplexBlackBox, bbtk::ComplexBlackBoxDescriptor, bbtk::Connection, bbtk::Executer, bbtk::Factory, bbtk::Interpreter, bbtk::InterpreterVirtual, bbtk::Package, and bbtk::Transcriptor.
Definition at line 61 of file bbtkObject.h.
00061 { return sizeof(Object); }
std::string bbtk::Object::GetObjectName | ( | ) | const [virtual] |
Reimplemented in bbtk::ComplexBlackBox, bbtk::ComplexBlackBoxDescriptor, bbtk::Connection, bbtk::Executer, bbtk::Factory, bbtk::Interpreter, bbtk::InterpreterVirtual, bbtk::Package, bbtk::QtBlackBox, bbtk::QtBlackBoxDescriptor, bbtk::Transcriptor, bbtk::WidgetBlackBox< W >, bbtk::WidgetBlackBoxDescriptor< T >, bbtk::WxBlackBox, bbtk::WxBlackBoxDescriptor, bbtk::WidgetBlackBox< QWidget >, bbtk::WidgetBlackBox< wxWindow >, bbtk::WidgetBlackBoxDescriptor< QWidget >, and bbtk::WidgetBlackBoxDescriptor< wxWindow >.
Definition at line 91 of file bbtkObject.cxx.
Referenced by bbtk::BlackBox::Deleter::Delete(), and bbtk::Object::Deleter::operator()().
virtual size_t bbtk::Object::GetObjectRecursiveSize | ( | ) | const [inline, virtual] |
Reimplemented in bbtk::AtomicBlackBox, bbtk::ComplexBlackBox, bbtk::ComplexBlackBoxDescriptor, bbtk::Connection, bbtk::Executer, bbtk::Factory, bbtk::Interpreter, bbtk::InterpreterVirtual, bbtk::Package, and bbtk::Transcriptor.
Definition at line 62 of file bbtkObject.h.
Referenced by bbtk::Transcriptor::GetObjectRecursiveSize(), bbtk::Package::GetObjectRecursiveSize(), bbtk::InterpreterVirtual::GetObjectRecursiveSize(), bbtk::Interpreter::GetObjectRecursiveSize(), bbtk::Factory::GetObjectRecursiveSize(), bbtk::Executer::GetObjectRecursiveSize(), bbtk::Connection::GetObjectRecursiveSize(), bbtk::ComplexBlackBoxDescriptor::GetObjectRecursiveSize(), and bbtk::ComplexBlackBox::GetObjectRecursiveSize().
00062 { return sizeof(Object); }
static long bbtk::Object::GetObjectsCount | ( | ) | [inline, static] |
Definition at line 75 of file bbtkObject.h.
Referenced by bbtk::StaticInitTime::~StaticInitTime().
00075 { return mgObjectList.size(); }
virtual size_t bbtk::Object::GetObjectSize | ( | ) | const [inline, virtual] |
Reimplemented in bbtk::AtomicBlackBox, bbtk::ComplexBlackBox, bbtk::ComplexBlackBoxDescriptor, bbtk::Connection, bbtk::Executer, bbtk::Factory, bbtk::Interpreter, bbtk::InterpreterVirtual, bbtk::Package, bbtk::QtBlackBoxDescriptor, bbtk::Transcriptor, and bbtk::WxBlackBoxDescriptor.
Definition at line 60 of file bbtkObject.h.
Referenced by bbtk::Transcriptor::GetObjectSize(), bbtk::Package::GetObjectSize(), bbtk::InterpreterVirtual::GetObjectSize(), bbtk::Interpreter::GetObjectSize(), bbtk::Factory::GetObjectSize(), bbtk::Executer::GetObjectSize(), bbtk::Connection::GetObjectSize(), bbtk::ComplexBlackBoxDescriptor::GetObjectSize(), and bbtk::ComplexBlackBox::GetObjectSize().
00060 { return sizeof(Object); }
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] |
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 }
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] |
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 }
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 }
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 }
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 }
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 }
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 }
void bbtk::Object::UnLockThis | ( | ) | [inline, protected] |
Object::ObjectListType bbtk::Object::mgObjectList [static, private] |
Definition at line 137 of file bbtkObject.h.
Referenced by InsertInObjectList(), PrintObjectListInfo(), and RemoveFromObjectList().
Object::ObjectListType bbtk::Object::mgPackageList [static, private] |
Definition at line 138 of file bbtkObject.h.
Referenced by InsertInPackageList(), and ReleasePackages().
WeakPointer bbtk::Object::mThisPointer [private] |
Definition at line 139 of file bbtkObject.h.
Pointer bbtk::Object::mThisPointerLocked [private] |
Definition at line 140 of file bbtkObject.h.