This commit is contained in:
Matthias Koefferlein 2025-10-11 19:26:11 +02:00
parent ff2beaf32f
commit 5045287712
2 changed files with 33 additions and 15 deletions

View File

@ -37,14 +37,6 @@ namespace gsi
// ---------------------------------------------------------------
// db::Library binding
/**
* @brief A basic implementation of the library
*/
static db::Library *new_lib ()
{
return new db::Library ();
}
static db::Library *library_by_name (const std::string &name, const std::string &for_technology)
{
return db::LibraryManager::instance ().lib_ptr_by_name (name, for_technology);
@ -135,7 +127,10 @@ class LibraryImpl
: public db::Library
{
public:
LibraryImpl () : db::Library () { }
LibraryImpl () : db::Library ()
{
// .. nothing yet ..
}
virtual std::string reload ()
{
@ -151,6 +146,15 @@ public:
}
static LibraryImpl *new_lib ()
{
return new LibraryImpl ();
}
/**
* @brief A basic implementation of the library
*/
LibraryClass<db::Library> decl_Library ("db", "LibraryBase",
gsi::method ("library_by_name", &library_by_name, gsi::arg ("name"), gsi::arg ("for_technology", std::string (), "unspecific"),
"@brief Gets a library by name\n"
@ -289,6 +293,10 @@ LibraryClass<db::Library> decl_Library ("db", "LibraryBase",
"@hide"
);
/**
* @brief The reimplementation stub
*/
LibraryClass<LibraryImpl> decl_LibraryImpl (decl_Library, "db", "Library",
gsi::constructor ("new", &new_lib,
"@brief Creates a new, empty library"

View File

@ -45,14 +45,17 @@ class DBLibrary_TestClass < TestBase
assert_equal(RBA::Library::library_names.member?("RBA-unit-test"), true)
assert_equal(RBA::Library::library_by_name("RBA-unit-test").id, lib_id)
# destroy should not do anything as libraries are not to be removed through the destructor
lib._destroy
assert_equal(RBA::Library::library_by_name("RBA-unit-test").id, lib_id)
assert_equal(lib.destroyed?, true)
# The library reference is kept internally
lib = nil
GC.start
GC.start
lib = RBA::Library::library_by_name("RBA-unit-test")
assert_equal(lib.destroyed?, false)
lib.delete
assert_equal(lib.name, "RBA-unit-test")
lib._destroy
assert_equal(lib.destroyed?, true)
assert_equal(RBA::Library::library_by_name("RBA-unit-test"), nil)
end
@ -101,6 +104,13 @@ class DBLibrary_TestClass < TestBase
lib._destroy
assert_equal(lib.destroyed?, true)
end
def test_4_library_registration
end
end