#include <bbtkPackage.h>
Classes | |
class | AdaptorKey |
The type of key in the map of adaptor descriptors. More... | |
Public Types | |
typedef Package | Self |
typedef boost::shared_ptr< Self > | Pointer |
typedef boost::weak_ptr< Self > | WeakPointer |
typedef std::map< std::string, BlackBoxDescriptor::Pointer > | DescriptorMapType |
The type of map of descriptors. | |
typedef std::map< AdaptorKey, BlackBoxDescriptor::WeakPointer > | AdaptorMapType |
The type of map of adaptor descriptors. | |
typedef std::set < FactoryWeakPointer > | FactorySet |
typedef Package::Pointer(* | DLGetPackageFunction )() |
typedef void(* | DLDeletePackageFunction )() |
typedef const std::string &(* | DLGetPackageBBTKVersionFunction )() |
Public Member Functions | |
std::string | GetObjectName () const |
std::string | GetObjectInfo () const |
size_t | GetObjectSize () const |
size_t | GetObjectInternalSize () const |
size_t | GetObjectRecursiveSize () const |
bool | Register (BlackBoxDescriptor::Pointer) |
Registers the BlackBoxDescriptor in the Package. | |
const std::string & | GetName () const |
Returns the name of the package. | |
const std::string & | GetAuthor () const |
Returns the author of the package. | |
const std::string & | GetCategory () const |
Returns the category of the package. | |
const std::string & | GetDescription () const |
Returns the description of the package. | |
const std::string & | GetVersion () const |
Returns the version of the package. | |
bool | ContainsDescriptor (const std::string &name) const |
Returns true iff the package contains the box of name boxname. | |
BlackBox::Pointer | NewBlackBox (const std::string &type, const std::string &name) const |
Creates a new BlackBox of given type with name name. | |
BlackBox::Pointer | NewAdaptor (const DataInfo &typein, const DataInfo &typeout, const std::string &name) const |
BlackBox::Pointer | NewWidgetAdaptor (const DataInfo &typein, const DataInfo &typeout, const std::string &name) const |
bool | FindAdaptor (const DataInfo &typein, const DataInfo &typeout, std::string &adaptor) const |
bool | FindWidgetAdaptor (const DataInfo &typein, const DataInfo &typeout, std::string &adaptor) const |
void | PrintHelpListDescriptors (bool description=false, bool adaptors=false) const |
Displays the list of black box descriptors of the package. | |
void | PrintHelpListAdaptors (bool description=false) const |
Displays the list of adaptors of the package. | |
void | PrintHelpDescriptor (const std::string &name, bool full=true) const |
Prints help on a particular Descriptor. | |
void | CreateHtmlPage (const std::string &filename, const std::string &caller="?", const std::string &source="?", const std::string &custom_header="", const std::string &custom_title="", int detail=1, int level=0, bool relative_link=false) const |
void | SetDocURL (std::string url) |
const std::string & | GetDocURL () const |
void | SetDocRelativeURL (std::string url) |
const std::string & | GetDocRelativeURL () const |
unsigned int | GetNumberOfDescriptors () const |
void | ChangeDescriptorName (const std::string &oldname, const std::string &newname) |
Changes the name of a descriptor. | |
const DescriptorMapType & | GetDescriptorMap () const |
DescriptorMapType & | GetDescriptorMap () |
const AdaptorMapType & | GetAdaptorMap () const |
void | AddFactory (FactoryPointer f) |
Adds the factory to the set of factories which use the package. | |
void | RemoveFactory (FactoryPointer f) |
Removes the factory from the set of factories which use the package. | |
FactorySet & | GetFactorySet () |
Gets the set of factories which use the package. | |
const FactorySet & | GetFactorySet () const |
Gets the set of factories which use the package (const). | |
void | Check () const |
bool | ifBoxExist (std::string boxType) |
long | GetUseCount () |
Static Public Member Functions | |
static Pointer | New (const std::string &name, const std::string &author, const std::string &description, const std::string &version) |
Creates a new package. | |
static Pointer | CreateFromDynamicLibrary (const std::string &libname, const std::string &pkgname, const std::string &path) |
Creates a package from a dynamic library. | |
static void | UnLoadDynamicLibrary (Package::WeakPointer p, bool doit=true) |
UnLoads the package dynamic library (if any). | |
static void | UnLoadReleasedDynamicallyLoadedPackages () |
static void | Release (Package::WeakPointer p) |
Release. | |
static void | ReleaseBlackBoxDescriptor (Package::WeakPointer p, BlackBoxDescriptor::WeakPointer d) |
static DynamicLibraryHandler | OpenDynamicLibrary (const std::string &dynamic_library_path, const std::string &package_name, DLGetPackageFunction &, DLDeletePackageFunction &) |
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 | |
Package () | |
Package (const Package &) | |
~Package () | |
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 | |
Package (const std::string &name, const std::string &author, const std::string &description, const std::string &version) | |
Default ctor is private : use the static New method. | |
Static Private Member Functions | |
static void | UnLoad (Package::WeakPointer p) |
Does unload a package (no test). | |
Private Attributes | |
DynamicLibraryHandler | mDynamicLibraryHandler |
The dynamic library handler of the package if it was loaded from a dl. | |
DLDeletePackageFunction | mDLDeletePackageFunction |
std::string | mName |
The name of the package. | |
std::string | mAuthor |
The author of the package. | |
std::string | mCategory |
The categories of the package. | |
std::string | mDescription |
The description of the package. | |
std::string | mVersion |
The version of the package. | |
std::string | mDocURL |
URL of the documentation of the Package (absolute path). | |
std::string | mDocRelativeURL |
DescriptorMapType | mDescriptorMap |
The map of black boxes descriptors. | |
AdaptorMapType | mAdaptorMap |
The map of adaptors descriptors. | |
FactorySet | mFactorySet |
The set of factories which contain the package. | |
Static Private Attributes | |
static std::set < Package::WeakPointer > | mReleasedDynamicallyLoadedPackages |
Friends | |
struct | Object::Deleter |
Definition at line 52 of file bbtkPackage.h.
typedef std::map< AdaptorKey, BlackBoxDescriptor::WeakPointer> bbtk::Package::AdaptorMapType |
typedef std::map< std::string, BlackBoxDescriptor::Pointer> bbtk::Package::DescriptorMapType |
typedef void(* bbtk::Package::DLDeletePackageFunction)() |
typedef const std::string&(* bbtk::Package::DLGetPackageBBTKVersionFunction)() |
typedef Package::Pointer(* bbtk::Package::DLGetPackageFunction)() |
typedef std::set<FactoryWeakPointer> bbtk::Package::FactorySet |
Definition at line 250 of file bbtkPackage.h.
typedef boost::shared_ptr<Self> bbtk::Package::Pointer |
typedef Package bbtk::Package::Self |
Definition at line 54 of file bbtkPackage.h.
typedef Object bbtk::Package::Superclass [protected] |
Definition at line 54 of file bbtkPackage.h.
typedef boost::weak_ptr<Self> bbtk::Package::WeakPointer |
bbtk::Package::Package | ( | ) | [protected] |
bbtk::Package::Package | ( | const Package & | ) | [protected] |
bbtk::Package::~Package | ( | ) | [protected] |
Dtor.
Definition at line 113 of file bbtkPackage.cxx.
References bbtkDebugMessage, bbtkendl, and mName.
00114 { 00115 bbtkDebugMessage("object",2,"==> ~Package(\""<<mName<<"\")"<<bbtkendl); 00116 }
bbtk::Package::Package | ( | const std::string & | name, | |
const std::string & | author, | |||
const std::string & | description, | |||
const std::string & | version | |||
) | [private] |
Default ctor is private : use the static New method.
Ctor with the name of the package.
A Package cannot be copy constructed Ctor is private : use the static New method
Definition at line 70 of file bbtkPackage.cxx.
References bbtkDebugMessage, bbtkendl, bbtk::ConfigurationFile::Get_default_temp_dir(), bbtk::ConfigurationFile::GetInstance(), SetDocRelativeURL(), and SetDocURL().
00074 : 00075 mDynamicLibraryHandler(0), 00076 mName(name), 00077 mAuthor(author), 00078 mDescription(description), 00079 mVersion(version) 00080 { 00081 bbtkDebugMessage("object",2,"==> Package('"<<name<<"',...)" 00082 <<bbtkendl); 00083 std::string default_doc_dir = ConfigurationFile::GetInstance().Get_default_temp_dir(); 00084 char c = default_doc_dir.c_str()[strlen(default_doc_dir.c_str())-1]; 00085 std::string url = default_doc_dir; 00086 if (c != '/' && c !='\\') url = url + "/"; 00087 url = url + "temp_dir/" + name + "/index.html"; 00088 00089 SetDocURL(url); 00090 SetDocRelativeURL("Relative url not set"); 00091 00092 /* 00093 std::string relurl(BBTK_STRINGIFY_SYMBOL(BBTK_DOC_REL_PATH)); 00094 relurl += "/packages/"+name+"/bbdoc/index.html"; 00095 std::string url = ConfigurationFile::GetInstance().Get_url() 00096 + relurl; 00097 SetDocURL(url); 00098 SetDocRelativeURL(relurl); 00099 */ 00100 00101 // std::cout << " url=["<<url<<"]"<<std::endl; 00102 // std::cout << "relurl=["<<relurl<<"]"<<std::endl; 00103 bbtkDebugMessage("object",2,"<== Package::Package('"<<name<<"',...) OK" 00104 <<bbtkendl); 00105 00106 } //==========================================================================
void bbtk::Package::AddFactory | ( | FactoryPointer | f | ) | [inline] |
Adds the factory to the set of factories which use the package.
Definition at line 245 of file bbtkPackage.h.
00245 { mFactorySet.insert(f); }
void bbtk::Package::ChangeDescriptorName | ( | const std::string & | oldname, | |
const std::string & | newname | |||
) |
Changes the name of a descriptor.
Changes the name of a black box type.
Definition at line 941 of file bbtkPackage.cxx.
References bbtkDebugDecTab, bbtkDebugMessageInc, bbtkError, GetName(), bbtk::i, and mDescriptorMap.
00942 { 00943 bbtkDebugMessageInc("kernel",8,"Package<"<<GetName() 00944 <<">::ChangeDescriptorName(\""<<oldname 00945 <<"\",\""<<newname<<"\")"<<std::endl); 00946 // Looking into the bb map 00947 DescriptorMapType::iterator i = mDescriptorMap.find(oldname); 00948 if (i == mDescriptorMap.end()) 00949 { 00950 bbtkDebugDecTab("kernel",8); 00951 bbtkError("ChangeDescriptorName : The package <"<<GetName()<<"> does not contains the black box <"<<oldname<<">"); 00952 } 00953 00954 i->second->SetTypeName(newname); 00955 mDescriptorMap[newname] = i->second; 00956 mDescriptorMap.erase(i); 00957 00958 bbtkDebugDecTab("kernel",8); 00959 }
void bbtk::Package::Check | ( | ) | const |
Definition at line 922 of file bbtkPackage.cxx.
References bbtkMessage, GetName(), bbtk::i, and mDescriptorMap.
00923 { 00924 bbtkMessage("debug",1,"****** Checking Package "<<(void*)this 00925 <<" ["<<GetName()<<"]"<<std::endl); 00926 DescriptorMapType::const_iterator i; 00927 for (i=mDescriptorMap.begin(); 00928 i!=mDescriptorMap.end(); 00929 ++i) 00930 { 00931 i->second->Check(true); 00932 } 00933 bbtkMessage("debug",1,"****** Checking Package "<<(void*)this 00934 <<" ["<<GetName()<<"] ... OK"<<std::endl); 00935 }
bool bbtk::Package::ContainsDescriptor | ( | const std::string & | name | ) | const |
Returns true iff the package contains the box of name boxname.
Returns true iff the package contains a BlackBoxDescriptor with the name provided
Definition at line 1106 of file bbtkPackage.cxx.
References bbtkDebugDecTab, bbtkDebugMessageInc, bbtkendl, GetName(), bbtk::i, and mDescriptorMap.
01107 { 01108 bbtkDebugMessageInc("kernel",8,"Package<"<<GetName() 01109 <<">::ContainsDescriptor(\"" 01110 <<name<<"\")"<<bbtkendl); 01111 01112 DescriptorMapType::const_iterator i = mDescriptorMap.find(name); 01113 if (i == mDescriptorMap.end()) 01114 { 01115 bbtkDebugDecTab("kernel",8); 01116 return false; 01117 } 01118 bbtkDebugDecTab("kernel",8); 01119 return true; 01120 }
Package::Pointer bbtk::Package::CreateFromDynamicLibrary | ( | const std::string & | libname, | |
const std::string & | pkgname, | |||
const std::string & | path | |||
) | [static] |
Creates a package from a dynamic library.
Loads a package from a dynamic library.
Definition at line 531 of file bbtkPackage.cxx.
References BBTK_STRINGIFY_SYMBOL, bbtkDebugMessage, bbtk::ConfigurationFile::Get_file_separator(), bbtk::ConfigurationFile::GetInstance(), and OpenDynamicLibrary().
Referenced by bbtk::Factory::DoLoadPackage().
00534 { 00535 bbtkDebugMessage("package",1,"==> Package::CreateFromDynamicLibrary(" 00536 <<libname<<")"<<std::endl); 00537 00538 DLGetPackageFunction gf; 00539 DLDeletePackageFunction df; 00540 DynamicLibraryHandler h = Package::OpenDynamicLibrary(libname, 00541 pkgname, 00542 gf,df); 00543 if (h==0) return Package::Pointer(); 00544 Package::Pointer p = gf(); 00545 p->mDynamicLibraryHandler = h; 00546 p->mDLDeletePackageFunction = df; 00547 00548 std::string separator = 00549 ConfigurationFile::GetInstance().Get_file_separator (); 00550 //BBTK_STRINGIFY_SYMBOL(BBTK_DOC_REL_PATH) 00551 std::string docreldoc = 00552 separator + "bbdoc" + separator + pkgname + separator + "index.html"; 00553 std::string reldoc = 00554 ".." + separator + ".." + docreldoc; 00555 std::string doc = path + separator + ".." + separator 00556 + BBTK_STRINGIFY_SYMBOL(BBTK_DOC_REL_PATH) 00557 + docreldoc; 00558 00559 p->SetDocURL(doc); 00560 p->SetDocRelativeURL(reldoc); 00561 00562 bbtkDebugMessage("package",2,"<== Package::CreateFromDynamicLibrary(" 00563 <<libname<<") .. OK"<<std::endl); 00564 return p; 00565 }
void bbtk::Package::CreateHtmlPage | ( | const std::string & | filename, | |
const std::string & | caller = "?" , |
|||
const std::string & | source = "?" , |
|||
const std::string & | custom_header = "" , |
|||
const std::string & | custom_title = "" , |
|||
int | detail = 1 , |
|||
int | level = 0 , |
|||
bool | relative_link = false | |||
) | const |
Definition at line 1126 of file bbtkPackage.cxx.
References bbtkDebugDecTab, bbtkDebugMessageInc, bbtkendl, bbtkError, GetAuthor(), GetCategory(), GetDescription(), GetName(), GetVersion(), bbtk::Utilities::html_format(), bbtk::i, mAdaptorMap, mDescriptorMap, and bbtk::BlackBoxDescriptor::STANDARD.
01134 { 01135 bbtkDebugMessageInc("kernel",9,"Package<"<<GetName()<<">::CreateHtmlPage(\"" 01136 <<filename<<"\")"<<bbtkendl); 01137 01138 //std::cout<<"JCP bbtkPackage.cxx void Package::CreateHtmlPage() ln 1133"<<std::endl; 01139 01140 //--------------------- 01141 // Open output file 01142 std::ofstream s; 01143 s.open(filename.c_str()); 01144 if (!s.good()) 01145 { 01146 bbtkError("Package "<<GetName()<<" : CreateHtmlPage : could not open file '"<<filename<<"'"); 01147 } 01148 01149 //---------------------- 01150 // Html head 01151 std::string title = "BBTK Package "+GetName()+" "+GetVersion(); 01152 01153 if (custom_title.length() != 0) title = custom_title; 01154 01155 s << "<html lang=\"en\">\n"; 01156 s << "<head>\n"; 01157 s << "<title>" << title << "</title>\n"; 01158 s << "<meta http-equiv=\"Content-Type\" content=\"text/html\">\n"; 01159 s << "<meta name=\"description\" content=\""<<title<<"\">\n"; 01160 s << "<meta name=\"generator\" content=\"\">\n"; 01161 s << "<link title=\"Top\" rel=\"top\" href=\"#Top\">\n"; 01162 //<link href="http://www.gnu.org/software/texinfo/" rel="generator-home" title="Texinfo Homepage"> 01163 s << "<meta http-equiv=\"Content-Style-Type\" content=\"text/css\"><style type=\"text/css\"><!--\n"; 01164 s << "pre.display { font-family:inherit }\n"; 01165 s << "pre.format { font-family:inherit }\n"; 01166 s << "pre.smalldisplay { font-family:inherit; font-size:smaller }\n"; 01167 s << "pre.smallformat { font-family:inherit; font-size:smaller }\n"; 01168 s << "pre.smallexample { font-size:smaller }\n"; 01169 s << "pre.smalllisp { font-size:smaller }\n"; 01170 s << "span.sc { font-variant:small-caps }\n"; 01171 s << "span.roman { font-family:serif; font-weight:normal; } \n"; 01172 s << "span.sansserif { font-family:sans-serif; font-weight:normal; }\n"; 01173 s << "--></style>\n"; 01174 s << "</head>\n"; 01175 //---------------------- 01176 01177 //---------------------- 01178 // Html body 01179 s << "<body>\n"; 01180 s << "<a name=\"Top\"></a>\n"; 01181 01182 //---------------------- 01183 // Header 01184 if ( custom_header.length() != 0) 01185 { 01186 if ( custom_header != "none" ) 01187 { 01188 std::ifstream in; 01189 in.open(custom_header.c_str()); 01190 if (!in.good()) 01191 { 01192 bbtkError("Could not open file \""<<custom_header<<"\""); 01193 } 01194 char buffer[512]; 01195 while (!in.eof()) 01196 { 01197 in.getline(buffer,512); 01198 std::string line(buffer); 01199 s << line; 01200 } 01201 in.close(); 01202 s << "<hr>\n"; 01203 01204 /* 01205 s << "<object data=\"" << custom_header 01206 << "\" type = \"text/html\"\"style=\"width: 1200px; height: 400px;\"> Warning: " 01207 << custom_header <<" could not be embedded.</object>\n"; 01208 01209 s << "<hr>\n"; 01210 */ 01211 } 01212 } 01213 01214 else 01215 { 01216 s << "<h1 class=\"settitle\">"<<title<<"</h1>\n"; 01217 s << "<p><TABLE cellspacing=0 cellpadding=3>\n"; 01218 s << "<TR><TD style='vertical-align: top;'><b> Description </b></TD><TD style='vertical-align: top;'> : </TD><TD style='vertical-align: top;'> " 01219 << GetDescription() << "</TD></TR>\n"; 01220 s << "<TR><TD style='vertical-align: top;'><b> Author(s) </b></TD><TD style='vertical-align: top;'> : </TD><TD style='vertical-align: top;'> " 01221 << GetAuthor() << "</TD></TR>\n"; 01222 s << "<TR><TD style='vertical-align: top;'><b> Author(s) </b></TD><TD style='vertical-align: top;'> : </TD><TD style='vertical-align: top;'> " 01223 << GetCategory() << "</TD></TR>\n"; 01224 s << "<TR><TD style='vertical-align: top;'><b> Version </b></TD><TD style='vertical-align: top;'> : </TD><TD style='vertical-align: top;'> " 01225 << GetVersion() << "</TD></TR>\n"; 01226 s << "<TR><TD style='vertical-align: top;'><b> bbtk Version </b></TD><TD style='vertical-align: top;'> : </TD><TD style='vertical-align: top;'> " 01227 << bbtk::GetVersion() << "</TD></TR>\n"; 01228 s << "</TABLE>\n"; 01229 } 01230 //std::cout<<"JCP bbtkPackage.cxx void Package::CreateHtmlPage() ln 1225"<<std::endl; 01231 //------------------- 01232 // Table of contents 01233 // Black boxes list 01234 // s << "<div class=\"contents\">\n"; 01235 s << "<p><b> Black Boxes : </b>\n"; 01236 s << "<ul>\n"; 01237 01238 s << "<p><TABLE cellspacing=0 cellpadding=3>\n"; 01239 01240 DescriptorMapType::const_iterator i; 01241 //std::cout<<"JCP bbtkPackage.cxx void Package::CreateHtmlPage() ln 1236"<<std::endl; 01242 for (i=mDescriptorMap.begin(); i!=mDescriptorMap.end(); ++i) { 01243 if ( i->second->GetKind() != BlackBoxDescriptor::STANDARD) 01244 continue; 01245 01246 std::string name = i->second->GetTypeName(); 01247 Utilities::html_format(name); 01248 std::string descr = i->second->GetDescription(); 01249 //Utilities::html_format(descr); 01250 //std::cout<<"JCP bbtkPackage.cxx void Package::CreateHtmlPage() ln 1246"<<std::endl; 01251 s << "<TR>"; 01252 s << "<TD style='vertical-align: top;'>"; 01253 s << " <a name=\"toc_"<<name 01254 <<"\" href=\"#"<<name<<"\">" 01255 <<name<<"</a>"; 01256 s << "</TD> "; 01257 s << " <TD style='vertical-align: top;'>" << descr << " </TD>"; 01258 s << "</TR>\n"; 01259 } 01260 s << "</TABLE>\n"; 01261 01262 01263 s << "</ul>\n"; 01264 s << "</div>\n"; 01265 01266 //------------------- 01267 // Adaptors list 01268 if (mAdaptorMap.size()>0) 01269 { 01270 // s << "<div class=\"contents\">\n"; 01271 s << "<p><b> Adaptors : </b>\n"; 01272 s << "<ul>\n"; 01273 //std::cout<<"JCP bbtkPackage.cxx void Package::CreateHtmlPage() ln 1268"<<std::endl; 01274 // DescriptorMapType::const_iterator i; 01275 s << "<p><TABLE cellspacing=0 cellpadding=3>\n"; 01276 for (i=mDescriptorMap.begin(); i!=mDescriptorMap.end();++i) 01277 { 01278 if ( i->second->GetKind() == BlackBoxDescriptor::STANDARD) 01279 continue; 01280 01281 std::string name = i->second->GetTypeName(); 01282 Utilities::html_format(name); 01283 std::string descr = i->second->GetDescription(); 01284 01285 s << "<TR>"; 01286 s << "<TD style='vertical-align: top;'>"; 01287 s << " <a name=\"toc_"<<name 01288 <<"\" href=\"#"<<name<<"\">" 01289 <<name<<"</a>"; 01290 s << "</TD> "; 01291 s << " <TD style='vertical-align: top;'>" << descr << " </TD>"; 01292 s << "</TR>\n"; 01293 } 01294 s << "</TABLE>\n"; 01295 01296 s << "</ul>\n"; 01297 s << "</div>\n"; 01298 } 01299 01300 01301 // s << "<div class=\"node\">\n"; 01302 01303 // s << "<p><hr>\n"; 01304 // s << "<a name=\"Top\"></a>\n"; 01305 // s << "Top: <a rel=\"top\" accesskey=\"t\" href=\"#Top\">Top</a>\n"; 01306 // s << "Previous: <a rel="previous" accesskey="p" href="#dir">(dir)</a>, 01307 // s << "Up: <a rel="up" accesskey="u" href="#dir">(dir)</a> 01308 01309 // s << "</div>\n"; 01310 01311 //---------------------- 01312 // Boxes doc 01313 01314 //------------------- 01315 // Computes output directory from filename to pass it to 01316 // BlackBoxDescriptor::InsertHtmlHelp 01317 std::string dir; 01318 01319 std::string::size_type slash_position = filename.find_last_of("/\\"); 01320 01321 01322 if (slash_position != std::string::npos) { 01323 if (slash_position == 0) 01324 slash_position = 1; 01325 dir = filename.substr(0,slash_position); 01326 } 01327 01328 for (i=mDescriptorMap.begin(); 01329 i!=mDescriptorMap.end(); 01330 ++i) 01331 { 01332 i->second->InsertHtmlHelp(s,detail,level,dir,relative_link); 01333 } 01334 01335 //---------------------- 01336 // Footer 01337 time_t rawtime; 01338 tm * ptm; 01339 time ( &rawtime ); 01340 ptm = gmtime ( &rawtime ); 01341 01342 s << "<p><hr>\n"; 01343 s << "Automatically generated by <b>"<<caller<<"</b> "//from <b>" 01344 // <<source<<"</b> 01345 <<"on " 01346 << ptm->tm_mday << "/" << ptm->tm_mon << "/" << ptm->tm_year+1900 01347 << " - " << ptm->tm_hour << ":" << ptm->tm_min << " GMT\n"; 01348 s << "</body></html>\n"; 01349 s.close(); 01350 //---------------------- 01351 01352 // End 01353 bbtkDebugDecTab("kernel",9); 01354 }
bool bbtk::Package::FindAdaptor | ( | const DataInfo & | typein, | |
const DataInfo & | typeout, | |||
std::string & | adaptor | |||
) | const |
Returns true is the package contains an adaptor of input type <typein> and output type <typeout> If successfull then adaptor contains the black box type name
Definition at line 811 of file bbtkPackage.cxx.
References bbtkDebugDecTab, bbtkDebugMessageInc, bbtkendl, bbtk::BlackBoxDescriptor::DEFAULT_ADAPTOR, GetName(), bbtk::i, and mAdaptorMap.
00814 { 00815 bbtkDebugMessageInc("kernel",8,"Package<"<<GetName()<< 00816 ">::FindAdaptor(" 00817 <<typein<<"," 00818 <<typeout<<")"<<bbtkendl); 00819 00820 AdaptorKey key(typein,typeout, 00821 BlackBoxDescriptor::DEFAULT_ADAPTOR); 00822 AdaptorMapType::const_iterator i = mAdaptorMap.find(key); 00823 if (i == mAdaptorMap.end()) 00824 { 00825 bbtkDebugDecTab("kernel",8); 00826 return false; 00827 } 00828 adaptor = i->second.lock()->GetTypeName(); 00829 bbtkDebugDecTab("kernel",8); 00830 return true; 00831 00832 }
bool bbtk::Package::FindWidgetAdaptor | ( | const DataInfo & | typein, | |
const DataInfo & | typeout, | |||
std::string & | adaptor | |||
) | const |
Returns true is the package contains an adaptor of input type <typein> and output type <typeout> If successfull then adaptor contains the black box type name
Definition at line 777 of file bbtkPackage.cxx.
References bbtkDebugDecTab, bbtkDebugMessageInc, bbtkendl, bbtk::BlackBoxDescriptor::DEFAULT_GUI, GetName(), bbtk::i, and mAdaptorMap.
00780 { 00781 bbtkDebugMessageInc("kernel",8,"Package<"<<GetName()<< 00782 ">::FindWidgetAdaptor(" 00783 <<typein<<"," 00784 <<typeout<<")"<<bbtkendl); 00785 00786 AdaptorKey key(/*typein*/ 00787 DataInfo(typeid(void),""), 00788 typeout, 00789 BlackBoxDescriptor::DEFAULT_GUI); 00790 // First try to find a single widget adaptor 00791 AdaptorMapType::const_iterator i = mAdaptorMap.find(key); 00792 if (i == mAdaptorMap.end()) 00793 { 00794 bbtkDebugDecTab("kernel",8); 00795 return false; 00796 } 00797 adaptor = i->second.lock()->GetTypeName(); 00798 bbtkDebugDecTab("kernel",8); 00799 return true; 00800 00801 }
const AdaptorMapType& bbtk::Package::GetAdaptorMap | ( | ) | const [inline] |
const std::string& bbtk::Package::GetAuthor | ( | ) | const [inline] |
Returns the author of the package.
Definition at line 132 of file bbtkPackage.h.
Referenced by CreateHtmlPage().
00132 { return mAuthor; }
const std::string& bbtk::Package::GetCategory | ( | ) | const [inline] |
Returns the category of the package.
Definition at line 135 of file bbtkPackage.h.
Referenced by CreateHtmlPage().
00135 { return mCategory; }
const std::string& bbtk::Package::GetDescription | ( | ) | const [inline] |
Returns the description of the package.
Definition at line 138 of file bbtkPackage.h.
Referenced by CreateHtmlPage().
00138 { return mDescription; }
DescriptorMapType& bbtk::Package::GetDescriptorMap | ( | ) | [inline] |
const DescriptorMapType& bbtk::Package::GetDescriptorMap | ( | ) | const [inline] |
const std::string& bbtk::Package::GetDocRelativeURL | ( | ) | const [inline] |
const std::string& bbtk::Package::GetDocURL | ( | ) | const [inline] |
const FactorySet& bbtk::Package::GetFactorySet | ( | ) | const [inline] |
Gets the set of factories which use the package (const).
Definition at line 254 of file bbtkPackage.h.
00254 { return mFactorySet; }
FactorySet& bbtk::Package::GetFactorySet | ( | ) | [inline] |
Gets the set of factories which use the package.
Definition at line 252 of file bbtkPackage.h.
00252 { return mFactorySet; }
const std::string& bbtk::Package::GetName | ( | ) | const [inline] |
Returns the name of the package.
Definition at line 129 of file bbtkPackage.h.
Referenced by ChangeDescriptorName(), Check(), ContainsDescriptor(), CreateHtmlPage(), FindAdaptor(), FindWidgetAdaptor(), NewAdaptor(), NewBlackBox(), NewWidgetAdaptor(), PrintHelpDescriptor(), and Register().
00129 { return mName; }
unsigned int bbtk::Package::GetNumberOfDescriptors | ( | ) | const [inline] |
std::string bbtk::Package::GetObjectInfo | ( | ) | const [virtual] |
Reimplemented from bbtk::Object.
Definition at line 1365 of file bbtkPackage.cxx.
References bbtk::i, mDescriptorMap, and mDynamicLibraryHandler.
01366 { 01367 std::stringstream i; 01368 i << " - "<<mDescriptorMap.size() << " boxes" << std::endl; 01369 if (mDynamicLibraryHandler) 01370 { 01371 i<< " - Loaded from dynamic library"<<std::endl; 01372 } 01373 return i.str(); 01374 }
size_t bbtk::Package::GetObjectInternalSize | ( | ) | const [virtual] |
Reimplemented from bbtk::Object.
Definition at line 1387 of file bbtkPackage.cxx.
Referenced by GetObjectRecursiveSize(), and GetObjectSize().
01388 { 01389 size_t s = sizeof(Package); 01390 return s; 01391 }
std::string bbtk::Package::GetObjectName | ( | ) | const [virtual] |
Reimplemented from bbtk::Object.
Definition at line 1358 of file bbtkPackage.cxx.
References mName.
01359 { 01360 return std::string("Package '")+mName+std::string("'"); 01361 }
size_t bbtk::Package::GetObjectRecursiveSize | ( | ) | const [virtual] |
Reimplemented from bbtk::Object.
Definition at line 1394 of file bbtkPackage.cxx.
References GetObjectInternalSize(), bbtk::Object::GetObjectRecursiveSize(), bbtk::i, and mDescriptorMap.
01395 { 01396 size_t s = Superclass::GetObjectRecursiveSize(); 01397 s += Package::GetObjectInternalSize(); 01398 01399 DescriptorMapType::const_iterator i; 01400 for (i = mDescriptorMap.begin(); i!=mDescriptorMap.end(); ++i ) 01401 { 01402 s += i->second->GetObjectRecursiveSize(); 01403 } 01404 return s; 01405 }
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::Package::GetObjectSize | ( | ) | const [virtual] |
Reimplemented from bbtk::Object.
Definition at line 1379 of file bbtkPackage.cxx.
References GetObjectInternalSize(), and bbtk::Object::GetObjectSize().
01380 { 01381 size_t s = Superclass::GetObjectSize(); 01382 s += Package::GetObjectInternalSize(); 01383 return s; 01384 }
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] |
const std::string& bbtk::Package::GetVersion | ( | ) | const [inline] |
Returns the version of the package.
Definition at line 141 of file bbtkPackage.h.
Referenced by CreateHtmlPage().
00141 { return mVersion; }
bool bbtk::Package::ifBoxExist | ( | std::string | boxType | ) |
Definition at line 681 of file bbtkPackage.cxx.
References bbtk::i, and mDescriptorMap.
00682 { 00683 bool ok=false; 00684 DescriptorMapType::const_iterator i = mDescriptorMap.find(type); 00685 if (i != mDescriptorMap.end()) 00686 { 00687 ok=true; 00688 } 00689 return ok; 00690 }
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::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(), 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 }
Package::Pointer bbtk::Package::New | ( | const std::string & | name, | |
const std::string & | author, | |||
const std::string & | description, | |||
const std::string & | version | |||
) | [static] |
Creates a new package.
Definition at line 51 of file bbtkPackage.cxx.
References bbtkDebugMessage, bbtkendl, bbtk::Object::MakePointer(), and Package().
00055 { 00056 bbtkDebugMessage("object",1,"##> Package::New('"<<name<<"',...)" 00057 <<bbtkendl); 00058 Package::Pointer p = MakePointer(new Package(name, 00059 author, 00060 description, 00061 version)); 00062 bbtkDebugMessage("object",2,"<## Package::New('"<<name<<"',...)" 00063 <<bbtkendl); 00064 return p; 00065 }
BlackBox::Pointer bbtk::Package::NewAdaptor | ( | const DataInfo & | typein, | |
const DataInfo & | typeout, | |||
const std::string & | name | |||
) | const |
Creates a new adaptor BlackBox for the given input and output types with name name
Creates an instance of an adaptor of input type <typein> and output type <typeout> with name <name>
Definition at line 717 of file bbtkPackage.cxx.
References bbtkDebugDecTab, bbtkDebugMessageInc, bbtkendl, bbtk::BlackBoxDescriptor::DEFAULT_ADAPTOR, GetName(), bbtk::i, and mAdaptorMap.
00720 { 00721 bbtkDebugMessageInc("kernel",8,"Package<"<<GetName()<< 00722 ">::NewAdaptor(" 00723 <<typein<<"," 00724 <<typeout<<",\"" 00725 <<name<<"\")"<<bbtkendl); 00726 00727 AdaptorKey key(typein,typeout, 00728 BlackBoxDescriptor::DEFAULT_ADAPTOR); 00729 AdaptorMapType::const_iterator i = mAdaptorMap.find(key); 00730 if (i == mAdaptorMap.end()) 00731 { 00732 bbtkDebugDecTab("kernel",8); 00733 return BlackBox::Pointer(); 00734 } 00735 BlackBox::Pointer bb =i->second.lock()->NewBlackBox(name); 00736 bbtkDebugDecTab("kernel",8); 00737 return bb; 00738 00739 }
BlackBox::Pointer bbtk::Package::NewBlackBox | ( | const std::string & | type, | |
const std::string & | name | |||
) | const |
Creates a new BlackBox of given type with name name.
Creates an instance of a black box of type <type> with name <name>.
Definition at line 694 of file bbtkPackage.cxx.
References bbtkDebugDecTab, bbtkDebugMessageInc, bbtkendl, GetName(), bbtk::i, and mDescriptorMap.
00696 { 00697 bbtkDebugMessageInc("kernel",8,"Package<"<<GetName()<<">::NewBlackBox(\""<<type<<"\",\""<<name<<"\")"<<bbtkendl); 00698 00699 DescriptorMapType::const_iterator i = mDescriptorMap.find(type); 00700 if (i == mDescriptorMap.end()) 00701 { 00702 bbtkDebugDecTab("kernel",8); 00703 return BlackBox::Pointer(); 00704 } 00705 BlackBox::Pointer bb =i->second->NewBlackBox(name); 00706 bbtkDebugDecTab("kernel",8); 00707 return bb; 00708 00709 }
BlackBox::Pointer bbtk::Package::NewWidgetAdaptor | ( | const DataInfo & | typein, | |
const DataInfo & | typeout, | |||
const std::string & | name | |||
) | const |
Creates a new widget adaptor BlackBox for the given input and output types with name name
Creates an instance of an adaptor of input type <typein> and output type <typeout> with name <name>
Definition at line 745 of file bbtkPackage.cxx.
References bbtkDebugDecTab, bbtkDebugMessageInc, bbtkendl, bbtk::BlackBoxDescriptor::DEFAULT_GUI, GetName(), bbtk::i, and mAdaptorMap.
00748 { 00749 bbtkDebugMessageInc("kernel",8,"Package<"<<GetName()<< 00750 ">::NewWidgetAdaptor(" 00751 <<typein<<"," 00752 <<typeout<<",\"" 00753 <<name<<"\")"<<bbtkendl); 00754 00755 AdaptorKey key(typein,typeout, 00756 BlackBoxDescriptor::DEFAULT_GUI); 00757 AdaptorMapType::const_iterator i = mAdaptorMap.find(key); 00758 if (i == mAdaptorMap.end()) 00759 { 00760 bbtkDebugDecTab("kernel",8); 00761 return BlackBox::Pointer(); 00762 } 00763 BlackBox::Pointer bb =i->second.lock()->NewBlackBox(name); 00764 bbtkDebugDecTab("kernel",8); 00765 return bb; 00766 00767 }
DynamicLibraryHandler bbtk::Package::OpenDynamicLibrary | ( | const std::string & | libname, | |
const std::string & | package_name, | |||
DLGetPackageFunction & | getpack, | |||
DLDeletePackageFunction & | delpack | |||
) | [static] |
Opens a dynamic library which contains a bbtk package Returns the handler Load the package management symbols from the lib returns false if a problem occured hence can be used to test that a dyn lib is a valid bbtk package lib NB : The BBTK version exported from the library is tested against the current bbtk version
Opens a dynamic library which contains a bbtk package Returns the handler Load the package management symbols from the lib returns false if a problem occured hence can be used to test that a dyn lib is a valid bbtk package lib NB : The BBTK version exported from the library is tested against the current bbtk version
Definition at line 353 of file bbtkPackage.cxx.
References BBTK_DEL_PACKAGE_FUNCTION_NAME, BBTK_GET_PACKAGE_BBTK_VERSION_FUNCTION_NAME, BBTK_GET_PACKAGE_FUNCTION_NAME, BBTK_STRINGIFY_SYMBOL, bbtkDebugMessage, bbtkError, bbtkMessage, and bbtk::GetVersion().
Referenced by CreateFromDynamicLibrary().
00357 { 00358 bbtkDebugMessage("package",3,"==> Package::OpenDynamicLibrary(" 00359 <<libname<<")"<<std::endl); 00360 #if defined(__GNUC__) 00361 00362 // Open shared lib 00363 void *handler; 00364 handler = dlopen(libname.c_str(), BBTK_RTLD_TIME | BBTK_RTLD_SCOPE ); 00365 //EED handler = dlopen(libname.c_str(), RTLD_LAZY | RTLD_LOCAL ); 00366 00367 if (!handler) 00368 { 00369 bbtkMessage("package",2, 00370 "Could not open shared library [" <<libname<<"] : " 00371 <<dlerror() << std::endl); 00372 return 0; 00373 } 00374 00375 bbtkDebugMessage("package",3,"* Shared lib ["<<libname<<"] open"<<std::endl); 00376 00377 // Loads the Package bbtk version function 00378 std::string getvername(package_name); 00379 getvername += 00380 BBTK_STRINGIFY_SYMBOL(BBTK_GET_PACKAGE_BBTK_VERSION_FUNCTION_NAME); 00381 DLGetPackageBBTKVersionFunction getbbtkversion 00382 = (DLGetPackageBBTKVersionFunction)(dlsym(handler,getvername.c_str())); 00383 if (!getbbtkversion) 00384 { 00385 bbtkDebugMessage("package",3,"***"<<std::endl); 00386 bbtkMessage("package",2, 00387 "Shared library ["<<libname 00388 <<"] is not a valid bbtk package." 00389 <<" Symbol ["<<getvername<<"] :"<<dlerror()<< std::endl); 00390 dlclose(handler); 00391 return 0; 00392 } 00393 00394 bbtkDebugMessage("package",3,"* Symbol ["<<getvername 00395 <<"] found"<<std::endl); 00396 // version matches ? 00397 if (getbbtkversion() != bbtk::GetVersion()) 00398 { 00399 bbtkMessage("package",2, 00400 "Shared library ["<<libname 00401 <<"] was build with bbtk version " 00402 <<getbbtkversion() 00403 <<" but the current program runs with version " 00404 <<bbtk::GetVersion()<<" : cannot load it"<<std::endl); 00405 dlclose(handler); 00406 return 0; 00407 00408 } 00409 00410 bbtkDebugMessage("package",3,"* Package bbtk version '"<<getbbtkversion()<<"' matches"<<std::endl); 00411 // Loads the Package get function 00412 std::string getpackname(package_name); 00413 getpackname += BBTK_STRINGIFY_SYMBOL(BBTK_GET_PACKAGE_FUNCTION_NAME); 00414 getpack = (DLGetPackageFunction)(dlsym(handler, getpackname.c_str())); 00415 if (!getpack) 00416 { 00417 bbtkMessage("package",2, 00418 "Shared library ["<<libname 00419 <<"] is not a valid bbtk package." 00420 <<" Symbol ["<<getpackname<<"] :"<<dlerror()<< std::endl); 00421 dlclose(handler); 00422 return 0; 00423 } 00424 00425 bbtkDebugMessage("package",3,"* Symbol ["<<getpackname<<"] found"<<std::endl); 00426 // Loads the Package delete function 00427 00428 std::string delpackname(package_name); 00429 delpackname += BBTK_STRINGIFY_SYMBOL(BBTK_DEL_PACKAGE_FUNCTION_NAME); 00430 delpack = (DLDeletePackageFunction)(dlsym(handler, delpackname.c_str())); 00431 if (!delpack) 00432 { 00433 bbtkMessage("package",2, 00434 "Shared library ["<<libname 00435 <<"] is not a valid bbtk package." 00436 <<" Symbol ["<<delpackname<<"] :"<<dlerror()<< std::endl); 00437 dlclose(handler); 00438 return 0; 00439 } 00440 bbtkDebugMessage("package",3,"* Symbol ["<<delpackname<<"] found"<<std::endl); 00441 #elif defined(_WIN32) 00442 00443 HINSTANCE handler; 00444 00445 SetErrorMode(0); 00446 // Open shared lib 00447 handler = LoadLibrary(libname.c_str()); 00448 if (!handler) 00449 { 00450 bbtkMessage("package",2, 00451 "Could not open shared library [" <<libname<<"]" 00452 << std::endl); 00453 DWORD dwErrorCode = 0; 00454 dwErrorCode = GetLastError(); 00455 bbtkMessage("package",2, 00456 "Windows Error: [" << dwErrorCode <<"]" 00457 << std::endl); 00458 00459 return 0; 00460 } 00461 00462 // Loads the Package bbtk version function 00463 std::string getvername(package_name); 00464 getvername += 00465 BBTK_STRINGIFY_SYMBOL(BBTK_GET_PACKAGE_BBTK_VERSION_FUNCTION_NAME); 00466 DLGetPackageBBTKVersionFunction getbbtkversion 00467 = (DLGetPackageBBTKVersionFunction)(GetProcAddress(handler, 00468 getvername.c_str())); 00469 if (!getbbtkversion) 00470 { 00471 FreeLibrary(handler); 00472 bbtkMessage("package",2, 00473 "Shared library ["<<libname 00474 <<"] is not a valid bbtk package." 00475 <<" Symbol ["<<getbbtkversion<<"] not found"<< std::endl); 00476 return 0; 00477 } 00478 00479 // version matches ? 00480 if (getbbtkversion() != bbtk::GetVersion()) 00481 { 00482 FreeLibrary(handler); 00483 bbtkMessage("package",2, 00484 "Shared library ["<<libname 00485 <<"] was build with bbtk version " 00486 <<getbbtkversion() 00487 <<" but the current program runs with version " 00488 <<bbtk::GetVersion()<<" : cannot load it"<<std::endl); 00489 return 0; 00490 00491 } 00492 00493 // Loads the Package get function 00494 std::string getpackname(package_name); 00495 getpackname += BBTK_STRINGIFY_SYMBOL(BBTK_GET_PACKAGE_FUNCTION_NAME); 00496 getpack = (DLGetPackageFunction)(GetProcAddress(handler, getpackname.c_str())); 00497 if (!getpack) 00498 { 00499 FreeLibrary(handler); 00500 bbtkMessage("package",2, 00501 "Shared library ["<<libname 00502 <<"] is not a valid bbtk package." 00503 <<" Symbol ["<<getpackname<<"] not found"<< std::endl); 00504 return 0; 00505 } 00506 00507 // Loads the Package delete function 00508 std::string delpackname(package_name); 00509 delpackname += BBTK_STRINGIFY_SYMBOL(BBTK_DEL_PACKAGE_FUNCTION_NAME); 00510 delpack = (DLDeletePackageFunction)(GetProcAddress(handler, delpackname.c_str())); 00511 if (!delpack) 00512 { 00513 FreeLibrary(handler); 00514 bbtkMessage("package",2, 00515 "Shared library ["<<libname 00516 <<"] is not a valid bbtk package." 00517 <<" Symbol ["<<delpackname<<"] not found"<< std::endl); 00518 return 0; 00519 } 00520 00521 #else 00522 bbtkError("neither __GNUC__ nor _WIN32 ?!? How did you compile ?"); 00523 #endif 00524 00525 return handler; 00526 }
void bbtk::Package::PrintHelpDescriptor | ( | const std::string & | name, | |
bool | full = true | |||
) | const |
Prints help on a particular Descriptor.
Prints help on a black box descriptor.
Definition at line 1084 of file bbtkPackage.cxx.
References bbtkDebugDecTab, bbtkDebugMessageInc, bbtkendl, bbtkError, GetName(), bbtk::i, and mDescriptorMap.
01085 { 01086 bbtkDebugMessageInc("kernel",8,"Package<"<<GetName() 01087 <<">::PrintHelpDescriptor(\"" 01088 <<name<<"\")"<<bbtkendl); 01089 01090 DescriptorMapType::const_iterator i = mDescriptorMap.find(name); 01091 if (i == mDescriptorMap.end()) 01092 { 01093 bbtkDebugDecTab("kernel",8); 01094 bbtkError("The package <"<<GetName()<<"> does not contains the black box <"<<name<<">"); 01095 } 01096 // bbtkMessage("help",1,"["<<GetName()<<"] "); 01097 i->second->GetHelp(full); 01098 bbtkDebugDecTab("kernel",8); 01099 01100 }
void bbtk::Package::PrintHelpListAdaptors | ( | bool | description = false |
) | const |
Displays the list of adaptors of the package.
Definition at line 1036 of file bbtkPackage.cxx.
References bbtkMessage, bbtk::BlackBoxDescriptor::DEFAULT_ADAPTOR, bbtk::i, mDescriptorMap, and bbtk::BlackBoxDescriptor::STANDARD.
01037 { 01038 DescriptorMapType::const_iterator i; 01039 for (i=mDescriptorMap.begin(); 01040 i!=mDescriptorMap.end(); 01041 ++i) 01042 { 01043 if ( i->second->GetKind() != BlackBoxDescriptor::STANDARD ) 01044 { 01045 bbtkMessage("help",1, 01046 " "<<i->second->GetTypeName()); 01047 if ( i->second->GetKind() == 01048 BlackBoxDescriptor::DEFAULT_ADAPTOR ) 01049 { 01050 bbtkMessage("help",1, 01051 " [default]"); 01052 } 01053 if (description) 01054 { 01055 bbtkMessage("help",1, 01056 " : "<<i->second->GetDescription()); 01057 01058 } 01059 bbtkMessage("help",1,std::endl); 01060 } 01061 } 01062 /* 01063 AdaptorMapType::const_iterator i; 01064 for (i=mAdaptorMap.begin(); 01065 i!=mAdaptorMap.end(); 01066 ++i) 01067 { 01068 bbtkMessage("help",1, 01069 " "<<i->second->GetTypeName()); 01070 if (detail_level>0) 01071 { 01072 bbtkMessage("help",1, 01073 " : "<<i->second->GetDescription()); 01074 01075 } 01076 bbtkMessage("help",1,std::endl); 01077 } 01078 */ 01079 }
void bbtk::Package::PrintHelpListDescriptors | ( | bool | description = false , |
|
bool | adaptors = false | |||
) | const |
Displays the list of black box descriptors of the package.
Definition at line 965 of file bbtkPackage.cxx.
References bbtk::BlackBoxDescriptor::ADAPTOR, bbtkMessage, bbtk::BlackBoxDescriptor::DEFAULT_ADAPTOR, bbtk::i, mDescriptorMap, and bbtk::BlackBoxDescriptor::STANDARD.
00966 { 00967 unsigned int lmax = 0; 00968 std::vector<std::string> names; 00969 std::vector<std::string> kinds; 00970 std::vector<std::string> descrs; 00971 00972 DescriptorMapType::const_iterator i; 00973 for (i=mDescriptorMap.begin(); 00974 i!=mDescriptorMap.end(); 00975 ++i) 00976 { 00977 if ( adaptors || 00978 ( i->second->GetKind() == BlackBoxDescriptor::STANDARD) ) 00979 { 00980 std::string name(" "); 00981 name += i->second->GetTypeName(); 00982 names.push_back(name); 00983 00984 std::string kind; 00985 if ( i->second->GetKind() == BlackBoxDescriptor::ADAPTOR ) 00986 { 00987 kind = std::string("[A]"); 00988 } 00989 else if ( i->second->GetKind() == 00990 BlackBoxDescriptor::DEFAULT_ADAPTOR ) 00991 { 00992 kind = std::string("[DA]"); 00993 } 00994 kinds.push_back(kind); 00995 00996 unsigned int l = name.size()+kind.size(); 00997 if (l>lmax) lmax = l; 00998 00999 std::string descr; 01000 if (description) 01001 { 01002 descr += " : "; 01003 descr += i->second->GetDescription(); 01004 } 01005 descrs.push_back(descr); 01006 } 01007 } 01008 01009 01010 std::string offs; 01011 offs.append(lmax+3,' '); 01012 std::vector<std::string>::iterator ni,ci,di; 01013 for (ni = names.begin(), ci = kinds.begin(), di = descrs.begin(); 01014 ni != names.end(); ++ni, ++ci, ++di) 01015 { 01016 std::string space; 01017 space.append(lmax - ni->size() - ci->size(),' '); 01018 bbtkMessage("help",1,*ni << space << *ci ); 01019 std::string d(*di); 01020 unsigned int dmax = 75 - lmax; 01021 // while (d.size() > dmax ) 01022 // { 01023 if (d.size()>dmax) 01024 bbtkMessage("help",1,d.substr(0,dmax) << "..." << std::endl); 01025 else 01026 bbtkMessage("help",1,d << std::endl); 01027 // d = d.substr(dmax,d.size()); 01028 // } 01029 } 01030 01031 }
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 }
bool bbtk::Package::Register | ( | BlackBoxDescriptor::Pointer | d | ) |
Registers the BlackBoxDescriptor in the Package.
Registers a black box descriptor in the package.
Definition at line 838 of file bbtkPackage.cxx.
References bbtkDebugDecTab, bbtkDebugMessage, bbtkDebugMessageInc, bbtkError, bbtkWarning, bbtk::BlackBoxDescriptor::DEFAULT_ADAPTOR, bbtk::BlackBoxDescriptor::DEFAULT_GUI, GetName(), bbtk::i, mAdaptorMap, and mDescriptorMap.
00839 { 00840 bbtkDebugMessageInc("kernel",8,"Package<"<<GetName()<<">::Register(\""<<d->GetTypeName()<<"\")"<<std::endl); 00841 00842 DescriptorMapType::iterator i = mDescriptorMap.find(d->GetTypeName()); 00843 if (i!=mDescriptorMap.end()) 00844 { 00845 bbtkWarning("Package<"<<GetName()<<"> : Trying to register box type <" 00846 <<d->GetTypeName()<<"> which is already in the package"); 00847 return false; 00848 } 00849 00850 mDescriptorMap[d->GetTypeName()] = d; 00851 // d->Reference(); 00852 d->SetPackage(GetThisPointer<Package>()); 00853 00854 // If it is a default adaptor, also register it in the adaptors map 00855 if ( d->GetKind() == BlackBoxDescriptor::DEFAULT_ADAPTOR ) 00856 { 00857 bbtkDebugMessage("kernel",8,"Package<"<<GetName()<<">::Register(\""<<d->GetTypeName()<<"\") : The box is an adaptor, inserting it in adaptors map ..."<<std::endl); 00858 00859 TypeInfo typein = d->GetInputDescriptor("In")->GetTypeInfo(); 00860 TypeInfo typeout = d->GetOutputDescriptor("Out")->GetTypeInfo(); 00861 DataInfo infoin(typein,d->GetInputDescriptor("In")->GetNature()); 00862 DataInfo infoout(typeout,d->GetOutputDescriptor("Out")->GetNature()); 00863 AdaptorKey key(infoin,infoout,d->GetKind()); 00864 00865 AdaptorMapType::const_iterator i; 00866 i = mAdaptorMap.find(key); 00867 if (i == mAdaptorMap.end()) 00868 { 00869 mAdaptorMap[key] = d; 00870 } 00871 // If already an adaptor registered : error 00872 else 00873 { 00874 if (i->second.lock()->GetTypeName() != d->GetTypeName()) 00875 { 00876 bbtkError("Package <"<<GetName()<< 00877 "> : trying to register black box <" 00878 <<d->GetTypeName() 00879 <<"> as default adaptor but there is already a default adaptor registered (<" 00880 <<i->second.lock()->GetTypeName()<<">)"); 00881 } 00882 } 00883 } 00884 // If it is a default adaptor, also register it in the adaptors map 00885 else if ( d->GetKind() == BlackBoxDescriptor::DEFAULT_GUI) 00886 { 00887 bbtkDebugMessage("kernel",8,"Package<"<<GetName()<<">::Register(\""<<d->GetTypeName()<<"\") : The box is a widget adaptor, inserting it in adaptors map ..."<<std::endl); 00888 00889 TypeInfo typeout = d->GetOutputDescriptor("Out")->GetTypeInfo(); 00890 DataInfo infoin(typeid(void),""); 00891 DataInfo infoout(typeout,d->GetOutputDescriptor("Out")->GetNature()); 00892 AdaptorKey key(infoin,infoout,d->GetKind()); 00893 00894 AdaptorMapType::const_iterator i; 00895 i = mAdaptorMap.find(key); 00896 if (i == mAdaptorMap.end()) 00897 { 00898 mAdaptorMap[key] = d; 00899 } 00900 // If already an adaptor registered : error 00901 else 00902 { 00903 if (i->second.lock()->GetTypeName() != d->GetTypeName()) 00904 { 00905 bbtkError("Package <"<<GetName()<< 00906 "> : trying to register black box <" 00907 <<d->GetTypeName() 00908 <<"> as default widget adaptor but there is already a default adaptor registered (<" 00909 <<i->second.lock()->GetTypeName()<<">)"); 00910 } 00911 } 00912 } 00913 00914 00915 bbtkDebugDecTab("kernel",8); 00916 00917 return true; 00918 }
void bbtk::Package::Release | ( | Package::WeakPointer | p | ) | [static] |
Release.
"Releases" the package Signals the package that it can free its descriptors if they are no more used then frees and unloads the package if it is no more used (released) Note : Any non-weak pointer on the package must have been freed
Definition at line 169 of file bbtkPackage.cxx.
References bbtkDebugMessage, bbtkendl, bbtk::i, bbtk::PackageReleaseBlackBoxDescriptorInternal(), UnLoadDynamicLibrary(), and UnLoadReleasedDynamicallyLoadedPackages().
Referenced by bbtk::Factory::ClosePackage(), and bbtk::Object::ReleasePackages().
00170 { 00171 std::string packname = pack.lock()->mName; 00172 bbtkDebugMessage("package",1,"==> Package::Release('"<< 00173 packname<<"')"<<bbtkendl); 00174 00175 long dyn = pack.lock()->mDynamicLibraryHandler ? 1:0; 00176 long ndesc = pack.lock()->GetDescriptorMap().size(); 00177 long nrefs = pack.use_count(); 00178 00179 bbtkDebugMessage("package",5," "<<nrefs<<" refs / " 00180 <<ndesc<<" descr / dyn=" 00181 <<dyn<<std::endl); 00182 00183 // A package is "free" from any external reference iff : 00184 // i) It is not dynamically loaded and nrefs == ndesc 00185 // (each desc references its package) or 00186 // ii) It is dynamically loaded and nrefs == ndesc + 1 00187 // (A dynamic library holds a static pointer on the package it contains 00188 // which is allocated when the PACKAGENAMEGetPackage() func is called, 00189 // and descallocated (reset) by PACKAGENAMEDeletePackage()) 00190 if (nrefs == ndesc + dyn) 00191 { 00192 bbtkDebugMessage("package",5, 00193 " -> No more external ref : checking descriptors" 00194 <<bbtkendl); 00195 // We must take care that removing refs on descriptors 00196 // can lead to their deletion which can in turn unref 00197 // internal boxes which can release their descriptors hence 00198 // call Package::ReleaseBlackBoxDescriptor 00199 // As a consequence during descriptors release : 00200 // 1) The map can change dynamically : we cannot iterate over it 00201 // as any iterator can become invalid 00202 // 2) The package can auto-destruct : we must test its existence 00203 // after each release 00204 // We must also take care of not locking the package pointer 00205 // or any ref count check in Package::ReleaseBlackBoxDescriptor 00206 // would be wrong 00207 00208 // The list of descriptors names at start 00209 std::vector<std::string> descnamelist; 00210 DescriptorMapType::iterator i; 00211 for (i=pack.lock()->mDescriptorMap.begin(); 00212 i!= pack.lock()->mDescriptorMap.end(); 00213 ++i) 00214 descnamelist.push_back(i->first); 00215 00216 // Iterator over the initial names 00217 std::vector<std::string>::iterator descname; 00218 for (descname=descnamelist.begin(); 00219 descname!=descnamelist.end(); 00220 ++descname) 00221 { 00222 // Is package still alive ? 00223 if (pack.expired()) 00224 { 00225 bbtkDebugMessage("package",1,"--- Package::Release('"<< 00226 packname 00227 <<"') : package expired during release : bailing out"<<bbtkendl); 00228 break; 00229 } 00230 00231 #if defined(MACOSX) 00232 BlackBoxDescriptor::Pointer desc = pack.lock()->mDescriptorMap[*descname]; 00233 if ( (dyn==0) || (boost::dynamic_pointer_cast<ComplexBlackBoxDescriptor>(desc)) ) 00234 { 00235 PackageReleaseBlackBoxDescriptorInternal(pack,*descname); 00236 } 00237 #else 00238 PackageReleaseBlackBoxDescriptorInternal(pack,*descname); 00239 #endif 00240 00241 } 00242 00243 // 00244 UnLoadDynamicLibrary(pack); 00245 // Unload orphan dl packages 00246 Package::UnLoadReleasedDynamicallyLoadedPackages(); 00247 00248 } 00249 00250 #ifdef BBTK_COMPILE_DEBUG_MESSAGES 00251 00252 bbtkDebugMessage("package",2,"<== Package::Release('"<< 00253 packname<<"')"<<bbtkendl); 00254 00255 if (!pack.expired()) 00256 { 00257 long dyn = pack.lock()->mDynamicLibraryHandler ? 1:0; 00258 long ndesc = pack.lock()->GetDescriptorMap().size(); 00259 long nrefs = pack.use_count(); 00260 00261 bbtkDebugMessage("package",1," ... Package still alive (" 00262 <<nrefs<<" refs / " 00263 <<ndesc<<" descr / dyn=" 00264 <<dyn<<")"<<std::endl); 00265 } 00266 else 00267 { 00268 bbtkDebugMessage("package",1," ... Package has been released" 00269 <<std::endl); 00270 } 00271 #endif 00272 }
void bbtk::Package::ReleaseBlackBoxDescriptor | ( | Package::WeakPointer | pack, | |
BlackBoxDescriptor::WeakPointer | descr | |||
) | [static] |
"Releases" a black box descriptor Signals the package that it can free the given descriptor if it is no more used and frees and put it the the ReleasedDynamicallyLoadedPackages if it is dyn loaded and no more used (released) Note : Any non-weak pointer on the package must have been freed
"Releases" the package Signals the package that it can free the given descriptor if they are no more used and free itself if it is no more used Note : Any non-weak pointer on the package must have been freed
Definition at line 281 of file bbtkPackage.cxx.
References bbtkDebugMessage, bbtkendl, bbtk::PackageReleaseBlackBoxDescriptorInternal(), and UnLoadDynamicLibrary().
Referenced by bbtk::BlackBox::Deleter::Delete().
00283 { 00284 std::string packname = pack.lock()->mName; 00285 std::string dname = descr.lock()->GetTypeName(); 00286 bbtkDebugMessage("package",3,"==> Package::ReleaseBlackBoxDescriptor('"<< 00287 packname<<"','"<<dname<<"') : refs=" 00288 <<descr.use_count()<<bbtkendl); 00289 00290 long dyn = pack.lock()->mDynamicLibraryHandler ? 1:0; 00291 long ndesc = pack.lock()->GetDescriptorMap().size(); 00292 long nrefs = pack.use_count(); 00293 00294 bbtkDebugMessage("package",5," "<<nrefs<<" refs / " 00295 <<ndesc<<" descr / dynamically loaded = " 00296 <<dyn<<std::endl); 00297 00298 // A package is "free" from any external reference iff : 00299 // i) It is not dynamically loaded and nrefs == ndesc 00300 // (each desc references its package) or 00301 // ii) It is dynamically loaded and nrefs == ndesc + 1 00302 // (A dynamic library holds a static pointer on the package it contains 00303 // which is allocated when the PACKAGENAMEGetPackage() func is called, 00304 // and descallocated (reset) by PACKAGENAMEDeletePackage()) 00305 if (nrefs == ndesc + dyn) 00306 { 00307 #if defined(MACOSX) 00308 // 00309 if (dyn==0) 00310 PackageReleaseBlackBoxDescriptorInternal(pack,dname); 00311 #else 00312 PackageReleaseBlackBoxDescriptorInternal(pack,dname); 00313 #endif 00314 } 00315 00316 // If the package is released and dynamically loaded 00317 // then put it in the static list mReleasedDynamicallyLoadedPackages 00318 UnLoadDynamicLibrary(pack,false); 00319 00320 bbtkDebugMessage("package",4,"<== Package::ReleaseBlackBoxDescriptor('"<< 00321 packname<<"','"<<dname<<"'): refs=" 00322 <<descr.use_count()<<bbtkendl); 00323 /* 00324 if (!pack.expired()) 00325 { 00326 long dyn = pack.lock()->mDynamicLibraryHandler ? 1:0; 00327 long ndesc = pack.lock()->GetDescriptorMap().size(); 00328 long nrefs = pack.use_count(); 00329 00330 bbtkDebugMessage("package",3," ... Package still alive (" 00331 <<nrefs<<" refs / " 00332 <<ndesc<<" descr / dyn=" 00333 <<dyn<<")"<<std::endl); 00334 } 00335 else 00336 { 00337 bbtkDebugMessage("package",3," ... Package has been released" 00338 <<std::endl); 00339 } 00340 */ 00341 }
void bbtk::Object::ReleasePackages | ( | ) | [static, inherited] |
Definition at line 222 of file bbtkObject.cxx.
References bbtkDebugMessage, bbtk::i, bbtk::Object::mgPackageList, and 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::Package::RemoveFactory | ( | FactoryPointer | f | ) | [inline] |
Removes the factory from the set of factories which use the package.
Definition at line 247 of file bbtkPackage.h.
00247 { mFactorySet.erase(f); }
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::Package::SetDocRelativeURL | ( | std::string | url | ) | [inline] |
Definition at line 193 of file bbtkPackage.h.
Referenced by Package().
00193 { mDocRelativeURL=url; }
void bbtk::Package::SetDocURL | ( | std::string | url | ) | [inline] |
Definition at line 190 of file bbtkPackage.h.
Referenced by Package().
00190 { mDocURL=url; }
void bbtk::Package::UnLoad | ( | Package::WeakPointer | p | ) | [static, private] |
Does unload a package (no test).
Definition at line 648 of file bbtkPackage.cxx.
References bbtkDebugMessage, bbtkWarning, mDLDeletePackageFunction, and mDynamicLibraryHandler.
Referenced by UnLoadDynamicLibrary(), and UnLoadReleasedDynamicallyLoadedPackages().
00649 { 00650 std::string packname = pack.lock()->GetName(); 00651 bbtkDebugMessage("package",6,"==> Package::UnLoad("<<packname<<")"<<std::endl); 00652 00653 Package* p = pack.lock().get(); 00654 00655 DynamicLibraryHandler h = p->mDynamicLibraryHandler; 00656 00657 // deletes the package 00658 p->mDLDeletePackageFunction(); 00659 00660 // closes the dl handler 00661 #if defined(__GNUC__) 00662 if (dlclose(h)!=0) 00663 { 00664 printf("EED Package::UnLoad ERROR %s\n", packname.c_str() ); 00665 bbtkWarning("Failed to close dynamic library for package '"<<packname 00666 <<"'"<<std::endl); 00667 } 00668 00669 #elif defined(_WIN32) 00670 FreeLibrary(h); 00671 #endif 00672 00673 bbtkDebugMessage("package",1,"==> dynamic library for package '" 00674 <<packname<<"' closed" 00675 <<std::endl); 00676 bbtkDebugMessage("package",6," ... dynamic library unloaded"<<std::endl); 00677 }
void bbtk::Package::UnLoadDynamicLibrary | ( | Package::WeakPointer | p, | |
bool | doit = true | |||
) | [static] |
UnLoads the package dynamic library (if any).
NOTE : All the static methods below for package destruction are not member because they can cause the package death and thus close the dynamic library from which it has been loaded. If the dynamic lib which provides a function is closed while in the function: imagine the crash ! The principal method is Release UnLoads the package dynamic library (if any and if the package is released) If doit == false then does not do it but just put the package in the list of ReleasedDynamicallyLoadedPackages. This is because we cannot close the dl from inside a package member method or the program crashes. The actual dl close must be done by an external user calling UnLoadReleasedDynamicallyLoadedPackages
Definition at line 573 of file bbtkPackage.cxx.
References BBTK_INTERNAL_ERROR_MESSAGE, bbtkDebugMessage, bbtkGlobalError, mReleasedDynamicallyLoadedPackages, and UnLoad().
Referenced by Release(), and ReleaseBlackBoxDescriptor().
00574 { 00575 if (pack.expired() || (!pack.lock()->mDynamicLibraryHandler)) 00576 return; 00577 00578 std::string packname = pack.lock()->GetName(); 00579 bbtkDebugMessage("package",5,"==> Package::UnLoadDynamicLibrary('" 00580 <<packname<<"')" 00581 <<std::endl); 00582 00583 if (!pack.lock()->GetDescriptorMap().empty()) 00584 { 00585 00586 bbtkDebugMessage("package",5," Package not empty ... abort" 00587 <<std::endl); 00588 return; 00589 /* 00590 bbtkGlobalError("Package::UnLoadDynamicLibrary('"<<packname<<") : " 00591 <<"DescriptorMap not empty " 00592 <<BBTK_INTERNAL_ERROR_MESSAGE); 00593 */ 00594 } 00595 00596 if (pack.use_count()!=1) 00597 { 00598 bbtkGlobalError("Package::UnLoadDynamicLibrary('"<<packname<<") : " 00599 <<"empty dl package with external refs" 00600 <<BBTK_INTERNAL_ERROR_MESSAGE); 00601 } 00602 00603 if (doit) 00604 { 00605 UnLoad(pack); 00606 bbtkDebugMessage("package",5,"==> dynamic library for package '" 00607 <<packname<<"' closed" 00608 <<std::endl); 00609 } 00610 else 00611 { 00612 mReleasedDynamicallyLoadedPackages.insert(pack); 00613 bbtkDebugMessage("package",1,"==> package '"<<packname 00614 <<"' put in the 'to unload' list" 00615 <<std::endl); 00616 } 00617 00618 bbtkDebugMessage("package",5,"<== Package::UnLoadDynamicLibrary('" 00619 <<packname<<"')" 00620 <<std::endl); 00621 }
void bbtk::Package::UnLoadReleasedDynamicallyLoadedPackages | ( | ) | [static] |
UnLoads released packages that were loaded dynamically see UnLoadDynamicLibrary and ReleaseBlackBoxDescriptor
UnLoads released packages that were loaded dynamically see UnLoadDynamicLibrary and ReleaseBlackBoxDescriptor
Definition at line 627 of file bbtkPackage.cxx.
References bbtkDebugMessage, bbtk::i, mReleasedDynamicallyLoadedPackages, and UnLoad().
Referenced by bbtk::ComplexBlackBox::bbRemoveBlackBox(), and Release().
00628 { 00629 bbtkDebugMessage("package",5,"==> Package::UnLoadReleasedDynamicallyLoadedPackages()"<<std::endl); 00630 00631 std::set<Package::WeakPointer>::iterator i; 00632 00633 //JCP- 21-04-09 00634 if(mReleasedDynamicallyLoadedPackages.size()>0){ 00635 for (i=mReleasedDynamicallyLoadedPackages.begin(); 00636 i!=mReleasedDynamicallyLoadedPackages.end(); 00637 ++i) 00638 { 00639 if (!i->expired()) UnLoad(*i); 00640 } 00641 } 00642 //JCP- 21-04-09 00643 bbtkDebugMessage("package",5,"<== Package::UnLoadReleasedDynamicallyLoadedPackages()"<<std::endl); 00644 }
void bbtk::Object::UnLockThis | ( | ) | [inline, protected, inherited] |
friend struct Object::Deleter [friend] |
Definition at line 54 of file bbtkPackage.h.
AdaptorMapType bbtk::Package::mAdaptorMap [private] |
The map of adaptors descriptors.
Definition at line 300 of file bbtkPackage.h.
Referenced by CreateHtmlPage(), FindAdaptor(), FindWidgetAdaptor(), NewAdaptor(), NewWidgetAdaptor(), and Register().
std::string bbtk::Package::mAuthor [private] |
std::string bbtk::Package::mCategory [private] |
std::string bbtk::Package::mDescription [private] |
The map of black boxes descriptors.
Definition at line 297 of file bbtkPackage.h.
Referenced by ChangeDescriptorName(), Check(), ContainsDescriptor(), CreateHtmlPage(), GetObjectInfo(), GetObjectRecursiveSize(), ifBoxExist(), NewBlackBox(), PrintHelpDescriptor(), PrintHelpListAdaptors(), PrintHelpListDescriptors(), and Register().
The pointer on the delete function of the package in case it was loaded from a dynamic library
Definition at line 277 of file bbtkPackage.h.
Referenced by UnLoad().
std::string bbtk::Package::mDocRelativeURL [private] |
URL of the documentation of the Package (path relative to bbtk doc root)
Definition at line 294 of file bbtkPackage.h.
std::string bbtk::Package::mDocURL [private] |
URL of the documentation of the Package (absolute path).
Definition at line 291 of file bbtkPackage.h.
DynamicLibraryHandler bbtk::Package::mDynamicLibraryHandler [private] |
The dynamic library handler of the package if it was loaded from a dl.
Definition at line 274 of file bbtkPackage.h.
Referenced by GetObjectInfo(), and UnLoad().
FactorySet bbtk::Package::mFactorySet [private] |
std::string bbtk::Package::mName [private] |
The name of the package.
Definition at line 281 of file bbtkPackage.h.
Referenced by GetObjectName(), and ~Package().
std::set< Package::WeakPointer > bbtk::Package::mReleasedDynamicallyLoadedPackages [static, private] |
The set of released dynamically loaded packages to be unloaded explicitely calling UnLoadReleasedDynamicallyLoadedPackages
Definition at line 310 of file bbtkPackage.h.
Referenced by UnLoadDynamicLibrary(), and UnLoadReleasedDynamicallyLoadedPackages().
std::string bbtk::Package::mVersion [private] |