48 std::unique_ptr<LIB_SYMBOL> symbol = std::make_unique<LIB_SYMBOL>( wxS(
"Symbol" ) );
49 std::unique_ptr<SCH_SCREEN> screen = std::make_unique<SCH_SCREEN>();
53 SYMBOL_BUFFER buffer( std::move( symbol ), std::move( screen ) );
56 BOOST_CHECK( &buffer.
GetSymbol() == &symbolRef );
62 std::unique_ptr<LIB_SYMBOL> originalSymbol =
63 std::make_unique<LIB_SYMBOL>( wxS(
"OriginalSymbol" ) );
64 LIB_SYMBOL& originalSymbolRef = *originalSymbol;
68 BOOST_CHECK( &buffer.
GetOriginal() == &originalSymbolRef );
69 BOOST_CHECK( buffer.
GetOriginal() == originalSymbolRef );
79 wxArrayString symbolNames;
83 BOOST_CHECK_EQUAL( libBuffer.
GetHash(), 1 );
85 auto parentSymbol1 = std::make_unique<LIB_SYMBOL>( wxS(
"Parent1" ) );
90 BOOST_CHECK_EQUAL( libBuffer.
GetSymbol( parentSymbol1->GetName() ),
nullptr );
92 parentSymbol1->GetValueField().SetText( parentSymbol1->GetName() );
93 libBuffer.
CreateBuffer( std::move( parentSymbol1 ), std::make_unique<SCH_SCREEN>() );
94 BOOST_CHECK( libBuffer.
GetSymbol( parentSymbol1Ref.
GetName() ) == &parentSymbol1Ref );
96 BOOST_CHECK_EQUAL( libBuffer.
GetHash(), 2 );
99 BOOST_CHECK_EQUAL( symbolNames.GetCount(), 1 );
100 BOOST_CHECK_EQUAL( symbolNames[0], parentSymbol1Ref.
GetName() );
104 BOOST_CHECK_EQUAL( symbolNames.GetCount(), 1 );
105 BOOST_CHECK_EQUAL( symbolNames[0], parentSymbol1Ref.
GetName() );
109 BOOST_CHECK_EQUAL( symbolNames.GetCount(), 0 );
111 auto childSymbol1 = std::make_unique<LIB_SYMBOL>( wxS(
"Child1" ) );
114 childSymbol1->
SetParent( &parentSymbol1Ref );
115 childSymbol1->GetValueField().SetText( childSymbol1->GetName() );
116 libBuffer.
CreateBuffer( std::move( childSymbol1 ), std::make_unique<SCH_SCREEN>() );
117 BOOST_CHECK( libBuffer.
GetSymbol( childSymbol1Ref.
GetName() ) == &childSymbol1Ref );
119 BOOST_CHECK_EQUAL( libBuffer.
GetHash(), 3 );
123 BOOST_CHECK_EQUAL( symbolNames.GetCount(), 2 );
124 BOOST_CHECK_EQUAL( symbolNames[0], parentSymbol1Ref.
GetName() );
125 BOOST_CHECK_EQUAL( symbolNames[1], childSymbol1Ref.
GetName() );
129 BOOST_CHECK_EQUAL( symbolNames.GetCount(), 1 );
130 BOOST_CHECK_EQUAL( symbolNames[0], childSymbol1Ref.
GetName() );
135 BOOST_CHECK_EQUAL( symbolNames[0], childSymbol1Ref.
GetName() );
137 std::shared_ptr<SYMBOL_BUFFER> buf = libBuffer.
GetBuffer( parentSymbol1Ref.
GetName() );
143 BOOST_CHECK_EQUAL( libBuffer.
GetHash(), 4 );
147 BOOST_CHECK( deletedOk );
148 BOOST_CHECK( libBuffer.
GetBuffers().empty() );
void SetContentModified(bool aModified=true)
size_t GetDerivedSymbolNames(const wxString &aSymbolName, wxArrayString &aList)
Fetch all of the symbols derived from a aSymbolName into aList.
bool CreateBuffer(std::unique_ptr< LIB_SYMBOL > aCopy, std::unique_ptr< SCH_SCREEN > aScreen)
Update the buffered symbol with the contents of aCopy.
bool DeleteBuffer(const SYMBOL_BUFFER &aSymbolBuf)
Delete the given symbol buffer from the library buffer.
void GetSymbolNames(wxArrayString &aSymbolNames, SYMBOL_NAME_FILTER aFilter=SYMBOL_NAME_FILTER::ALL)
Fetch a list of root symbols names from the library buffer.
const std::deque< std::shared_ptr< SYMBOL_BUFFER > > & GetBuffers() const
std::shared_ptr< SYMBOL_BUFFER > GetBuffer(const wxString &aAlias) const
Return all buffered symbols.
LIB_SYMBOL * GetSymbol(const wxString &aAlias) const
Create a new buffer to store a symbol. LIB_BUFFER takes ownership of aCopy.
int GetHash() const
Return the working copy of a LIB_SYMBOL root object with specified alias.
bool HasDerivedSymbols(const wxString &aParentName) const
Check to see any symbols in the buffer are derived from a parent named aParentName.
bool UpdateBuffer(SYMBOL_BUFFER &aSymbolBuf, const LIB_SYMBOL &aCopy)
Define a library symbol object.
void SetParent(LIB_SYMBOL *aParent=nullptr)
wxString GetName() const override
SCH_FIELD & GetDescriptionField() const
Return reference to the description field.
void SetText(const wxString &aText) override
Store a working copy of a library.
LIB_SYMBOL & GetSymbol() const
SCH_SCREEN * GetScreen() const
LIB_SYMBOL & GetOriginal() const
void SetOriginal(std::unique_ptr< LIB_SYMBOL > aSymbol)
SYMBOL_LIBRARY_MANAGER_TEST_FIXTURE()
BOOST_AUTO_TEST_SUITE_END()
BOOST_AUTO_TEST_CASE(SymbolBuffer)
Test the SYMBOL_BUFFER object.