KiCad PCB EDA Suite
LIB_MANAGER::PART_BUFFER Class Reference

Class to store a working copy of a LIB_PART object and editor context.

More...

Public Types

typedef std::shared_ptr< PART_BUFFERPTR
 
typedef std::weak_ptr< PART_BUFFERWEAK_PTR
 

Public Member Functions

 PART_BUFFER (LIB_PART *aPart=nullptr, std::unique_ptr< SCH_SCREEN > aScreen=nullptr)
 
 ~PART_BUFFER ()
 
LIB_PARTGetPart () const
 
void SetPart (LIB_PART *aPart)
 
LIB_PARTGetOriginal () const
 
void SetOriginal (LIB_PART *aPart)
 
bool IsModified () const
 
SCH_SCREENGetScreen () const
 
std::unique_ptr< SCH_SCREENRemoveScreen ()
 

Transfer the screen ownership

More...
 
bool SetScreen (std::unique_ptr< SCH_SCREEN > aScreen)
 

Private Attributes

std::unique_ptr< SCH_SCREENm_screen
 
LIB_PARTm_part
 

Working copy

More...
 
LIB_PARTm_original
 

Initial state of the part

More...
 

Detailed Description

Class to store a working copy of a LIB_PART object and editor context.

Definition at line 291 of file lib_manager.h.

Member Typedef Documentation

typedef std::shared_ptr<PART_BUFFER> LIB_MANAGER::PART_BUFFER::PTR

Definition at line 319 of file lib_manager.h.

Definition at line 320 of file lib_manager.h.

Constructor & Destructor Documentation

LIB_MANAGER::PART_BUFFER::PART_BUFFER ( LIB_PART aPart = nullptr,
std::unique_ptr< SCH_SCREEN aScreen = nullptr 
)

Definition at line 712 of file lib_manager.cpp.

References m_original.

713  : m_screen( std::move( aScreen ) ), m_part( aPart )
714 {
715  m_original = new LIB_PART( *aPart );
716 }
std::unique_ptr< SCH_SCREEN > m_screen
Definition: lib_manager.h:323
LIB_PART * m_part
Working copy
Definition: lib_manager.h:326
Define a library symbol object.
LIB_PART * m_original
Initial state of the part
Definition: lib_manager.h:329
LIB_MANAGER::PART_BUFFER::~PART_BUFFER ( )

Definition at line 719 of file lib_manager.cpp.

References m_original, and m_part.

720 {
721  delete m_part;
722  delete m_original;
723 }
LIB_PART * m_part
Working copy
Definition: lib_manager.h:326
LIB_PART * m_original
Initial state of the part
Definition: lib_manager.h:329

Member Function Documentation

LIB_PART* LIB_MANAGER::PART_BUFFER::GetOriginal ( ) const
inline

Definition at line 300 of file lib_manager.h.

References IsModified(), m_original, and SetOriginal().

300 { return m_original; }
LIB_PART * m_original
Initial state of the part
Definition: lib_manager.h:329
LIB_PART* LIB_MANAGER::PART_BUFFER::GetPart ( ) const
inline

Definition at line 297 of file lib_manager.h.

References m_part, and SetPart().

297 { return m_part; }
LIB_PART * m_part
Working copy
Definition: lib_manager.h:326
SCH_SCREEN* LIB_MANAGER::PART_BUFFER::GetScreen ( ) const
inline

Definition at line 304 of file lib_manager.h.

References m_screen.

304 { return m_screen.get(); }
std::unique_ptr< SCH_SCREEN > m_screen
Definition: lib_manager.h:323
bool LIB_MANAGER::PART_BUFFER::IsModified ( ) const

Definition at line 758 of file lib_manager.cpp.

References m_screen.

Referenced by GetOriginal().

759 {
760  return m_screen && m_screen->IsModify();
761 }
std::unique_ptr< SCH_SCREEN > m_screen
Definition: lib_manager.h:323
std::unique_ptr<SCH_SCREEN> LIB_MANAGER::PART_BUFFER::RemoveScreen ( )
inline

Transfer the screen ownership

Definition at line 307 of file lib_manager.h.

References m_screen.

308  {
309  return std::move( m_screen );
310  }
std::unique_ptr< SCH_SCREEN > m_screen
Definition: lib_manager.h:323
void LIB_MANAGER::PART_BUFFER::SetOriginal ( LIB_PART aPart)

Definition at line 742 of file lib_manager.cpp.

References LIB_PART::GetLibId(), LIB_ID::GetLibItemName(), LIB_ID::GetLibNickname(), m_original, m_part, and LIB_PART::SetLibId().

Referenced by GetOriginal().

743 {
744  wxCHECK( m_original != aPart, /* void */ );
745  wxASSERT( aPart );
746  delete m_original;
747  m_original = aPart;
748 
749  // The original is not allowed to have a different library than its part
751  {
754  }
755 }
LIB_PART * m_part
Working copy
Definition: lib_manager.h:326
const LIB_ID & GetLibId() const
A logical library item identifier and consists of various portions much like a URI.
Definition: lib_id.h:51
const UTF8 & GetLibItemName() const
Definition: lib_id.h:114
LIB_PART * m_original
Initial state of the part
Definition: lib_manager.h:329
const UTF8 & GetLibNickname() const
Return the logical library name portion of a LIB_ID.
Definition: lib_id.h:97
void SetLibId(const LIB_ID &aLibId)
void LIB_MANAGER::PART_BUFFER::SetPart ( LIB_PART aPart)

Definition at line 726 of file lib_manager.cpp.

References LIB_PART::GetLibId(), LIB_ID::GetLibItemName(), LIB_ID::GetLibNickname(), m_original, m_part, and LIB_PART::SetLibId().

Referenced by GetPart().

727 {
728  wxCHECK( m_part != aPart, /* void */ );
729  wxASSERT( aPart );
730  delete m_part;
731  m_part = aPart;
732 
733  // If the part moves libraries then the original moves with it
735  {
738  }
739 }
LIB_PART * m_part
Working copy
Definition: lib_manager.h:326
const LIB_ID & GetLibId() const
A logical library item identifier and consists of various portions much like a URI.
Definition: lib_id.h:51
const UTF8 & GetLibItemName() const
Definition: lib_id.h:114
LIB_PART * m_original
Initial state of the part
Definition: lib_manager.h:329
const UTF8 & GetLibNickname() const
Return the logical library name portion of a LIB_ID.
Definition: lib_id.h:97
void SetLibId(const LIB_ID &aLibId)
bool LIB_MANAGER::PART_BUFFER::SetScreen ( std::unique_ptr< SCH_SCREEN aScreen)
inline

Definition at line 312 of file lib_manager.h.

References m_screen.

313  {
314  bool ret = !!m_screen;
315  m_screen = std::move( aScreen );
316  return ret;
317  }
std::unique_ptr< SCH_SCREEN > m_screen
Definition: lib_manager.h:323

Member Data Documentation

LIB_PART* LIB_MANAGER::PART_BUFFER::m_original
private

Initial state of the part

Definition at line 329 of file lib_manager.h.

Referenced by GetOriginal(), PART_BUFFER(), SetOriginal(), SetPart(), and ~PART_BUFFER().

LIB_PART* LIB_MANAGER::PART_BUFFER::m_part
private

Working copy

Definition at line 326 of file lib_manager.h.

Referenced by GetPart(), SetOriginal(), SetPart(), and ~PART_BUFFER().

std::unique_ptr<SCH_SCREEN> LIB_MANAGER::PART_BUFFER::m_screen
private

Definition at line 323 of file lib_manager.h.

Referenced by GetScreen(), IsModified(), RemoveScreen(), and SetScreen().


The documentation for this class was generated from the following files: