#include <bbtkFactory.h>
typedef std::map< std::string, Package::Pointer > | PackageMapType |
The type of map of packages. | |
void | GetPackagesList (std::vector< std::string > &) |
Pushes back the names of the Package s which are in the Factory. | |
void | LoadPackage (const std::string &name) |
Loads a dynamic library which contains a Package. | |
void | UnLoadPackage (const std::string &name) |
Unloads a Package which was loaded from a dynamic library. | |
void | InsertPackage (Package::Pointer) |
Inserts a Package in the Factory. | |
void | RemovePackage (Package::Pointer) |
Removess a Package from the Factory. | |
Package::Pointer | GetPackage (const std::string &name) const |
Returns the pointer on a Package provided by name. | |
const PackageMapType & | GetPackageMap () const |
Returns the map of Packages. | |
Public Types | |
enum | IndexEntryType { Packages, Categories, Initials, Adaptors } |
typedef Factory | Self |
typedef boost::shared_ptr< Self > | Pointer |
typedef boost::weak_ptr< Self > | WeakPointer |
Public Member Functions | |
std::string | GetObjectName () const |
std::string | GetObjectInfo () const |
size_t | GetObjectSize () const |
size_t | GetObjectInternalSize () const |
size_t | GetObjectRecursiveSize () const |
void | WriteDotFilePackagesList (FILE *ff) |
void | Reset () |
Releases all the packages of the Factory. | |
void | Check () const |
void | CreateHtmlIndex (IndexEntryType type, const std::string &filename) |
void | SetExecuter (ExecuterPointer e) |
Sets the executer who created the factory (if any). | |
ExecuterPointer | GetExecuter () |
Gets the executer who created the factory (if any). | |
std::string | GetPackageNameOfaBlackBox (std::string boxType) |
Gets the executer who created the factory (if any) - const. | |
long | GetUseCount () |
void | PrintHelpListPackages (bool details=true, bool adaptors=false) const |
Prints the list of Package. | |
void | PrintHelpPackage (const std::string &name, bool adaptors=false) const |
Prints help on a particular Package. | |
void | PrintHelpDescriptor (const std::string &name, std::string &package, bool full=true) const |
Prints help on a BlackBoxDescriptor. | |
void | ShowGraphTypes (const std::string &name) const |
Object creation methods | |
BlackBox::Pointer | NewBlackBox (const std::string &type, const std::string &name) const |
Creates an instance of a black box of type <type> with name <name>. | |
BlackBox::Pointer | NewAdaptor (const DataInfo &typein, const DataInfo &typeout, const std::string &name) const |
Creates an instance of a black box of type <type> with name <name>. | |
BlackBox::Pointer | NewWidgetAdaptor (const DataInfo &typein, const DataInfo &typeout, const std::string &name) const |
Creates an instance of a black box of type <type> with name <name>. | |
Connection::Pointer | NewConnection (BlackBox::Pointer from, const std::string &output, BlackBox::Pointer to, const std::string &input) const |
Creates an instance of a connection. | |
Package inspection methods | |
Allow to test if an Adaptor is present in the packages WITHOUT instanciating it | |
bool | FindAdaptor (const DataInfo &typein, const DataInfo &typeout, std::string &adaptor) const |
Creates an instance of a black box of type <type> with name <name>. | |
bool | FindWidgetAdaptor (const DataInfo &typein, const DataInfo &typeout, std::string &adaptor) const |
Creates an instance of a black box of type <type> with name <name>. | |
bool | FindWidgetAdaptor2 (const DataInfo &typein, const DataInfo &typeout, std::string &widget, std::string &adaptor) const |
Creates an instance of a black box of type <type> with name <name>. | |
Static Public Member Functions | |
static Pointer | New () |
Default ctor. | |
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 Types | |
typedef Object | Superclass |
Protected Member Functions | |
Factory () | |
Default ctor. | |
Factory (const Factory &) | |
~Factory () | |
Dtor. | |
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 Member Functions | |
bool | DoLoadPackage (std::string libname, std::string pkgname, std::string path) |
void | CloseAllPackages () |
void | ClosePackage (PackageMapType::iterator &i) |
Close the package referenced by the iterator. | |
Private Attributes | |
PackageMapType | mPackageMap |
The map of packages. | |
ExecuterWeakPointer | mExecuter |
The executer which created the factory (if any). | |
Friends | |
struct | Object::Deleter |
Definition at line 53 of file bbtkFactory.h.
typedef std::map< std::string, Package::Pointer > bbtk::Factory::PackageMapType |
typedef boost::shared_ptr<Self> bbtk::Factory::Pointer |
typedef Factory bbtk::Factory::Self |
Definition at line 55 of file bbtkFactory.h.
typedef Object bbtk::Factory::Superclass [protected] |
Definition at line 55 of file bbtkFactory.h.
typedef boost::weak_ptr<Self> bbtk::Factory::WeakPointer |
Definition at line 140 of file bbtkFactory.h.
00141 { 00142 Packages, 00143 Categories, 00144 Initials, 00145 Adaptors 00146 }
bbtk::Factory::Factory | ( | ) | [protected] |
Default ctor.
Definition at line 68 of file bbtkFactory.cxx.
References bbtkDebugMessage.
Referenced by New().
00069 : mExecuter() 00070 { 00071 bbtkDebugMessage("kernel",7,"Factory()"<<std::endl); 00072 }
bbtk::Factory::Factory | ( | const Factory & | ) | [protected] |
bbtk::Factory::~Factory | ( | ) | [protected] |
Dtor.
Definition at line 77 of file bbtkFactory.cxx.
References bbtkDebugMessage, and CloseAllPackages().
00078 { 00079 bbtkDebugMessage("kernel",7,"==> ~Factory()"<<std::endl); 00080 CloseAllPackages(); 00081 bbtkDebugMessage("kernel",7,"<== ~Factory()"<<std::endl); 00082 }
void bbtk::Factory::Check | ( | ) | const |
Definition at line 831 of file bbtkFactory.cxx.
References bbtkMessage, and mPackageMap.
00832 { 00833 bbtkMessage("debug",1,"****** Checking Factory "<<(void*)this 00834 <<std::endl); 00835 PackageMapType::const_iterator i; 00836 for (i = mPackageMap.begin(); i!=mPackageMap.end(); ++i ) 00837 { 00838 i->second->Check(); 00839 } 00840 bbtkMessage("debug",1,"****** Checking Factory "<<(void*)this 00841 <<" ... OK"<<std::endl); 00842 }
void bbtk::Factory::CloseAllPackages | ( | ) | [private] |
Definition at line 349 of file bbtkFactory.cxx.
References bbtkDebugDecTab, bbtkDebugMessage, bbtkDebugMessageInc, ClosePackage(), bbtk::i, and mPackageMap.
Referenced by Reset(), and ~Factory().
00350 { 00351 bbtkDebugMessageInc("kernel",7,"Factory::CloseAllPackages()"<<std::endl); 00352 00353 std::vector< Package::WeakPointer > mAlive; 00354 do { 00355 mAlive.clear(); 00356 while (mPackageMap.begin() != mPackageMap.end()) 00357 { 00358 PackageMapType::iterator i = mPackageMap.begin(); 00359 Package::WeakPointer p = i->second; 00360 ClosePackage(i); 00361 if (p.lock()) mAlive.push_back(p); 00362 } 00363 std::vector< Package::WeakPointer >::iterator i; 00364 for (i=mAlive.begin();i!=mAlive.end();++i) 00365 { 00366 // If not dead : reinsert 00367 if (i->lock()) 00368 { 00369 bbtkDebugMessage("kernel",7,"Package "<<i->lock()->GetName() 00370 <<" still alive"<<std::endl); 00371 // InsertPackage(i->lock()); 00372 } 00373 } 00374 } 00375 while (mPackageMap.size()>0); 00376 00377 bbtkDebugDecTab("kernel",7); 00378 }
void bbtk::Factory::ClosePackage | ( | PackageMapType::iterator & | i | ) | [private] |
Close the package referenced by the iterator.
First removes the factory from the set of factories which use the package If the set is empty then : If it is a dynamically loaded package :
Finally erases the package entry in the packages map
Definition at line 393 of file bbtkFactory.cxx.
References bbtkDebugDecTab, bbtkDebugMessageInc, mPackageMap, and bbtk::Package::Release().
Referenced by CloseAllPackages(), RemovePackage(), and UnLoadPackage().
00394 { 00395 bbtkDebugMessageInc("kernel",7,"Factory::ClosePackage(\"" 00396 <<i->second->GetName() 00397 <<"\")"<<std::endl); 00398 00399 00400 // Removes this from the set of factories which use the package 00401 i->second->RemoveFactory(GetThisPointer<Factory>()); 00402 Package::WeakPointer p = i->second; 00403 // remove the entry in the map 00404 mPackageMap.erase(i); 00405 // Release the package if not already destroyed 00406 if (p.lock()) 00407 { 00408 Package::Release(p); 00409 } 00410 bbtkDebugDecTab("kernel",7); 00411 }
void bbtk::Factory::CreateHtmlIndex | ( | IndexEntryType | type, | |
const std::string & | filename | |||
) |
Definition at line 919 of file bbtkFactory.cxx.
References Adaptors, bbtkDebugDecTab, bbtkDebugMessageInc, bbtkendl, bbtkError, Categories, bbtk::ConfigurationFile::Get_bin_path(), bbtk::ConfigurationFile::GetInstance(), bbtk::Utilities::html_format(), Initials, mPackageMap, Packages, bbtk::Utilities::SplitString(), and bbtk::BlackBoxDescriptor::STANDARD.
00921 { 00922 bbtkDebugMessageInc("kernel",9,"Factory::CreateHtmlIndex(\"" 00923 <<filename<<"\")"<<bbtkendl); 00924 00925 std::string title; 00926 00927 typedef std::map<std::string, 00928 std::vector<BlackBoxDescriptor::Pointer> > IndexType; 00929 IndexType index; 00930 // Builds the index map 00931 PackageMapType::const_iterator i; 00932 for (i = mPackageMap.begin(); i!=mPackageMap.end(); ++i ) 00933 { 00934 Package::Pointer pack = i->second; 00935 if (pack->GetName()=="user") continue; 00936 Package::DescriptorMapType::const_iterator j; 00937 for (j = pack->GetDescriptorMap().begin(); 00938 j!= pack->GetDescriptorMap().end(); 00939 ++j) 00940 { 00941 00942 // Skip adaptors 00943 if ( type==Adaptors ) 00944 { 00945 if (j->second->GetKind() == BlackBoxDescriptor::STANDARD ) 00946 continue; 00947 } 00948 else 00949 if (j->second->GetKind() != BlackBoxDescriptor::STANDARD ) 00950 continue; 00951 00952 std::vector<std::string> keys; 00953 if (type==Packages) 00954 { 00955 std::string k(""); 00956 k += pack->GetName(); 00957 keys.push_back(k); 00958 title = "Boxes by package"; 00959 } 00960 else if ((type==Initials) || (type==Adaptors)) 00961 { 00962 std::string init(" "); 00963 init[0] = std::toupper(j->second->GetTypeName()[0]); 00964 keys.push_back(init); 00965 title = "Alphabetical list"; 00966 } 00967 else if (type==Categories) 00968 { 00969 // Split the category string 00970 std::string delimiters = ";,"; 00971 Utilities::SplitString(j->second->GetCategory(), 00972 delimiters,keys); 00973 if (keys.size()==0) 00974 keys.push_back(" NONE"); 00975 title = "Boxes by category"; 00976 } 00977 00978 std::vector<std::string>::const_iterator k; 00979 for (k=keys.begin(); k!=keys.end(); ++k ) 00980 { 00981 IndexType::iterator p; 00982 p = index.find(*k); 00983 if (p != index.end()) 00984 { 00985 p->second.push_back(j->second); 00986 } 00987 else 00988 { 00989 std::vector<BlackBoxDescriptor::Pointer> v; 00990 v.push_back(j->second); 00991 index[*k] = v; 00992 } 00993 } 00994 } 00995 } 00996 // Creates the file 00997 //--------------------- 00998 // Open output file 00999 std::ofstream s; 01000 s.open(filename.c_str()); 01001 if (!s.good()) 01002 { 01003 bbtkError("Factory::CreateHtmlIndex : could not open file '" 01004 <<filename<<"'"); 01005 } 01006 01007 //---------------------- 01008 // Html head 01009 s << "<html lang=\"en\">\n"; 01010 s << "<head>\n"; 01011 s << "<title>"<<title<<"</title>\n"; 01012 s << "<meta http-equiv=\"Content-Type\" content=\"text/html\">\n"; 01013 s << "<meta name=\"description\" content=\""<<title<<"\">\n"; 01014 s << "<meta name=\"generator\" content=\"\">\n"; 01015 s << "<link title=\"Top\" rel=\"top\" href=\"#Top\">\n"; 01016 //<link href="http://www.gnu.org/software/texinfo/" rel="generator-home" title="Texinfo Homepage"> 01017 s << "<meta http-equiv=\"Content-Style-Type\" content=\"text/css\"><style type=\"text/css\"><!--\n"; 01018 s << "pre.display { font-family:inherit }\n"; 01019 s << "pre.format { font-family:inherit }\n"; 01020 s << "pre.smalldisplay { font-family:inherit; font-size:smaller }\n"; 01021 s << "pre.smallformat { font-family:inherit; font-size:smaller }\n"; 01022 s << "pre.smallexample { font-size:smaller }\n"; 01023 s << "pre.smalllisp { font-size:smaller }\n"; 01024 s << "span.sc { font-variant:small-caps }\n"; 01025 s << "span.roman { font-family:serif; font-weight:normal; } \n"; 01026 s << "span.sansserif { font-family:sans-serif; font-weight:normal; }\n"; 01027 s << "--></style>\n"; 01028 s << "</head>\n"; 01029 //---------------------- 01030 01031 //---------------------- 01032 // Html body 01033 s << "<body>\n"; 01034 s << "<a name=\"Top\"></a>\n"; 01035 s << "<h1 class=\"settitle\">"<<title<<"</h1>\n"; 01036 s << "<p>\n"; 01037 IndexType::iterator ii; 01038 for (ii=index.begin();ii!=index.end();++ii) 01039 { 01040 s << "<a href=\"#"<<ii->first<<"\">"<<ii->first<<"</a> "; 01041 } 01042 01043 for (ii=index.begin();ii!=index.end();++ii) 01044 { 01045 s << "<p><hr>\n"; 01046 s << "<p><a href=\"#Top\">Top</a>"; 01047 if (type==Packages) 01048 { 01049 s << "<a name=\""<<ii->first<<"\"></a>\n"; 01050 s << "<p><a href=\""<<ii->first<<"/index.html\">" 01051 << ii->first<<"</a>\n"; 01052 01053 s << " - \n"; 01054 01055 s << "<a name=\"doxygen\"></a>\n"; 01056 01057 //EED 26Mars2009 01058 /*JCP 19 Nov 2009 01059 std::string bin_path = bbtk::ConfigurationFile::GetInstance().Get_bin_path(); 01060 s << "<a href=" << bin_path <<"/../share/bbtk/doc/doxygen/" << ii->first << "/main.html>(Doxygen documentation of the source)</a>\n"; 01061 JCP 19 Nov 2009*/ 01062 std::string bin_path = bbtk::ConfigurationFile::GetInstance().Get_bin_path(); 01063 s << "<a href=" << bin_path <<"/../share/bbtk/doc/doxygen/" << ii->first << "/main.html>(Doxygen documentation of the source)</a>\n"; 01064 } 01065 else 01066 { 01067 s << "<a name=\""<<ii->first<<"\"></a>\n"; 01068 s << "<p><b>"<<ii->first<<"</b>\n"; 01069 } 01070 s << "<ul>\n"; 01071 01072 s << "<p><TABLE cellspacing=0 cellpadding=3>\n"; 01073 01074 std::vector<BlackBoxDescriptor::Pointer>::iterator di; 01075 for (di=ii->second.begin();di!=ii->second.end();++di) 01076 { 01077 std::string pack = (*di)->GetPackage()->GetName(); 01078 std::string name = (*di)->GetTypeName(); 01079 Utilities::html_format(name); 01080 std::string descr = (*di)->GetDescription(); 01081 Utilities::html_format(descr); 01082 s << "<TR>"; 01083 s << "<TD style='vertical-align: top;'>"; 01084 s << " <a href=\""<<pack 01085 <<"/index.html#"<<name<<"\">" 01086 <<pack<<"::"<<name<<"</a>"; 01087 s << "</TD> "; 01088 s << " <TD style='vertical-align: top;'>" << descr << " </TD>"; 01089 s << "</TR>\n"; 01090 } 01091 s << "</TABLE>\n"; 01092 s << "</ul>\n"; 01093 s << "</div>\n"; 01094 } 01095 //---------------------- 01096 // Footer 01097 time_t rawtime; 01098 tm * ptm; 01099 time ( &rawtime ); 01100 ptm = gmtime ( &rawtime ); 01101 01102 s << "<p><hr>\n"; 01103 s << "Automatically generated by <b>bbtk</b> on " 01104 << ptm->tm_mday << "/" << ptm->tm_mon << "/" << ptm->tm_year+1900 01105 << " - " << ptm->tm_hour << ":" << ptm->tm_min << " GMT\n"; 01106 s << "</body></html>\n"; 01107 s.close(); 01108 //---------------------- 01109 01110 // End 01111 bbtkDebugDecTab("kernel",9); 01112 }
bool bbtk::Factory::DoLoadPackage | ( | std::string | libname, | |
std::string | pkgname, | |||
std::string | path | |||
) | [private] |
Definition at line 98 of file bbtkFactory.cxx.
References bbtkMessage, bbtk::Package::CreateFromDynamicLibrary(), and mPackageMap.
Referenced by LoadPackage().
00101 { 00102 00103 Package::Pointer p = Package::CreateFromDynamicLibrary(libname, 00104 pkgname, 00105 path); 00106 if (p!=0) 00107 { 00108 //=================================================================== 00109 bbtkMessage("output",2,p->GetName()<<" " 00110 <<p->GetVersion() 00111 <<" " 00112 <<p->GetAuthor() << " Category(s) :" 00113 <<p->GetCategory() 00114 <<std::endl); 00115 bbtkMessage("output",2,p->GetDescription()<<std::endl); 00116 //=================================================================== 00117 p->AddFactory(GetThisPointer<Factory>()); 00118 printf("EED Factory::DoLoadPackage > %s %s %s \n",libname.c_str(), pkgname.c_str(),path.c_str()); 00119 mPackageMap[pkgname] = p; 00120 return true; 00121 } 00122 return false; 00123 00124 }
bool bbtk::Factory::FindAdaptor | ( | const DataInfo & | typein, | |
const DataInfo & | typeout, | |||
std::string & | adaptor | |||
) | const |
Creates an instance of a black box of type <type> with name <name>.
Definition at line 664 of file bbtkFactory.cxx.
References bbtkDebugDecTab, bbtkDebugMessageInc, bbtkendl, and mPackageMap.
Referenced by FindWidgetAdaptor2().
00667 { 00668 bbtkDebugMessageInc("kernel",8,"Factory::FindAdaptor(<" 00669 <<typein<<">,<" 00670 <<typeout<<">)"<<bbtkendl); 00671 00672 bool b = false; 00673 PackageMapType::const_iterator i; 00674 for (i = mPackageMap.begin(); i!=mPackageMap.end(); ++i ) 00675 { 00676 b = i->second->FindAdaptor(typein, 00677 typeout, 00678 adaptor); 00679 if (b) break; 00680 } 00681 /* 00682 if (!b) 00683 { 00684 bbtkError("no "<<typein<<" to "<<typeout 00685 <<"> widget adaptor available"); 00686 } 00687 */ 00688 00689 bbtkDebugDecTab("kernel",7); 00690 return b; 00691 }
bool bbtk::Factory::FindWidgetAdaptor | ( | const DataInfo & | typein, | |
const DataInfo & | typeout, | |||
std::string & | adaptor | |||
) | const |
Creates an instance of a black box of type <type> with name <name>.
Definition at line 696 of file bbtkFactory.cxx.
References bbtkDebugDecTab, bbtkDebugMessageInc, bbtkendl, and mPackageMap.
00699 { 00700 bbtkDebugMessageInc("kernel",8,"Factory::FindWidgetAdaptor(<" 00701 <<typein<<">,<" 00702 <<typeout<<">)"<<bbtkendl); 00703 00704 bool b = false; 00705 PackageMapType::const_iterator i; 00706 for (i = mPackageMap.begin(); i!=mPackageMap.end(); ++i ) 00707 { 00708 b = i->second->FindWidgetAdaptor(typein, 00709 typeout, 00710 adaptor); 00711 if (b) break; 00712 } 00713 bbtkDebugDecTab("kernel",7); 00714 return b; 00715 }
bool bbtk::Factory::FindWidgetAdaptor2 | ( | const DataInfo & | typein, | |
const DataInfo & | typeout, | |||
std::string & | widget, | |||
std::string & | adaptor | |||
) | const |
Creates an instance of a black box of type <type> with name <name>.
Definition at line 720 of file bbtkFactory.cxx.
References bbtkDebugDecTab, bbtkDebugMessageInc, bbtkendl, bbtkMessage, bbtk::BlackBoxDescriptor::DEFAULT_GUI, FindAdaptor(), bbtk::DataInfo::GetNature(), bbtk::DataInfo::GetType(), and mPackageMap.
00724 { 00725 bbtkDebugMessageInc("kernel",8,"Factory::FindWidgetAdaptor(<" 00726 <<typein<<">,<" 00727 <<typeout<<">)"<<bbtkendl); 00728 00729 bool b = false; 00730 adaptor = widget = ""; 00731 PackageMapType::const_iterator i; 00732 for (i = mPackageMap.begin(); i!=mPackageMap.end(); ++i ) 00733 { 00734 b = i->second->FindWidgetAdaptor(typein, 00735 typeout, 00736 widget); 00737 if (b) break; 00738 } 00739 if (!b) 00740 { 00741 // Look for a widget adaptor with good nature out 00742 bbtkMessage("kernel",5, 00743 "*** Looking for a two pieces widget adaptor for : " 00744 << typein << "->"<<typeout<<std::endl); 00745 for (i = mPackageMap.begin(); i!=mPackageMap.end(); ++i ) 00746 { 00747 Package::AdaptorMapType::const_iterator j; 00748 for (j=i->second->GetAdaptorMap().begin(); 00749 j!=i->second->GetAdaptorMap().end(); 00750 ++j) 00751 { 00752 if ( ( j->first.mKind == 00753 BlackBoxDescriptor::DEFAULT_GUI) && 00754 //(j->first.mTypeIn == typein) && 00755 (j->first.mTypeOut.GetNature() == typeout.GetNature() ) 00756 ) 00757 { 00758 widget = j->second.lock()->GetTypeName(); 00759 bbtkMessage("kernel",5, 00760 "===> Found first part : "<<widget 00761 << " "<<j->first.mTypeIn<<"->" 00762 <<j->first.mTypeOut<<std::endl); 00763 DataInfo ti( j->first.mTypeOut.GetType(), ""); 00764 DataInfo to( typeout.GetType(), ""); 00765 b = FindAdaptor( ti, to, adaptor ); 00766 if (b) 00767 { 00768 bbtkMessage("kernel",5, 00769 "===> Found second part : "<<adaptor 00770 <<std::endl); 00771 break; 00772 } 00773 else 00774 { 00775 bbtkMessage("kernel",5, 00776 "===> No second part found"<<std::endl); 00777 } 00778 } 00779 } 00780 if (b) break; 00781 } 00782 } 00783 bbtkDebugDecTab("kernel",7); 00784 return b; 00785 }
ExecuterPointer bbtk::Factory::GetExecuter | ( | ) | [inline] |
Gets the executer who created the factory (if any).
Definition at line 153 of file bbtkFactory.h.
00153 { return mExecuter.lock(); }
std::string bbtk::Factory::GetObjectInfo | ( | ) | const [virtual] |
Reimplemented from bbtk::Object.
Definition at line 1122 of file bbtkFactory.cxx.
01123 { 01124 std::stringstream i; 01125 return i.str(); 01126 }
size_t bbtk::Factory::GetObjectInternalSize | ( | ) | const [virtual] |
Reimplemented from bbtk::Object.
Definition at line 1138 of file bbtkFactory.cxx.
Referenced by GetObjectRecursiveSize(), and GetObjectSize().
01139 { 01140 size_t s = sizeof(Factory); 01141 return s; 01142 }
std::string bbtk::Factory::GetObjectName | ( | ) | const [virtual] |
size_t bbtk::Factory::GetObjectRecursiveSize | ( | ) | const [virtual] |
Reimplemented from bbtk::Object.
Definition at line 1145 of file bbtkFactory.cxx.
References GetObjectInternalSize(), bbtk::Object::GetObjectRecursiveSize(), and mPackageMap.
01146 { 01147 size_t s = Superclass::GetObjectRecursiveSize(); 01148 s += Factory::GetObjectInternalSize(); 01149 01150 PackageMapType::const_iterator i; 01151 for (i = mPackageMap.begin(); i!=mPackageMap.end(); ++i ) 01152 { 01153 s += i->second->GetObjectRecursiveSize(); 01154 } 01155 return s; 01156 }
static long bbtk::Object::GetObjectsCount | ( | ) | [inline, static, inherited] |
Definition at line 75 of file bbtkObject.h.
Referenced by bbtk::StaticInitTime::~StaticInitTime().
00075 { return mgObjectList.size(); }
size_t bbtk::Factory::GetObjectSize | ( | ) | const [virtual] |
Reimplemented from bbtk::Object.
Definition at line 1130 of file bbtkFactory.cxx.
References GetObjectInternalSize(), and bbtk::Object::GetObjectSize().
01131 { 01132 size_t s = Superclass::GetObjectSize(); 01133 s += Factory::GetObjectInternalSize(); 01134 return s; 01135 }
Package::Pointer bbtk::Factory::GetPackage | ( | const std::string & | name | ) | const |
Returns the pointer on a Package provided by name.
Definition at line 808 of file bbtkFactory.cxx.
References bbtkDebugDecTab, bbtkDebugMessageInc, bbtkError, and mPackageMap.
Referenced by WriteDotFilePackagesList().
00809 { 00810 bbtkDebugMessageInc("kernel",9,"Factory::GetPackage(\""<<name<<"\")" 00811 <<std::endl); 00812 00813 PackageMapType::const_iterator i = mPackageMap.find(name); 00814 if ( i != mPackageMap.end() ) 00815 { 00816 bbtkDebugDecTab("kernel",9); 00817 return i->second; 00818 } 00819 else 00820 { 00821 bbtkDebugDecTab("kernel",9); 00822 bbtkError("package \""<<name<<"\" unknown"); 00823 } 00824 00825 bbtkDebugDecTab("kernel",9); 00826 }
const PackageMapType& bbtk::Factory::GetPackageMap | ( | ) | const [inline] |
Returns the map of Packages.
Definition at line 77 of file bbtkFactory.h.
00077 { return mPackageMap; }
std::string bbtk::Factory::GetPackageNameOfaBlackBox | ( | std::string | boxType | ) |
Gets the executer who created the factory (if any) - const.
Definition at line 559 of file bbtkFactory.cxx.
References mPackageMap.
00560 { 00561 std::string result="<void bbtk package name>"; 00562 PackageMapType::const_iterator i; 00563 for (i = mPackageMap.begin(); i!=mPackageMap.end(); ++i ) 00564 { 00565 if ( i->second->ifBoxExist( boxType ) == true) 00566 { 00567 result = i->first; 00568 } 00569 } 00570 return result; 00571 }
void bbtk::Factory::GetPackagesList | ( | std::vector< std::string > & | ) |
boost::shared_ptr<U> bbtk::Object::GetThisPointer | ( | ) | const [inline, protected, inherited] |
Definition at line 92 of file bbtkObject.h.
00093 { 00094 return boost::dynamic_pointer_cast<U>(mThisPointer.lock()); 00095 }
long bbtk::Object::GetUseCount | ( | ) | [inline, inherited] |
void bbtk::Object::InsertInObjectList | ( | Pointer | p | ) | [static, inherited] |
Definition at line 59 of file bbtkObject.cxx.
References bbtkDebugMessage, and bbtk::Object::mgObjectList.
Referenced by bbtk::Object::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, inherited] |
Definition at line 69 of file bbtkObject.cxx.
References bbtkDebugMessage, and bbtk::Object::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::Factory::InsertPackage | ( | Package::Pointer | p | ) |
Inserts a Package in the Factory.
Inserts a package in the factory.
Definition at line 515 of file bbtkFactory.cxx.
References bbtkDebugDecTab, bbtkDebugMessageInc, and mPackageMap.
00516 { 00517 bbtkDebugMessageInc("kernel",9,"Factory::InsertPackage(\""<< 00518 p->GetName()<<"\")"<<std::endl); 00519 00520 p->AddFactory(GetThisPointer<Factory>()); 00521 00522 printf("EED Factory::InsertPackage %s\n", p->GetName().c_str() ); 00523 00524 mPackageMap[p->GetName()] = p; 00525 00526 bbtkDebugDecTab("kernel",9); 00527 }
void bbtk::Factory::LoadPackage | ( | const std::string & | name | ) |
Loads a dynamic library which contains a Package.
Loads a package.
The name is the system-independant name of the package (the name of the instance of bbtk::Package). Tries to open the dynamic library :
Definition at line 142 of file bbtkFactory.cxx.
References bbtkDebugMessageInc, bbtkError, bbtkMessage, DoLoadPackage(), bbtk::Utilities::ExpandLibName(), bbtk::Utilities::ExtractPackageName(), bbtk::Utilities::FileExists(), bbtk::ConfigurationFile::Get_package_paths(), bbtk::ConfigurationFile::GetInstance(), bbtk::i, bbtk::Utilities::MakeLibnameFromPath(), and mPackageMap.
00143 { 00144 00145 00146 // Note : in the following : 00147 // name : the user supplied name 00148 // - abreviated name e.g. pkg pkg.so libbpkg libbbpkg.so 00149 // - relative full name e.g. ./libbbpkg.so ../../libbbpkg.so 00150 // - absolute full name e.g. /home/usrname/proj/lib/libbbpkg.so 00151 // same for Windows, with c:, d: ... 00152 // 00153 // lastname : string before the last / (if any), or user supplied name 00154 00155 00156 00157 if(name != ""){ 00158 bbtkDebugMessageInc("kernel",7,"Factory::LoadPackage(\""<<name<<"\")"<<std::endl); 00159 bbtkMessage("debug",1,"Factory::LoadPackage(\""<<name<<"\")"<<std::endl); 00160 00161 std::vector<std::string> package_paths; 00162 std::string libname; // full path library name 00163 std::string pkgname; // e.g. libbb<pkgname>.so 00164 00165 std::string upath; 00166 00167 00168 pkgname = Utilities::ExtractPackageName(name,upath); 00169 00170 printf("EED Factory::LoadPackage A. %s\n", name.c_str()); 00171 printf("EED Factory::LoadPackage A. %s\n", upath.c_str()); 00172 printf("EED Factory::LoadPackage A. %s\n", pkgname.c_str()); 00173 00174 bbtkMessage("debug",1,"Package name ["<<pkgname<<"]"<<std::endl); 00175 bbtkMessage("debug",1,"Package path ["<<upath<<"]"<<std::endl); 00176 00177 // no loading package if already loaded 00178 PackageMapType::iterator iUnload; 00179 iUnload = mPackageMap.find(pkgname); 00180 00181 PackageMapType::iterator it; 00182 std::cout << "EED Factory::LoadPackage PackageMap "; 00183 for ( it=mPackageMap.begin() ; it != mPackageMap.end(); it++ ) 00184 std::cout << (*it).first << " "; 00185 std::cout << std::endl; 00186 00187 if (iUnload != mPackageMap.end()) 00188 { 00189 bbtkMessage("output",2,"["<< pkgname <<"] already loaded" << std::endl); 00190 return; 00191 } 00192 00193 // ================================================= 00194 // The following structure was checked to work 00195 // with any type of relative/absolute path. 00196 // Please don't modify it without checking 00197 // *all* the cases. JP 00198 //================================================== 00199 00200 printf("\nEED Factory::LoadPackage B. %s\n\n", name.c_str()); 00201 //std::cout << "upath [" << name << "]" << std::endl; 00202 00203 bool ok = false; 00204 bool foundFile = false; 00205 00206 // If path provided by user will be the first scanned : 00207 // push it into vector of paths 00208 if (upath.length()>0) // ------------------------------------- check user supplied location 00209 { 00210 if (name[0] != '.' && name[0] != '/' && name[1]!= ':') 00211 { 00212 bbtkError("Use absolute or relative path name! ["<<name<<"] is an illegal name"); 00213 return; 00214 } 00215 00216 // std::string path = Utilities::ExpandLibName(upath, false); 00217 00218 std::string path = Utilities::ExpandLibName(name,false); // keep last item, here. 00219 if (path != "") 00220 { 00221 std::string p2; 00222 Utilities::ExtractPackageName(path,p2); 00223 //libname = Utilities::MakeLibnameFromPath(path, pkgname); 00224 libname = Utilities::MakeLibnameFromPath(p2, pkgname); // remove last item 00225 // Check if library exists 00226 if ( !Utilities::FileExists(libname) ) 00227 { 00228 // The following is *NOT* a debug time message : 00229 // It's a user intended message. 00230 // Please don't remove it. 00231 bbtkMessage("output",3," [" <<libname 00232 <<"] : doesn't exist" <<std::endl); 00233 } 00234 else 00235 { 00236 ok = DoLoadPackage( libname, pkgname, path); 00237 } 00238 } 00239 else 00240 { 00241 bbtkError("Path ["<<upath<<"] doesn't exist"); 00242 return; 00243 } 00244 } 00245 else // ----------------------------------------------------- iterate on the paths 00246 { 00247 00248 std::string path = "."; 00249 package_paths = ConfigurationFile::GetInstance().Get_package_paths(); 00250 std::vector<std::string>::iterator i; 00251 for (i=package_paths.begin();i!=package_paths.end();++i) 00252 { 00253 foundFile = false; 00254 path = *i; 00255 //std::cout<<"JCP bbtkFactory.cxx void Factory::LoadPackage = path "<<path<<std::endl; 00256 // we *really* want '.' to be the current working directory 00257 if (path == ".") 00258 { 00259 char buf[2048]; // for getcwd 00260 char * currentDir = getcwd(buf, 2048); 00261 std::string cwd(currentDir); 00262 //std::cout<<"JCP bbtkFactory.cxx void Factory::LoadPackage = currentDir "<<currentDir<<std::endl; 00263 path = currentDir; 00264 } 00265 //std::cout<<"JCP bbtkFactory.cxx void Factory::LoadPackage = path "<<path<<" pkgnam="<<pkgname<<std::endl; 00266 libname = Utilities::MakeLibnameFromPath(path, pkgname); 00267 00268 bbtkMessage("debug",2,"-> Trying to load [" << libname << "]" <<std::endl); 00269 00270 // Check if library exists 00271 if ( !Utilities::FileExists(libname) ) 00272 { 00273 // The following is *NOT* a debug time message : 00274 // It's a user intended message. 00275 // Please don't remove it. 00276 bbtkMessage("output",3, 00277 " [" <<libname <<"] : doesn't exist" <<std::endl); 00278 continue; // try next path 00279 } 00280 foundFile = true; 00281 00282 // Try to Load the library 00283 00284 ok = DoLoadPackage( libname, pkgname, path); 00285 if (ok) 00286 { 00287 bbtkMessage("debug",2," OK"<<std::endl); 00288 } 00289 break; // we stop iterating even if error : have to signal it to user 00290 } //------------------ // end for ( package_paths.begin();i!=package_paths.end() ) 00291 00292 } 00293 00294 if( !ok ) // nothing was loaded 00295 { 00296 if (!foundFile) 00297 { 00298 bbtkError("Could not find package ["<<pkgname<< "]"); 00299 } 00300 else 00301 { 00302 #if defined(__GNUC__) 00303 bbtkError("Could not load package ["<< pkgname 00304 <<"] :" << std::endl 00305 << " Opening "<<libname<<" failed" 00306 << " Reason: "<< dlerror()); 00307 #elif defined(_WIN32) 00308 bbtkError("Could not load package ["<<pkgname 00309 <<"] :"<< std::endl << " Error loading " <<libname); 00310 00311 // look how to get the error message on win 00312 //<<dlerror()); 00313 // it is the bordel !! (the bloody fucking bordel, you mean?) 00314 // look : http://msdn2.microsoft.com/en-us/library/ms680582.aspx 00315 #endif 00316 } 00317 } 00318 bbtkMessage("output",2,"[" << libname << "] loaded" << std::endl); 00319 } 00320 00321 00322 00323 }
void bbtk::Object::LockThis | ( | ) | [inline, protected, inherited] |
static boost::shared_ptr<U> bbtk::Object::MakePointer | ( | U * | s, | |
const D & | del, | |||
bool | lock = false | |||
) | [inline, static, protected, inherited] |
Definition at line 115 of file bbtkObject.h.
References bbtk::Object::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, inherited] |
Definition at line 97 of file bbtkObject.h.
References bbtk::Object::InsertInObjectList().
Referenced by bbtk::ComplexBlackBoxDescriptor::ComplexBlackBoxDescriptor(), bbtk::Executer::Executer(), bbtk::Interpreter::Init(), bbtk::Transcriptor::New(), bbtk::Package::New(), bbtk::InterpreterVirtual::New(), bbtk::Interpreter::New(), 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 }
Factory::Pointer bbtk::Factory::New | ( | ) | [static] |
Default ctor.
Definition at line 59 of file bbtkFactory.cxx.
References bbtkDebugMessage, Factory(), and bbtk::Object::MakePointer().
Referenced by NewConnection().
00060 { 00061 bbtkDebugMessage("kernel",9,"Factory::New()"<<std::endl); 00062 return MakePointer(new Factory()); 00063 }
BlackBox::Pointer bbtk::Factory::NewAdaptor | ( | const DataInfo & | typein, | |
const DataInfo & | typeout, | |||
const std::string & | name | |||
) | const |
Creates an instance of a black box of type <type> with name <name>.
Definition at line 601 of file bbtkFactory.cxx.
References bbtkDebugDecTab, bbtkDebugMessageInc, bbtkendl, bbtkError, and mPackageMap.
00604 { 00605 bbtkDebugMessageInc("kernel",8,"Factory::NewAdaptor(" 00606 <<typein<<"," 00607 <<typeout<<",\"" 00608 <<name<<"\")"<<bbtkendl); 00609 00610 00611 BlackBox::Pointer b; 00612 PackageMapType::const_iterator i; 00613 for (i = mPackageMap.begin(); i!=mPackageMap.end(); ++i ) 00614 { 00615 b = i->second->NewAdaptor(typein,typeout,name); 00616 if (b) break; 00617 } 00618 if (!b) 00619 { 00620 bbtkError("no "<<typein<<" to "<<typeout 00621 <<" adaptor available"); 00622 } 00623 00624 bbtkDebugDecTab("kernel",7); 00625 return b; 00626 }
BlackBox::Pointer bbtk::Factory::NewBlackBox | ( | const std::string & | type, | |
const std::string & | name | |||
) | const |
Creates an instance of a black box of type <type> with name <name>.
Definition at line 576 of file bbtkFactory.cxx.
References bbtkDebugDecTab, bbtkDebugMessageInc, bbtkError, and mPackageMap.
00578 { 00579 bbtkDebugMessageInc("kernel",7,"Factory::NewBlackBox(\"" 00580 <<type<<"\",\""<<name<<"\")"<<std::endl); 00581 00582 BlackBox::Pointer b; 00583 PackageMapType::const_iterator i; 00584 for (i = mPackageMap.begin(); i!=mPackageMap.end(); ++i ) 00585 { 00586 b = i->second->NewBlackBox(type,name); 00587 if (b) break; 00588 } 00589 if (!b) 00590 { 00591 bbtkError("black box type \""<<type<<"\" unknown"); 00592 } 00593 00594 bbtkDebugDecTab("kernel",7); 00595 return b; 00596 }
Connection::Pointer bbtk::Factory::NewConnection | ( | BlackBox::Pointer | from, | |
const std::string & | output, | |||
BlackBox::Pointer | to, | |||
const std::string & | input | |||
) | const |
Creates an instance of a connection.
Definition at line 790 of file bbtkFactory.cxx.
References bbtkDebugMessage, and New().
00794 { 00795 bbtkDebugMessage("kernel",7,"Factory::NewConnection(\"" 00796 <<from->bbGetName()<<"\",\""<<output<<"\",\"" 00797 <<to->bbGetName()<<"\",\""<<input 00798 <<"\")"<<std::endl); 00799 00800 return Connection::New(from,output,to,input, 00801 GetThisPointer<Factory>()); 00802 }
BlackBox::Pointer bbtk::Factory::NewWidgetAdaptor | ( | const DataInfo & | typein, | |
const DataInfo & | typeout, | |||
const std::string & | name | |||
) | const |
Creates an instance of a black box of type <type> with name <name>.
Definition at line 632 of file bbtkFactory.cxx.
References bbtkDebugDecTab, bbtkDebugMessageInc, bbtkendl, bbtkError, and mPackageMap.
00635 { 00636 bbtkDebugMessageInc("kernel",8,"Factory::NewWidgetAdaptor(<" 00637 <<typein<<">,<" 00638 <<typeout<<">,\"" 00639 <<name<<"\")"<<bbtkendl); 00640 00641 00642 BlackBox::Pointer b; 00643 PackageMapType::const_iterator i; 00644 for (i = mPackageMap.begin(); i!=mPackageMap.end(); ++i ) 00645 { 00646 b = i->second->NewWidgetAdaptor(typein, 00647 typeout, 00648 name); 00649 if (b) break; 00650 } 00651 if (!b) 00652 { 00653 bbtkError("no "<<typein<<" to "<<typeout 00654 <<"> widget adaptor available"); 00655 } 00656 00657 bbtkDebugDecTab("kernel",7); 00658 return b; 00659 }
void bbtk::Factory::PrintHelpDescriptor | ( | const std::string & | name, | |
std::string & | package, | |||
bool | full = true | |||
) | const |
Prints help on a BlackBoxDescriptor.
Prints help on the black box of type <name> Returns the package to which it belongs
Definition at line 483 of file bbtkFactory.cxx.
References bbtkDebugDecTab, bbtkDebugMessageInc, bbtkError, bbtk::i, and mPackageMap.
00486 { 00487 bbtkDebugMessageInc("kernel",9,"Factory::PrintHelpDescriptor(\"" 00488 <<name<<"\")" 00489 <<std::endl); 00490 00491 bool found = false; 00492 PackageMapType::const_iterator i; 00493 for (i = mPackageMap.begin(); i!=mPackageMap.end(); ++i ) 00494 { 00495 if (i->second->ContainsDescriptor(name)) 00496 { 00497 i->second->PrintHelpDescriptor(name,full); 00498 package = i->second->GetName(); 00499 found = true; 00500 } 00501 } 00502 00503 bbtkDebugDecTab("kernel",9); 00504 if (!found) 00505 { 00506 bbtkError("No package of the factory contains any black box <" 00507 <<name<<">"); 00508 } 00509 }
void bbtk::Factory::PrintHelpListPackages | ( | bool | details = true , |
|
bool | adaptors = false | |||
) | const |
Prints the list of Package.
Definition at line 417 of file bbtkFactory.cxx.
References bbtkDebugDecTab, bbtkDebugMessageInc, bbtkMessage, bbtk::i, and mPackageMap.
00418 { 00419 bbtkDebugMessageInc("kernel",9,"Factory::PrintPackages"<<std::endl); 00420 00421 PackageMapType::const_iterator i; 00422 for (i = mPackageMap.begin(); i!=mPackageMap.end(); ++i ) 00423 { 00424 bbtkMessage("help",1, i->first << std::endl); 00425 if (details) { 00426 i->second->PrintHelpListDescriptors(false,adaptors); 00427 } 00428 } 00429 00430 bbtkDebugDecTab("kernel",9); 00431 }
void bbtk::Factory::PrintHelpPackage | ( | const std::string & | name, | |
bool | adaptors = false | |||
) | const |
Prints help on a particular Package.
Displays help on a package.
Definition at line 436 of file bbtkFactory.cxx.
References bbtkDebugDecTab, bbtkDebugMessageInc, bbtkDecTab, bbtkError, bbtkIncTab, bbtkMessage, bbtkMessageCont, bbtk::i, and mPackageMap.
00437 { 00438 bbtkDebugMessageInc("kernel",9,"Factory::PrintHelpPackage(\"" 00439 <<name<<"\")" 00440 <<std::endl); 00441 00442 PackageMapType::const_iterator i = mPackageMap.find(name); 00443 if ( i != mPackageMap.end() ) 00444 { 00445 bbtkMessage("help",1, "Package "<<i->first<<" "); 00446 00447 if (i->second->GetVersion().length()>0) 00448 bbtkMessageCont("help",1,"v" <<i->second->GetVersion()); 00449 00450 if (i->second->GetAuthor().length()>0) 00451 bbtkMessageCont("help",1,"- "<<i->second->GetAuthor()); 00452 00453 if (i->second->GetCategory().length()>0) 00454 bbtkMessageCont("help",1,"- "<<i->second->GetCategory()); 00455 00456 bbtkMessageCont("help",1,std::endl); 00457 bbtkIncTab("help",1); 00458 bbtkMessage("help",1,i->second->GetDescription()<<std::endl); 00459 if (i->second->GetNumberOfDescriptors()>0) 00460 { 00461 bbtkMessage("help",1, "Black boxes : "<<std::endl); 00462 i->second->PrintHelpListDescriptors(true,adaptors); 00463 } 00464 else 00465 { 00466 bbtkMessage("help",1, "No black boxes"<<std::endl); 00467 } 00468 bbtkDecTab("help",1); 00469 } 00470 else 00471 { 00472 bbtkDebugDecTab("kernel",9); 00473 bbtkError("package \""<<name<<"\" unknown"); 00474 } 00475 00476 bbtkDebugDecTab("kernel",9); 00477 }
void bbtk::Object::PrintObjectInfo | ( | const Pointer & | o | ) | [static, inherited] |
Definition at line 180 of file bbtkObject.cxx.
Referenced by bbtk::Object::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, inherited] |
Definition at line 105 of file bbtkObject.cxx.
References bbtk::i, bbtk::Object::mgObjectList, and bbtk::Object::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, inherited] |
Definition at line 222 of file bbtkObject.cxx.
References bbtkDebugMessage, bbtk::i, bbtk::Object::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, inherited] |
Definition at line 80 of file bbtkObject.cxx.
References bbtkDebugMessage, and bbtk::Object::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::Factory::RemovePackage | ( | Package::Pointer | p | ) |
Removess a Package from the Factory.
Removes a package from the factory (and deletes it).
Definition at line 532 of file bbtkFactory.cxx.
References bbtkDebugDecTab, bbtkDebugMessageInc, bbtkError, ClosePackage(), and mPackageMap.
00533 { 00534 bbtkDebugMessageInc("kernel",9,"Factory::RemovePackage(\""<< 00535 p->GetName()<<"\")"<<std::endl); 00536 00537 PackageMapType::iterator i; 00538 for (i = mPackageMap.begin(); i!=mPackageMap.end(); ++i ) 00539 { 00540 if (i->second == p) break; 00541 }; 00542 00543 if (i!=mPackageMap.end()) 00544 { 00545 ClosePackage(i); 00546 } 00547 else 00548 { 00549 bbtkError("Factory::RemovePackage(\""<< 00550 p->GetName()<<"\") : package absent from factory"); 00551 } 00552 00553 bbtkDebugDecTab("kernel",9); 00554 }
void bbtk::Factory::Reset | ( | ) |
Releases all the packages of the Factory.
Definition at line 88 of file bbtkFactory.cxx.
References bbtkDebugMessage, and CloseAllPackages().
00089 { 00090 bbtkDebugMessage("kernel",7,"==> Factory::Reset()"<<std::endl); 00091 CloseAllPackages(); 00092 bbtkDebugMessage("kernel",7,"<== Factory::Reset()"<<std::endl); 00093 }
void bbtk::Factory::SetExecuter | ( | ExecuterPointer | e | ) | [inline] |
Sets the executer who created the factory (if any).
Definition at line 151 of file bbtkFactory.h.
00151 { mExecuter = e; }
void bbtk::Factory::ShowGraphTypes | ( | const std::string & | name | ) | const |
Definition at line 872 of file bbtkFactory.cxx.
References bbtkDebugDecTab, bbtkError, bbtk::ConfigurationFile::Get_default_temp_dir(), bbtk::ConfigurationFile::Get_file_separator(), bbtk::ConfigurationFile::GetInstance(), and mPackageMap.
00873 { 00874 bool found = false; 00875 PackageMapType::const_iterator i; 00876 for (i = mPackageMap.begin(); i!=mPackageMap.end(); ++i ) 00877 { 00878 if (i->second->ContainsDescriptor(name)) 00879 { 00880 std::string separator = ConfigurationFile::GetInstance().Get_file_separator (); 00881 00882 // Don't pollute the file store with "temp_dir" directories ... 00883 std::string default_doc_dir = ConfigurationFile::GetInstance().Get_default_temp_dir(); 00884 std::string directory = "\"" + default_doc_dir + separator + "temp_dir" +separator + "\""; 00885 std::string filename2 = default_doc_dir + separator + "temp_dir" + separator + "tmp.html"; 00886 00887 #if defined(_WIN32) 00888 std::string command("start \"Titre\" /D "); 00889 #else 00890 std::string command("gnome-open "); 00891 #endif 00892 command=command + directory +" tmp.html"; 00893 FILE *ff; 00894 ff=fopen(filename2.c_str(),"w"); 00895 00896 fprintf(ff,"<html><head><title>TMP</title> <script type=\"text/javascript\"> <!--\n"); 00897 fprintf(ff," window.location=\"%s#%s\";\n" , i->second->GetDocURL().c_str(),name.c_str() ); 00898 fprintf(ff,"//--></script></head><body></body></html>\n"); 00899 00900 00901 //fprintf(ff, "<a href=\"%s#%s\">Link</a>\n", i->second->GetDocURL().c_str(),name.c_str() ); 00902 fclose(ff); 00903 system( command.c_str() ); 00904 found = true; 00905 } 00906 } 00907 00908 bbtkDebugDecTab("kernel",9); 00909 if (!found) 00910 { 00911 bbtkError("No package of the factory contains any black box <" 00912 <<name<<">"); 00913 } 00914 }
void bbtk::Factory::UnLoadPackage | ( | const std::string & | name | ) |
Unloads a Package which was loaded from a dynamic library.
UnLoads a package.
The package must have been previously loaded by LoadPackage. If the entry is found in the map, calls ClosePackage
Definition at line 330 of file bbtkFactory.cxx.
References bbtkDebugDecTab, bbtkDebugMessageInc, bbtkError, ClosePackage(), bbtk::i, and mPackageMap.
00331 { 00332 bbtkDebugMessageInc("kernel",7,"Factory::UnLoadPackage(\"" 00333 <<name<<"\")"<<std::endl); 00334 00335 PackageMapType::iterator i; 00336 i = mPackageMap.find(name); 00337 if (i == mPackageMap.end()) 00338 { 00339 bbtkError("cannot unload package \""<<name 00340 <<"\" : package not loaded !"); 00341 } 00342 ClosePackage(i); 00343 bbtkDebugDecTab("kernel",7); 00344 }
void bbtk::Object::UnLockThis | ( | ) | [inline, protected, inherited] |
void bbtk::Factory::WriteDotFilePackagesList | ( | FILE * | ff | ) |
Definition at line 846 of file bbtkFactory.cxx.
References bbtkDebugDecTab, bbtkDebugMessageInc, GetPackage(), and mPackageMap.
00847 { 00848 00849 bbtkDebugMessageInc("kernel",9,"Factory::WriteDotFilePackagesList()" 00850 <<std::endl); 00851 00852 fprintf( ff , "\n"); 00853 fprintf( ff , "subgraph cluster_FACTORY {\n"); 00854 fprintf( ff , " label = \"PACKAGES\"%s\n", ";"); 00855 fprintf( ff , " style=filled%s\n",";"); 00856 fprintf( ff , " color=lightgrey%s\n",";"); 00857 fprintf( ff , " rankdir=TB%s\n",";"); 00858 00859 std::string url; 00860 PackageMapType::const_iterator i; 00861 for (i = mPackageMap.begin(); i!=mPackageMap.end(); ++i ) 00862 { 00863 url=GetPackage(i->first)->GetDocURL(); 00864 fprintf(ff," %s [shape=ellipse, URL=\"%s\"]%s\n",i->first.c_str(),url.c_str(),";" ); 00865 } 00866 fprintf( ff , "}\n\n"); 00867 bbtkDebugDecTab("kernel",9); 00868 }
friend struct Object::Deleter [friend] |
Definition at line 55 of file bbtkFactory.h.
ExecuterWeakPointer bbtk::Factory::mExecuter [private] |
PackageMapType bbtk::Factory::mPackageMap [private] |
The map of packages.
Definition at line 164 of file bbtkFactory.h.
Referenced by Check(), CloseAllPackages(), ClosePackage(), CreateHtmlIndex(), DoLoadPackage(), FindAdaptor(), FindWidgetAdaptor(), FindWidgetAdaptor2(), GetObjectRecursiveSize(), GetPackage(), GetPackageNameOfaBlackBox(), InsertPackage(), LoadPackage(), NewAdaptor(), NewBlackBox(), NewWidgetAdaptor(), PrintHelpDescriptor(), PrintHelpListPackages(), PrintHelpPackage(), RemovePackage(), ShowGraphTypes(), UnLoadPackage(), and WriteDotFilePackagesList().