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

◆ PTR

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

Definition at line 319 of file lib_manager.h.

◆ WEAK_PTR

Definition at line 320 of file lib_manager.h.

Constructor & Destructor Documentation

◆ PART_BUFFER()

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

Definition at line 716 of file lib_manager.cpp.

717  : m_screen( std::move( aScreen ) ), m_part( aPart )
718 {
719  m_original = new LIB_PART( *aPart );
720 }
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

References m_original.

◆ ~PART_BUFFER()

LIB_MANAGER::PART_BUFFER::~PART_BUFFER ( )

Definition at line 723 of file lib_manager.cpp.

724 {
725  delete m_part;
726  delete m_original;
727 }
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

◆ GetOriginal()

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

Definition at line 300 of file lib_manager.h.

300 { return m_original; }
LIB_PART * m_original
Initial state of the part
Definition: lib_manager.h:329

References m_original.

◆ GetPart()

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

Definition at line 297 of file lib_manager.h.

297 { return m_part; }
LIB_PART * m_part
Working copy
Definition: lib_manager.h:326

References m_part.

◆ GetScreen()

SCH_SCREEN* LIB_MANAGER::PART_BUFFER::GetScreen ( ) const
inline

Definition at line 304 of file lib_manager.h.

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

References m_screen.

◆ IsModified()

bool LIB_MANAGER::PART_BUFFER::IsModified ( ) const

Definition at line 762 of file lib_manager.cpp.

763 {
764  return m_screen && m_screen->IsModify();
765 }
std::unique_ptr< SCH_SCREEN > m_screen
Definition: lib_manager.h:323

◆ RemoveScreen()

std::unique_ptr<SCH_SCREEN> LIB_MANAGER::PART_BUFFER::RemoveScreen ( )
inline

Transfer the screen ownership

Definition at line 307 of file lib_manager.h.

308  {
309  return std::move( m_screen );
310  }
std::unique_ptr< SCH_SCREEN > m_screen
Definition: lib_manager.h:323

References m_screen.

◆ SetOriginal()

void LIB_MANAGER::PART_BUFFER::SetOriginal ( LIB_PART aPart)

Definition at line 746 of file lib_manager.cpp.

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

References LIB_PART::SetLibId().

◆ SetPart()

void LIB_MANAGER::PART_BUFFER::SetPart ( LIB_PART aPart)

Definition at line 730 of file lib_manager.cpp.

731 {
732  wxCHECK( m_part != aPart, /* void */ );
733  wxASSERT( aPart );
734  delete m_part;
735  m_part = aPart;
736 
737  // If the part moves libraries then the original moves with it
739  {
742  }
743 }
const UTF8 & GetLibItemName() const
Definition: lib_id.h:114
LIB_PART * m_part
Working copy
Definition: lib_manager.h:326
A logical library item identifier and consists of various portions much like a URI.
Definition: lib_id.h:51
const LIB_ID & GetLibId() const
const UTF8 & GetLibNickname() const
Return the logical library name portion of a LIB_ID.
Definition: lib_id.h:97
LIB_PART * m_original
Initial state of the part
Definition: lib_manager.h:329
void SetLibId(const LIB_ID &aLibId)

References LIB_PART::SetLibId().

◆ SetScreen()

bool LIB_MANAGER::PART_BUFFER::SetScreen ( std::unique_ptr< SCH_SCREEN aScreen)
inline

Definition at line 312 of file lib_manager.h.

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

References m_screen.

Member Data Documentation

◆ m_original

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(), and PART_BUFFER().

◆ m_part

LIB_PART* LIB_MANAGER::PART_BUFFER::m_part
private

Working copy

Definition at line 326 of file lib_manager.h.

Referenced by GetPart().

◆ m_screen

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

Definition at line 323 of file lib_manager.h.

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


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