mirror of https://github.com/KLayout/klayout.git
Fixed an issue with the deep region: the layout pointer is not a good key for the backannotation cache. So we better use the unique ID - a concept introduced herein.
This commit is contained in:
parent
ef0e0d38c2
commit
7ceb4ed076
|
|
@ -320,7 +320,7 @@ DeepShapeStore::insert (const DeepLayer &deep_layer, db::Layout *into_layout, db
|
||||||
|
|
||||||
// derive a cell mapping for source to target. We employ a
|
// derive a cell mapping for source to target. We employ a
|
||||||
|
|
||||||
DeliveryMappingCacheKey key (deep_layer.layout_index (), into_layout, into_cell);
|
DeliveryMappingCacheKey key (deep_layer.layout_index (), tl::id_of (into_layout), into_cell);
|
||||||
|
|
||||||
std::map<DeliveryMappingCacheKey, db::CellMapping>::iterator cm = m_delivery_mapping_cache.find (key);
|
std::map<DeliveryMappingCacheKey, db::CellMapping>::iterator cm = m_delivery_mapping_cache.find (key);
|
||||||
if (cm == m_delivery_mapping_cache.end ()) {
|
if (cm == m_delivery_mapping_cache.end ()) {
|
||||||
|
|
|
||||||
|
|
@ -301,7 +301,7 @@ private:
|
||||||
{
|
{
|
||||||
// NOTE: we shouldn't keep pointers here as the layouts may get deleted and recreated with the same address.
|
// NOTE: we shouldn't keep pointers here as the layouts may get deleted and recreated with the same address.
|
||||||
// But as we don't access these objects that's fairly safe.
|
// But as we don't access these objects that's fairly safe.
|
||||||
DeliveryMappingCacheKey (unsigned int _from_index, db::Layout *_into_layout, db::cell_index_type _into_cell)
|
DeliveryMappingCacheKey (unsigned int _from_index, tl::id_type _into_layout, db::cell_index_type _into_cell)
|
||||||
: from_index (_from_index), into_layout (_into_layout), into_cell (_into_cell)
|
: from_index (_from_index), into_layout (_into_layout), into_cell (_into_cell)
|
||||||
{
|
{
|
||||||
// .. nothing yet ..
|
// .. nothing yet ..
|
||||||
|
|
@ -319,7 +319,7 @@ private:
|
||||||
}
|
}
|
||||||
|
|
||||||
unsigned int from_index;
|
unsigned int from_index;
|
||||||
db::Layout *into_layout;
|
tl::id_type into_layout;
|
||||||
db::cell_index_type into_cell;
|
db::cell_index_type into_cell;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -40,6 +40,7 @@
|
||||||
#include "tlString.h"
|
#include "tlString.h"
|
||||||
#include "tlThreads.h"
|
#include "tlThreads.h"
|
||||||
#include "tlObject.h"
|
#include "tlObject.h"
|
||||||
|
#include "tlUniqueId.h"
|
||||||
#include "gsi.h"
|
#include "gsi.h"
|
||||||
|
|
||||||
#include <cstring>
|
#include <cstring>
|
||||||
|
|
@ -460,7 +461,8 @@ class DB_PUBLIC Layout
|
||||||
: public db::Object,
|
: public db::Object,
|
||||||
public db::LayoutStateModel,
|
public db::LayoutStateModel,
|
||||||
public gsi::ObjectBase,
|
public gsi::ObjectBase,
|
||||||
public tl::Object
|
public tl::Object,
|
||||||
|
public tl::UniqueId
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
typedef db::Box box_type;
|
typedef db::Box box_type;
|
||||||
|
|
|
||||||
|
|
@ -41,7 +41,8 @@ SOURCES = \
|
||||||
tlThreads.cc \
|
tlThreads.cc \
|
||||||
tlDeferredExecution.cc \
|
tlDeferredExecution.cc \
|
||||||
tlUri.cc \
|
tlUri.cc \
|
||||||
tlLongInt.cc
|
tlLongInt.cc \
|
||||||
|
tlUniqueId.cc
|
||||||
|
|
||||||
HEADERS = \
|
HEADERS = \
|
||||||
tlAlgorithm.h \
|
tlAlgorithm.h \
|
||||||
|
|
@ -92,7 +93,8 @@ HEADERS = \
|
||||||
tlThreads.h \
|
tlThreads.h \
|
||||||
tlDeferredExecution.h \
|
tlDeferredExecution.h \
|
||||||
tlUri.h \
|
tlUri.h \
|
||||||
tlLongInt.h
|
tlLongInt.h \
|
||||||
|
tlUniqueId.h
|
||||||
|
|
||||||
equals(HAVE_CURL, "1") {
|
equals(HAVE_CURL, "1") {
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,43 @@
|
||||||
|
|
||||||
|
/*
|
||||||
|
|
||||||
|
KLayout Layout Viewer
|
||||||
|
Copyright (C) 2006-2018 Matthias Koefferlein
|
||||||
|
|
||||||
|
This program is free software; you can redistribute it and/or modify
|
||||||
|
it under the terms of the GNU General Public License as published by
|
||||||
|
the Free Software Foundation; either version 2 of the License, or
|
||||||
|
(at your option) any later version.
|
||||||
|
|
||||||
|
This program is distributed in the hope that it will be useful,
|
||||||
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
GNU General Public License for more details.
|
||||||
|
|
||||||
|
You should have received a copy of the GNU General Public License
|
||||||
|
along with this program; if not, write to the Free Software
|
||||||
|
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||||
|
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
#include "tlUniqueId.h"
|
||||||
|
#include "tlThreads.h"
|
||||||
|
|
||||||
|
namespace tl
|
||||||
|
{
|
||||||
|
|
||||||
|
static tl::Mutex s_lock;
|
||||||
|
static id_type s_next_id = 0;
|
||||||
|
|
||||||
|
UniqueId::UniqueId ()
|
||||||
|
{
|
||||||
|
tl::MutexLocker locker (&s_lock);
|
||||||
|
do {
|
||||||
|
m_id = ++s_next_id;
|
||||||
|
} while (m_id == 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
} // namespace tl
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -0,0 +1,81 @@
|
||||||
|
|
||||||
|
/*
|
||||||
|
|
||||||
|
KLayout Layout Viewer
|
||||||
|
Copyright (C) 2006-2018 Matthias Koefferlein
|
||||||
|
|
||||||
|
This program is free software; you can redistribute it and/or modify
|
||||||
|
it under the terms of the GNU General Public License as published by
|
||||||
|
the Free Software Foundation; either version 2 of the License, or
|
||||||
|
(at your option) any later version.
|
||||||
|
|
||||||
|
This program is distributed in the hope that it will be useful,
|
||||||
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
GNU General Public License for more details.
|
||||||
|
|
||||||
|
You should have received a copy of the GNU General Public License
|
||||||
|
along with this program; if not, write to the Free Software
|
||||||
|
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||||
|
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
#ifndef HDR_tlUniqueId
|
||||||
|
#define HDR_tlUniqueId
|
||||||
|
|
||||||
|
#include "tlCommon.h"
|
||||||
|
#include <cstdint>
|
||||||
|
|
||||||
|
namespace tl
|
||||||
|
{
|
||||||
|
|
||||||
|
typedef uint64_t id_type;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief An object delivering a unique ID per object
|
||||||
|
*
|
||||||
|
* This class is supposed to provide a solution for the non-uniqueness
|
||||||
|
* issue of addresses. Instead of using addresses as keys, use the unique
|
||||||
|
* ID. The advantage is to be reproducible and guaranteed to be different
|
||||||
|
* for each allocation of an object (apart from overflow wrapping at 64bit -
|
||||||
|
* this this is pretty unlikely event).
|
||||||
|
*
|
||||||
|
* To supply an ID, derive your class from tl::UniqueId. Use
|
||||||
|
* "tl::id_of (object *)" the get the ID from that object.
|
||||||
|
* A null-pointer will give an ID of 0 which is reserved for
|
||||||
|
* "nothing".
|
||||||
|
*
|
||||||
|
* The type of the ID is tl::id_type.
|
||||||
|
*/
|
||||||
|
class TL_PUBLIC UniqueId
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
/**
|
||||||
|
* @brief @brief Creates a new object with a new ID
|
||||||
|
*/
|
||||||
|
UniqueId ();
|
||||||
|
|
||||||
|
UniqueId (const UniqueId &) { }
|
||||||
|
UniqueId &operator= (const UniqueId &) { return *this; }
|
||||||
|
|
||||||
|
private:
|
||||||
|
friend id_type id_of (const UniqueId *);
|
||||||
|
|
||||||
|
id_type m_id;
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Gets the ID of the object pointed to by o
|
||||||
|
*
|
||||||
|
* Returns 0 in a null pointer and only then.
|
||||||
|
*/
|
||||||
|
inline id_type id_of (const UniqueId *o)
|
||||||
|
{
|
||||||
|
return o ? o->m_id : 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
} // namespace tl
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
@ -0,0 +1,51 @@
|
||||||
|
|
||||||
|
/*
|
||||||
|
|
||||||
|
KLayout Layout Viewer
|
||||||
|
Copyright (C) 2006-2018 Matthias Koefferlein
|
||||||
|
|
||||||
|
This program is free software; you can redistribute it and/or modify
|
||||||
|
it under the terms of the GNU General Public License as published by
|
||||||
|
the Free Software Foundation; either version 2 of the License, or
|
||||||
|
(at your option) any later version.
|
||||||
|
|
||||||
|
This program is distributed in the hope that it will be useful,
|
||||||
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
GNU General Public License for more details.
|
||||||
|
|
||||||
|
You should have received a copy of the GNU General Public License
|
||||||
|
along with this program; if not, write to the Free Software
|
||||||
|
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||||
|
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include "tlUniqueId.h"
|
||||||
|
#include "tlUnitTest.h"
|
||||||
|
|
||||||
|
#include <memory>
|
||||||
|
|
||||||
|
namespace {
|
||||||
|
class MyClass : public tl::UniqueId {
|
||||||
|
public:
|
||||||
|
MyClass () { }
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
// basic parsing ability
|
||||||
|
TEST(1)
|
||||||
|
{
|
||||||
|
tl::id_type id, id0;
|
||||||
|
|
||||||
|
id = tl::id_of (0);
|
||||||
|
EXPECT_EQ (id, tl::id_type (0));
|
||||||
|
|
||||||
|
std::auto_ptr<MyClass> ptr;
|
||||||
|
ptr.reset (new MyClass ());
|
||||||
|
id0 = id = tl::id_of (ptr.get ());
|
||||||
|
EXPECT_NE (id, tl::id_type (0));
|
||||||
|
|
||||||
|
ptr.reset (new MyClass ());
|
||||||
|
id = tl::id_of (ptr.get ());
|
||||||
|
EXPECT_EQ (id, id0 + 1);
|
||||||
|
}
|
||||||
|
|
@ -35,6 +35,7 @@ SOURCES = \
|
||||||
tlHttpStream.cc \
|
tlHttpStream.cc \
|
||||||
tlInt128Support.cc \
|
tlInt128Support.cc \
|
||||||
tlLongInt.cc \
|
tlLongInt.cc \
|
||||||
|
tlUniqueIdTests.cc
|
||||||
|
|
||||||
!equals(HAVE_QT, "0") {
|
!equals(HAVE_QT, "0") {
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue