2222#include " dbChip.h"
2323#include " dbHashTable.hpp"
2424#include " odb/dbBlockCallBackObj.h"
25+ #include " odb/dbObject.h"
2526// User Code End Includes
2627namespace odb {
2728template class dbTable <_dbMarkerCategory>;
@@ -775,6 +776,13 @@ dbMarkerCategory* dbMarkerCategory::create(dbChip* chip, const char* name)
775776
776777 parent->marker_categories_map_ [name] = _category->getImpl ()->getId ();
777778
779+ _dbBlock* block = (_dbBlock*) chip->getBlock ();
780+ if (block) {
781+ for (auto cb : block->_callbacks ) {
782+ cb->inDbMarkerCategoryCreate ((dbMarkerCategory*) _category);
783+ }
784+ }
785+
778786 return (dbMarkerCategory*) _category;
779787}
780788
@@ -807,43 +815,19 @@ dbMarkerCategory* dbMarkerCategory::createOrReplace(dbChip* chip,
807815
808816dbMarkerCategory* dbMarkerCategory::create (dbBlock* block, const char * name)
809817{
810- dbChip* chip = block->getChip ();
811- dbMarkerCategory* category = create (chip, name);
812- if (category == nullptr ) {
813- return nullptr ;
814- }
815- for (auto cb : ((_dbBlock*) block)->_callbacks ) {
816- cb->inDbMarkerCategoryCreate (category);
817- }
818- return category;
818+ return create (block->getChip (), name);
819819}
820820
821821dbMarkerCategory* dbMarkerCategory::createOrGet (dbBlock* block,
822822 const char * name)
823823{
824- _dbChip* parent = (_dbChip*) block->getChip ();
825-
826- auto it = parent->marker_categories_map_ .find (name);
827- if (it != parent->marker_categories_map_ .end ()) {
828- return (dbMarkerCategory*) parent->marker_categories_tbl_ ->getPtr (
829- it->second );
830- }
831-
832- return create (block, name);
824+ return createOrGet (block->getChip (), name);
833825}
834826
835827dbMarkerCategory* dbMarkerCategory::createOrReplace (dbBlock* block,
836828 const char * name)
837829{
838- _dbChip* parent = (_dbChip*) block->getChip ();
839-
840- auto it = parent->marker_categories_map_ .find (name);
841- if (it != parent->marker_categories_map_ .end ()) {
842- destroy (
843- (dbMarkerCategory*) parent->marker_categories_tbl_ ->getPtr (it->second ));
844- }
845-
846- return create (block, name);
830+ return createOrReplace (block->getChip (), name);
847831}
848832
849833dbMarkerCategory* dbMarkerCategory::create (dbMarkerCategory* category,
@@ -902,7 +886,7 @@ void dbMarkerCategory::destroy(dbMarkerCategory* category)
902886 if (_category->isTopCategory ()) {
903887 _dbChip* _chip = (_dbChip*) _category->getOwner ();
904888 if (_category->getBlock ()) {
905- for (auto cb : ((_dbBlock*) _category->getBlock () )->_callbacks ) {
889+ for (auto cb : _category->getBlock ()->_callbacks ) {
906890 cb->inDbMarkerCategoryDestroy (category);
907891 }
908892 }
@@ -913,8 +897,10 @@ void dbMarkerCategory::destroy(dbMarkerCategory* category)
913897 _dbMarkerCategory* parent = (_dbMarkerCategory*) _category->getOwner ();
914898
915899 _dbBlock* block = parent->getBlock ();
916- for (auto cb : block->_callbacks ) {
917- cb->inDbMarkerCategoryDestroy (category);
900+ if (block) {
901+ for (auto cb : block->_callbacks ) {
902+ cb->inDbMarkerCategoryDestroy (category);
903+ }
918904 }
919905
920906 parent->categories_hash_ .remove (_category);
0 commit comments