mirror of https://github.com/KLayout/klayout.git
Merge pull request #938 from KLayout/issue-879
Solved #879: PCellDeclaration now knows the layout and layout knows t…
This commit is contained in:
commit
5fcc8c1251
|
|
@ -346,6 +346,7 @@ ProxyContextInfo::serialize (std::vector<std::string> &strings)
|
|||
|
||||
Layout::Layout (db::Manager *manager)
|
||||
: db::Object (manager),
|
||||
mp_library (0),
|
||||
m_cells_size (0),
|
||||
m_invalid (0),
|
||||
m_top_cells (0),
|
||||
|
|
@ -362,6 +363,7 @@ Layout::Layout (db::Manager *manager)
|
|||
|
||||
Layout::Layout (bool editable, db::Manager *manager)
|
||||
: db::Object (manager),
|
||||
mp_library (0),
|
||||
m_cells_size (0),
|
||||
m_invalid (0),
|
||||
m_top_cells (0),
|
||||
|
|
@ -382,6 +384,7 @@ Layout::Layout (const db::Layout &layout)
|
|||
gsi::ObjectBase (),
|
||||
tl::Object (),
|
||||
tl::UniqueId (),
|
||||
mp_library (0),
|
||||
m_cells_size (0),
|
||||
m_invalid (0),
|
||||
m_top_cells (0),
|
||||
|
|
@ -2270,6 +2273,7 @@ Layout::register_pcell (const std::string &name, pcell_declaration_type *declara
|
|||
|
||||
declaration->m_id = id;
|
||||
declaration->m_name = name;
|
||||
declaration->mp_layout = this;
|
||||
|
||||
// marks this object being held by the layout
|
||||
declaration->keep ();
|
||||
|
|
|
|||
|
|
@ -582,6 +582,22 @@ public:
|
|||
return m_tech_name;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Gets the library the layout lives in or NULL if the layout is not part of a library
|
||||
*/
|
||||
Library *library () const
|
||||
{
|
||||
return mp_library;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Sets the library pointer
|
||||
*/
|
||||
void set_library (db::Library *library)
|
||||
{
|
||||
mp_library = library;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Gets the technology object the layout is associated with or null if no valid technology is associated
|
||||
*/
|
||||
|
|
@ -1843,6 +1859,7 @@ protected:
|
|||
private:
|
||||
enum LayerState { Normal, Free, Special };
|
||||
|
||||
db::Library *mp_library;
|
||||
cell_list m_cells;
|
||||
size_t m_cells_size;
|
||||
cell_ptr_vector m_cell_ptrs;
|
||||
|
|
|
|||
|
|
@ -32,13 +32,13 @@ namespace db
|
|||
Library::Library()
|
||||
: m_id (0), m_layout (true)
|
||||
{
|
||||
// .. nothing yet ..
|
||||
m_layout.set_library (this);
|
||||
}
|
||||
|
||||
Library::Library(const Library &d)
|
||||
: gsi::ObjectBase (), tl::Object (), m_name (d.m_name), m_description (d.m_description), m_id (0), m_layout (d.m_layout)
|
||||
{
|
||||
// .. nothing yet ..
|
||||
m_layout.set_library (this);
|
||||
}
|
||||
|
||||
Library::~Library ()
|
||||
|
|
|
|||
|
|
@ -28,7 +28,7 @@ namespace db
|
|||
{
|
||||
|
||||
PCellDeclaration::PCellDeclaration ()
|
||||
: m_ref_count (0), m_id (0), m_has_parameter_declarations (false)
|
||||
: m_ref_count (0), m_id (0), mp_layout (0), m_has_parameter_declarations (false)
|
||||
{
|
||||
// .. nothing yet ..
|
||||
}
|
||||
|
|
|
|||
|
|
@ -429,6 +429,14 @@ public:
|
|||
return db::Trans ();
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Gets the Layout object the PCell is registered inside or NULL if it is not registered
|
||||
*/
|
||||
db::Layout *layout () const
|
||||
{
|
||||
return mp_layout;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Add a reference to this object
|
||||
*
|
||||
|
|
@ -518,6 +526,7 @@ private:
|
|||
int m_ref_count;
|
||||
pcell_id_type m_id;
|
||||
std::string m_name;
|
||||
db::Layout *mp_layout;
|
||||
mutable bool m_has_parameter_declarations;
|
||||
mutable std::vector<PCellParameterDeclaration> m_parameter_declarations;
|
||||
|
||||
|
|
|
|||
|
|
@ -980,6 +980,10 @@ Class<db::Layout> decl_Layout ("db", "Layout",
|
|||
"\n"
|
||||
"This method was introduced in version 0.22.\n"
|
||||
) +
|
||||
gsi::method ("library", &db::Layout::library,
|
||||
"@brief Gets the library this layout lives in or nil if the layout is not part of a library\n"
|
||||
"This attribute has been introduced in version 0.27.5."
|
||||
) +
|
||||
gsi::method ("add_meta_info", &db::Layout::add_meta_info, gsi::arg ("info"),
|
||||
"@brief Adds meta information to the layout\n"
|
||||
"See \\LayoutMetaInfo for details about layouts and meta information."
|
||||
|
|
|
|||
|
|
@ -277,6 +277,10 @@ Class<db::PCellDeclaration> decl_PCellDeclaration_Native ("db", "PCellDeclaratio
|
|||
gsi::method ("parameters_from_shape", &db::PCellDeclaration::parameters_from_shape) +
|
||||
gsi::method ("transformation_from_shape", &db::PCellDeclaration::transformation_from_shape) +
|
||||
gsi::method ("display_text", &db::PCellDeclaration::get_display_name) +
|
||||
gsi::method ("layout", &db::PCellDeclaration::layout,
|
||||
"@brief Gets the Layout object the PCell is registered in or nil if it is not registered yet.\n"
|
||||
"This attribute has been added in version 0.27.5."
|
||||
) +
|
||||
gsi::method ("id", &db::PCellDeclaration::id,
|
||||
"@brief Gets the integer ID of the PCell declaration\n"
|
||||
"This ID is used to identify the PCell in the context of a Layout object for example"
|
||||
|
|
|
|||
|
|
@ -38,6 +38,10 @@ class DBLibrary_TestClass < TestBase
|
|||
lib_id = lib.id
|
||||
assert_equal(lib_id != 0, true)
|
||||
|
||||
# the layout inside the library knows the library
|
||||
assert_equal(lib.layout.library.id == lib.id, true)
|
||||
assert_equal(lib.layout.library.name, "RBA-unit-test")
|
||||
|
||||
assert_equal(RBA::Library::library_names.member?("RBA-unit-test"), true)
|
||||
assert_equal(RBA::Library::library_by_name("RBA-unit-test").id, lib_id)
|
||||
|
||||
|
|
|
|||
|
|
@ -588,6 +588,21 @@ class DBPCell_TestClass < TestBase
|
|||
|
||||
end
|
||||
|
||||
def test_9
|
||||
|
||||
layout = RBA::Layout::new
|
||||
|
||||
pcell = BoxPCell::new
|
||||
assert_equal(pcell.layout == nil, true)
|
||||
|
||||
# sets the layout reference of the PCell declaration:
|
||||
layout.register_pcell("Box", pcell)
|
||||
|
||||
assert_equal(pcell.layout == nil, false)
|
||||
assert_equal(pcell.layout.object_id == layout.object_id, true)
|
||||
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
load("test_epilogue.rb")
|
||||
|
|
|
|||
Loading…
Reference in New Issue