diff --git a/3d-viewer/3d_cache/3d_cache_wrapper.h b/3d-viewer/3d_cache/3d_cache_wrapper.h index 60051d21af..35941bd8ce 100644 --- a/3d-viewer/3d_cache/3d_cache_wrapper.h +++ b/3d-viewer/3d_cache/3d_cache_wrapper.h @@ -30,6 +30,8 @@ class CACHE_WRAPPER : public S3D_CACHE, public PROJECT::_ELEM { public: + KICAD_T Type() override { return CACHE_WRAPPER_T; } + CACHE_WRAPPER(); virtual ~CACHE_WRAPPER(); }; diff --git a/common/project.cpp b/common/project.cpp index 49dc8f63d2..105e5096b4 100644 --- a/common/project.cpp +++ b/common/project.cpp @@ -401,7 +401,7 @@ FP_LIB_TABLE* PROJECT::PcbFootprintLibs( KIWAY& aKiway ) FP_LIB_TABLE* tbl = (FP_LIB_TABLE*) GetElem( ELEM_FPTBL ); // its gotta be NULL or a FP_LIB_TABLE, or a bug. - wxASSERT( !tbl || dynamic_cast( tbl ) ); + wxASSERT( !tbl || tbl->Type() == FP_LIB_TABLE_T ); if( !tbl ) { diff --git a/eeschema/class_library.h b/eeschema/class_library.h index 6f2e5620d2..821c68d899 100644 --- a/eeschema/class_library.h +++ b/eeschema/class_library.h @@ -189,8 +189,9 @@ typedef boost::ptr_vector< PART_LIB > PART_LIBS_BASE; class PART_LIBS : public PART_LIBS_BASE, public PROJECT::_ELEM { public: + KICAD_T Type() override { return PART_LIBS_T; } - static int s_modify_generation; ///< helper for GetModifyHash() + static int s_modify_generation; ///< helper for GetModifyHash() PART_LIBS() { diff --git a/eeschema/eeschema_config.cpp b/eeschema/eeschema_config.cpp index 819f5be857..586de4864d 100644 --- a/eeschema/eeschema_config.cpp +++ b/eeschema/eeschema_config.cpp @@ -641,7 +641,7 @@ SYMBOL_LIB_TABLE* PROJECT::SchSymbolLibTable() SYMBOL_LIB_TABLE* tbl = (SYMBOL_LIB_TABLE*) GetElem( ELEM_SYMBOL_LIB_TABLE ); // its gotta be NULL or a SYMBOL_LIB_TABLE, or a bug. - wxASSERT( !tbl || dynamic_cast( tbl ) ); + wxASSERT( !tbl || tbl->Type() == SYMBOL_LIB_TABLE_T ); if( !tbl ) { diff --git a/eeschema/sch_edit_frame.cpp b/eeschema/sch_edit_frame.cpp index 80dfee6288..16d6bef643 100644 --- a/eeschema/sch_edit_frame.cpp +++ b/eeschema/sch_edit_frame.cpp @@ -154,9 +154,9 @@ SEARCH_STACK* PROJECT::SchSearchS() PART_LIBS* PROJECT::SchLibs() { - PART_LIBS* libs = (PART_LIBS*) GetElem( PROJECT::ELEM_SCH_PART_LIBS ); + PART_LIBS* libs = (PART_LIBS*) GetElem( PROJECT::ELEM_SCH_PART_LIBS ); - wxASSERT( !libs || dynamic_cast( libs ) ); + wxASSERT( !libs || libs->Type() == PART_LIBS_T ); if( !libs ) { diff --git a/eeschema/symbol_lib_table.h b/eeschema/symbol_lib_table.h index e780d77eca..7dcc812883 100644 --- a/eeschema/symbol_lib_table.h +++ b/eeschema/symbol_lib_table.h @@ -107,6 +107,8 @@ class SYMBOL_LIB_TABLE : public LIB_TABLE static int m_modifyHash; ///< helper for GetModifyHash() public: + KICAD_T Type() override { return SYMBOL_LIB_TABLE_T; } + static const char* PropPowerSymsOnly; static const char* PropNonPowerSymsOnly; diff --git a/include/core/typeinfo.h b/include/core/typeinfo.h index 537171348b..4c176239f6 100644 --- a/include/core/typeinfo.h +++ b/include/core/typeinfo.h @@ -169,6 +169,15 @@ enum KICAD_T */ TYPE_PL_EDITOR_LAYOUT, + /* + * FOR PROJECT::_ELEMs + */ + SYMBOL_LIB_TABLE_T, + FP_LIB_TABLE_T, + PART_LIBS_T, + SEARCH_STACK_T, + CACHE_WRAPPER_T, + // End value MAX_STRUCT_TYPE_ID }; diff --git a/include/fp_lib_table.h b/include/fp_lib_table.h index 0ec94ac742..bf7e8a2175 100644 --- a/include/fp_lib_table.h +++ b/include/fp_lib_table.h @@ -105,6 +105,7 @@ class FP_LIB_TABLE : public LIB_TABLE friend class FP_LIB_TABLE_GRID; public: + KICAD_T Type() override { return FP_LIB_TABLE_T; } virtual void Parse( LIB_TABLE_LEXER* aLexer ) override; diff --git a/include/project.h b/include/project.h index 0124f99cfc..1035f51965 100644 --- a/include/project.h +++ b/include/project.h @@ -30,6 +30,7 @@ #include #include #include +#include /// A variable name whose value holds the current project directory. /// Currently an environment variable, eventually a project variable. @@ -67,6 +68,8 @@ public: { public: virtual ~_ELEM() {} + + virtual KICAD_T Type() = 0; // Sanity-checking for returned values. }; PROJECT(); diff --git a/include/search_stack.h b/include/search_stack.h index 4133cc78b7..33067757af 100644 --- a/include/search_stack.h +++ b/include/search_stack.h @@ -42,6 +42,8 @@ class SEARCH_STACK : public wxPathList, public PROJECT::_ELEM { public: + KICAD_T Type() override { return SEARCH_STACK_T; } + #if defined(DEBUG) void Show( const wxString& aPrefix ) const; #endif diff --git a/pcbnew/pcb_base_frame.cpp b/pcbnew/pcb_base_frame.cpp index ff96f457fd..ce2ec4c511 100644 --- a/pcbnew/pcb_base_frame.cpp +++ b/pcbnew/pcb_base_frame.cpp @@ -172,7 +172,7 @@ FP_LIB_TABLE* PROJECT::PcbFootprintLibs() FP_LIB_TABLE* tbl = (FP_LIB_TABLE*) GetElem( ELEM_FPTBL ); // its gotta be NULL or a FP_LIB_TABLE, or a bug. - wxASSERT( !tbl || dynamic_cast( tbl ) ); + wxASSERT( !tbl || tbl->Type() == FP_LIB_TABLE_T ); if( !tbl ) {