Added trans and name attributes to db::SubCircuit

This commit is contained in:
Matthias Koefferlein 2018-12-21 21:47:27 +01:00
parent 4dd17c3cd4
commit 80999475f4
3 changed files with 60 additions and 0 deletions

View File

@ -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

View File

@ -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<Circuit> m_circuit;
std::string m_name;
db::DCplxTrans m_trans;
};
/**

View File

@ -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");
}