KiCad PCB EDA Suite
PNS::LOGGER Class Reference

#include <pns_logger.h>

Classes

struct  EVENT_ENTRY
 

Public Types

enum  EVENT_TYPE {
  EVT_START_ROUTE = 0, EVT_START_DRAG, EVT_FIX, EVT_MOVE,
  EVT_ABORT
}
 

Public Member Functions

 LOGGER ()
 
 ~LOGGER ()
 
void Save (const std::string &aFilename)
 
void Clear ()
 
void Log (EVENT_TYPE evt, VECTOR2I pos, const ITEM *item=nullptr)
 
const std::vector< EVENT_ENTRY > & GetEvents ()
 

Private Attributes

std::vector< EVENT_ENTRYm_events
 

Detailed Description

Definition at line 39 of file pns_logger.h.

Member Enumeration Documentation

◆ EVENT_TYPE

Enumerator
EVT_START_ROUTE 
EVT_START_DRAG 
EVT_FIX 
EVT_MOVE 
EVT_ABORT 

Definition at line 43 of file pns_logger.h.

Constructor & Destructor Documentation

◆ LOGGER()

PNS::LOGGER::LOGGER ( )

Definition at line 30 of file pns_logger.cpp.

31 {
32 }

◆ ~LOGGER()

PNS::LOGGER::~LOGGER ( )

Definition at line 35 of file pns_logger.cpp.

36 {
37 }

Member Function Documentation

◆ Clear()

void PNS::LOGGER::Clear ( )

Definition at line 40 of file pns_logger.cpp.

41 {
42  m_events.clear();
43 }
std::vector< EVENT_ENTRY > m_events
Definition: pns_logger.h:70

References m_events.

Referenced by PNS::SHOVE::ShoveLines(), PNS::SHOVE::ShoveMultiLines(), PNS::ROUTER::StartDragging(), and PNS::ROUTER::StartRouting().

◆ GetEvents()

const std::vector<EVENT_ENTRY>& PNS::LOGGER::GetEvents ( )
inline

Definition at line 64 of file pns_logger.h.

65  {
66  return m_events;
67  }
std::vector< EVENT_ENTRY > m_events
Definition: pns_logger.h:70

References m_events.

◆ Log()

void PNS::LOGGER::Log ( LOGGER::EVENT_TYPE  evt,
VECTOR2I  pos,
const ITEM item = nullptr 
)

Definition at line 64 of file pns_logger.cpp.

65 {
66  LOGGER::EVENT_ENTRY ent;
67 
68  ent.type = evt;
69  ent.p = pos;
70  ent.uuid = "null";
71 
72 
73  if( item && item->Parent() )
74  ent.uuid = item->Parent()->m_Uuid.AsString();
75 
76  m_events.push_back( ent );
77 }
std::vector< EVENT_ENTRY > m_events
Definition: pns_logger.h:70

References KIID::AsString(), m_events, EDA_ITEM::m_Uuid, PNS::LOGGER::EVENT_ENTRY::p, PNS::ITEM::Parent(), PNS::LOGGER::EVENT_ENTRY::type, and PNS::LOGGER::EVENT_ENTRY::uuid.

Referenced by PNS::ROUTER::FixRoute(), PNS::ROUTER::Move(), PNS::SHOVE::onCollidingVia(), PNS::SHOVE::onReverseCollidingVia(), PNS::ROUTER::StartDragging(), and PNS::ROUTER::StartRouting().

◆ Save()

void PNS::LOGGER::Save ( const std::string &  aFilename)

Definition at line 46 of file pns_logger.cpp.

47 {
48  FILE* f = fopen( aFilename.c_str(), "wb" );
49 
50  wxLogTrace( "PNS", "Saving to '%s' [%p]", aFilename.c_str(), f );
51 
52  for( const EVENT_ENTRY& evt : m_events )
53  {
54  uint64_t id = 0;
55 
56  fprintf( f, "event %d %d %d %s\n", evt.type, evt.p.x, evt.p.y,
57  (const char*) evt.uuid.c_str() );
58  }
59 
60  fclose( f );
61 }
std::vector< EVENT_ENTRY > m_events
Definition: pns_logger.h:70

References m_events.

Member Data Documentation

◆ m_events

std::vector<EVENT_ENTRY> PNS::LOGGER::m_events
private

Definition at line 70 of file pns_logger.h.

Referenced by Clear(), GetEvents(), Log(), and Save().


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