MCPcopy Create free account
hub / github.com/OpenArkStudio/ARK / OnSyncTableAdd

Method OnSyncTableAdd

src/plugin/kernel/src/AFCKernelModule.cpp:782–837  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

780}
781
782int AFCKernelModule::OnSyncTableAdd(const AFGUID& self, const TABLE_EVENT_DATA& event, const ArkDataMask mask_value)
783{
784 // find parent entity
785 auto pEntity = GetEntity(self);
786 if (pEntity == nullptr)
787 {
788 ARK_LOG_ERROR("sync table failed entity do no exist, self={}", self);
789 return -1;
790 }
791
792 auto pTable = pEntity->FindTable(event.table_index_);
793 if (nullptr == pTable)
794 {
795 ARK_LOG_ERROR("sync table failed table do no exist, self={}, table={}", self, event.table_name_);
796 return -1;
797 }
798
799 auto pRow = pTable->FindRow(event.row_);
800 if (nullptr == pRow)
801 {
802 ARK_LOG_ERROR(
803 "sync table failed table row do no exist, self={}, table={}, row={}", self, event.table_name_, event.row_);
804 return -1;
805 }
806
807 AFMsg::pb_entity_table_add pb_data;
808 auto entity_id = self;
809 auto pb_entity = pb_data.mutable_data();
810
811 auto pParentContainer = pEntity->GetParentContainer();
812 if (pParentContainer != nullptr)
813 {
814 if (!TryAddContainerPBEntity(pParentContainer, self, *pb_data.mutable_data(), entity_id, pb_entity))
815 {
816 ARK_LOG_ERROR("sync node failed container entity do no exist, self={}", self);
817 return -1;
818 }
819 }
820
821 AFMsg::pb_entity_data pb_row;
822 if (!RowToPBData(pRow, event.row_, &pb_row))
823 {
824 ARK_LOG_ERROR(
825 "sync table failed table row do no exist, self={}, table={}, row={}", self, event.table_name_, event.row_);
826 return -1;
827 }
828
829 AFMsg::pb_table pb_table;
830 pb_table.mutable_datas_value()->insert({event.row_, pb_row});
831 pb_entity->mutable_datas_table()->insert({event.table_index_, pb_table});
832
833 pb_data.set_id(entity_id);
834 SendSyncMsg(entity_id, mask_value, pb_data);
835
836 return 0;
837}
838
839int AFCKernelModule::OnSyncTableDelete(const AFGUID& self, const TABLE_EVENT_DATA& event, const ArkDataMask mask_value)

Callers

nothing calls this directly

Calls 4

FindRowMethod · 0.80
GetParentContainerMethod · 0.80
FindTableMethod · 0.45
insertMethod · 0.45

Tested by

no test coverage detected