From 80999475f4383fac32a127034ec380f3fca6bd98 Mon Sep 17 00:00:00 2001 From: Matthias Koefferlein Date: Fri, 21 Dec 2018 21:47:27 +0100 Subject: [PATCH] Added trans and name attributes to db::SubCircuit --- src/db/db/dbNetlist.cc | 10 ++++++++ src/db/db/dbNetlist.h | 36 +++++++++++++++++++++++++++++ src/db/unit_tests/dbNetlistTests.cc | 14 +++++++++++ 3 files changed, 60 insertions(+) diff --git a/src/db/db/dbNetlist.cc b/src/db/db/dbNetlist.cc index 7cb00d18e..8305b9167 100644 --- a/src/db/db/dbNetlist.cc +++ b/src/db/db/dbNetlist.cc @@ -68,6 +68,16 @@ SubCircuit::SubCircuit (Circuit *circuit) // .. nothing yet .. } +void SubCircuit::set_name (const std::string &n) +{ + m_name = n; +} + +void SubCircuit::set_trans (const db::DCplxTrans &t) +{ + m_trans = t; +} + // -------------------------------------------------------------------------------- // NetPortRef class implementation diff --git a/src/db/db/dbNetlist.h b/src/db/db/dbNetlist.h index 4e4d90de9..c238fe9ce 100644 --- a/src/db/db/dbNetlist.h +++ b/src/db/db/dbNetlist.h @@ -25,6 +25,7 @@ #include "dbCommon.h" #include "dbTypes.h" +#include "dbTrans.h" #include "tlObjectCollection.h" #include "tlVector.h" @@ -183,8 +184,43 @@ public: m_circuit.reset (c); } + /** + * @brief Sets the name of the subcircuit + * + * The name is one way to identify the subcircuit. The transformation is + * another one. + */ + void set_name (const std::string &n); + + /** + * @brief Gets the name of the subcircuit + */ + const std::string &name () const + { + return m_name; + } + + /** + * @brief Sets the transformation describing the subcircuit + * + * The transformation is a natural description of a subcircuit + * (in contrast to the name) when deriving it from a layout. + */ + void set_trans (const db::DCplxTrans &trans); + + /** + * @brief Gets the transformation describing the subcircuit + */ + const db::DCplxTrans &trans () const + { + return m_trans; + } + + private: tl::weak_ptr m_circuit; + std::string m_name; + db::DCplxTrans m_trans; }; /** diff --git a/src/db/unit_tests/dbNetlistTests.cc b/src/db/unit_tests/dbNetlistTests.cc index c13d22e09..cc2653a15 100644 --- a/src/db/unit_tests/dbNetlistTests.cc +++ b/src/db/unit_tests/dbNetlistTests.cc @@ -306,3 +306,17 @@ TEST(4_NetlistSubcircuits) "D:B,+c2p2\n" ); } + +TEST(5_SubCircuit) +{ + db::SubCircuit sc, sc2; + + sc.set_name ("sc"); + EXPECT_EQ (sc.name (), "sc"); + sc.set_trans (db::DCplxTrans (2.5)); + EXPECT_EQ (sc.trans ().to_string (), "r0 *2.5 0,0"); + + sc2 = sc; + EXPECT_EQ (sc2.name (), "sc"); + EXPECT_EQ (sc2.trans ().to_string (), "r0 *2.5 0,0"); +}