d_storeResult d_storeMMFKernelBackupRestore( d_storeMMFKernel kernel, const d_store store, const d_nameSpace nameSpace) { c_iter groups; d_groupInfo group; d_groupInfo restore, found; d_storeResult result; OS_UNUSED_ARG(store); if(kernel && nameSpace){ groups = ospl_c_select(kernel->backup, 0); group = d_groupInfo(c_iterTakeFirst(groups)); result = D_STORE_RESULT_OK; while(group && (result == D_STORE_RESULT_OK)){ if(d_nameSpaceIsIn(nameSpace, group->partition, group->topic->name)){ restore = c_remove(kernel->backup, group, NULL, NULL); assert(restore); if(restore){ found = d_groupInfo(c_tableInsert(kernel->groups, restore)); if(found != restore){ c_remove(kernel->groups, found, NULL, NULL); c_free(found); found = d_groupInfo(c_tableInsert(kernel->groups, restore)); assert(found == restore); if(found != restore){ result = D_STORE_RESULT_ERROR; } } } else { result = D_STORE_RESULT_ERROR; } } c_free(group); group = d_groupInfo(c_iterTakeFirst(groups)); } c_iterFree(groups); } else { result = D_STORE_RESULT_ILL_PARAM; } return result; }
void v_entryRemoveGroup( v_entry entry, v_group group) { c_query query; q_expr qExpr; c_value params[2]; c_iter groups; v_proxy proxy, proxy2; v_handle handle; assert(entry != NULL); assert(C_TYPECHECK(entry,v_entry)); assert(group != NULL); assert(C_TYPECHECK(group,v_group)); handle = v_publicHandle(v_public(group)); qExpr = (q_expr)q_parse("source.index = %0 and source.server = %1"); params[0] = c_longValue(handle.index); params[1] = c_addressValue(handle.server); query = c_queryNew(entry->groups, qExpr, params); q_dispose(qExpr); groups = c_select(query, 0); c_free(query); assert(c_iterLength(groups) <= 1); proxy = v_proxy(c_iterTakeFirst(groups)); proxy2 = c_remove(entry->groups, proxy, NULL, NULL); c_iterFree(groups); c_free(proxy); c_free(proxy2); }
c_bool v_waitsetDetach ( v_waitset _this, v_observable o) { c_bool result; v_proxy found; findProxyArgument arg; void* userDataRemoved = NULL; assert(_this != NULL); assert(C_TYPECHECK(_this,v_waitset)); arg.observable = v_publicHandle(v_public(o)); arg.proxy = NULL; v_waitsetLock(_this); c_setWalk(_this->observables,findProxy,&arg); if (arg.proxy != NULL) { /* proxy to the observer found */ found = c_remove(_this->observables,arg.proxy,NULL,NULL); assert(found == arg.proxy); c_free(found); } v_waitsetUnlock(_this); result = v_observableRemoveObserver(o,v_observer(_this), &userDataRemoved); v_waitsetClearRemovedObserverPendingEvents(_this, userDataRemoved); /* wakeup blocking threads to evaluate new condition. */ if (v_observerWaitCount(_this)) { v_waitsetTrigger(_this, NULL); } return result; }
void v_subscriberRemoveReader( v_subscriber s, v_reader r) { v_reader found; v_partition d; c_iter iter; assert(s != NULL); assert(r != NULL); iter = c_iterNew(NULL); c_lockWrite(&s->lock); found = c_remove(s->readers,r,NULL,NULL); v_partitionAdminWalk(s->partitions,collectPartitions,iter); while ((d = c_iterTakeFirst(iter)) != NULL) { /* ES, dds1576: The unsubscribe here is performed for all partitions, * however for the K_DATAREADER class not all partitions were * actually subscribed too. Instead of verifying if a partition was * subscribed too or not, the unsubscribe is just executed every time * as this is 'cheaper' then performing the access check again. * If a partition was not subscribed too then the unsubcribe will have no * effect. */ v_readerUnSubscribe(r,d); c_free(d); } c_lockUnlock(&s->lock); c_iterFree(iter); c_free(found); }
d_storeResult d_groupInfoExpungeInstance( d_groupInfo _this, const d_store store, const v_groupAction action) { d_storeResult result; d_instance instance, removed; if(_this && action && action->message){ instance = d_groupInfoLookupInstance(_this, action); if(instance){ removed = c_remove(_this->instances, instance, NULL, NULL); assert(removed == instance); if(removed == instance){ _this->quality = action->actionTime; result = D_STORE_RESULT_OK; } else { result = D_STORE_RESULT_MUTILATED; } c_free(removed); c_free(instance); } else { result = D_STORE_RESULT_OK; } } else { result = D_STORE_RESULT_ILL_PARAM; } return result; }
//SUMMARY // Return the first request in the cache after removing it from the cache, or NULL if the cache is empty struct cache_entry* c_shift() { fprintf(stderr, "c_shift: Called\n"); struct cache_entry* first = c_first(); if (first != NULL) c_remove(first); return first; }
v_reader v_subscriberRemoveShare( v_subscriber _this, v_reader reader) { v_reader found; v_subscriberLockShares(_this); found = c_remove(_this->shares,reader,NULL,NULL); v_subscriberUnlockShares(_this); return found; }
v_entry v_readerRemoveEntry( v_reader r, v_entry e) { v_entry found; assert(C_TYPECHECK(r,v_reader)); v_readerEntrySetLock(r); found = c_keep(c_remove(r->entrySet.entries, e, NULL, NULL)); v_readerEntrySetUnlock(r); return found; }
void v_participantResendManagerRemoveWriter( v_participant p, v_writer w) { C_STRUCT(v_proxy) wp; v_proxy found; wp.source = v_publicHandle(v_public(w)); wp.userData = NULL; c_mutexLock(&p->resendMutex); found = c_remove(p->resendWriters, &wp, NULL, NULL); c_free(found); /* remove local reference transferred from collection */ c_mutexUnlock(&p->resendMutex); }
void v_participantRemove( v_participant p, v_entity e) { v_entity found; assert(p != NULL); assert(C_TYPECHECK(p,v_participant)); assert(e != NULL); assert(C_TYPECHECK(e,v_entity)); c_lockWrite(&p->lock); found = c_remove(p->entities,e,NULL,NULL); c_lockUnlock(&p->lock); c_free(found); }
v_entity v_removeShare( v_kernel kernel, v_entity e) { v_entity found; assert(kernel != NULL); assert(C_TYPECHECK(kernel,v_kernel)); assert(e != NULL); assert(C_TYPECHECK(e,v_entity)); v_lockShares(kernel); found = c_remove(kernel->shares,e,NULL,NULL); v_unlockShares(kernel); return found; }
v_participant v_removeParticipant( v_kernel kernel, v_participant p) { v_participant found; assert(kernel != NULL); assert(C_TYPECHECK(kernel,v_kernel)); assert(p != NULL); assert(C_TYPECHECK(p,v_participant)); c_lockWrite(&kernel->lock); found = c_remove(kernel->participants,p,NULL,NULL); c_lockUnlock(&kernel->lock); return found; }
c_bool v_groupStreamUnSubscribeGroup( v_groupStream stream, v_group group) { v_group found; c_bool result; assert(C_TYPECHECK(stream, v_groupStream)); assert(C_TYPECHECK(group, v_group)); found = c_remove(stream->groups, group, NULL, NULL); if(found == group){ result = TRUE; } else { result = FALSE; } return result; }
void v_dataViewInstanceRemove( v_dataViewInstance instance) { v_dataViewInstance found; assert(C_TYPECHECK(instance,v_dataViewInstance)); if (instance->sampleCount == 0) { CHECK_ZERO_INSTANCE(instance); found = c_remove(v_dataView(instance->dataView)->instances,instance,NULL,NULL); assert(found == instance); instance->dataView = NULL; v_publicFree(v_public(instance)); c_free(instance); } else { CHECK_INSTANCE(instance); } }
d_storeResult d_storeMMFKernelDeleteNonMatchingGroups( d_storeMMFKernel _this, c_string partitionExpr, c_string topicExpr) { d_storeResult result; d_groupInfo group, removed; c_iter groups; c_bool match; if(_this && partitionExpr && topicExpr){ result = D_STORE_RESULT_OK; groups = ospl_c_select(_this->groups, 0); group = d_groupInfo(c_iterTakeFirst(groups)); while(group){ match = d_patternMatch(group->partition, partitionExpr); if(match){ match = d_patternMatch(group->topic->name, topicExpr); } if(!match){ removed = c_remove(_this->groups, group, NULL, NULL); assert(removed == group); if(removed != group){ result = D_STORE_RESULT_MUTILATED; } c_free(removed); } c_free(group); group = d_groupInfo(c_iterTakeFirst(groups)); } c_iterFree(groups); } else { result = D_STORE_RESULT_ILL_PARAM; } return result; }
v_topic v_lookupTopic( v_kernel kernel, const char *name) { v_topic topicFound; C_STRUCT(v_topic) dummyTopic; c_base base = c_getBase(c_object(kernel)); /* Create a dummy topic for look-up */ memset(&dummyTopic, 0, sizeof(dummyTopic)); ((v_entity)(&dummyTopic))->name = c_stringNew(base,name); topicFound = NULL; c_lockRead(&kernel->lock); /* This does not remove anything because the alwaysFalse function always * returns false */ c_remove(kernel->topics, &dummyTopic, alwaysFalse, &topicFound); c_lockUnlock(&kernel->lock); c_free(((v_entity)(&dummyTopic))->name); return topicFound; }
v_result v_deliveryWaitListFree( v_deliveryWaitList _this) { v_deliveryWaitList found; v_result result; assert(C_TYPECHECK(_this,v_deliveryWaitList)); if (_this) { /* lookup or create a writer specific admin. */ found = c_remove(v_deliveryGuard(_this->guard)->waitlists, _this, NULL, NULL); assert(found == _this); assert(c_refCount(found) == 2); c_free(found); c_free(_this); result = V_RESULT_OK; } else { result = V_RESULT_ILL_PARAM; } return result; }
v_topic v_removeTopic( v_kernel kernel, v_topic topic) { v_topic found; assert(kernel != NULL); assert(C_TYPECHECK(kernel,v_kernel)); assert(topic != NULL); assert(C_TYPECHECK(topic,v_topic)); c_lockWrite(&kernel->lock); found = c_remove(kernel->topics,topic,NULL,NULL); c_lockUnlock(&kernel->lock); if (found == NULL) { return NULL; } if (v_objectKind(found) != K_TOPIC) { return NULL; } return found; }
void v_dataViewInstanceRemove( v_dataViewInstance instance) { v_dataView dataView; v_dataViewInstance found; assert(C_TYPECHECK(instance,v_dataViewInstance)); if (instance->sampleCount == 0) { CHECK_ZERO_INSTANCE(instance); if (v_objectKind (instance) == K_DATAVIEWINSTANCE) { dataView = v_dataView(v_instanceEntity(instance)); found = c_remove(dataView->instances,instance,NULL,NULL); assert(found == instance); OS_UNUSED_ARG(found); v_publicFree(v_public(instance)); c_free(instance); } } else { CHECK_INSTANCE(instance); } }
v_partition v_removePartition( v_kernel kernel, v_partition partition) { v_partition found; assert(kernel != NULL); assert(C_TYPECHECK(kernel,v_kernel)); assert(partition != NULL); assert(C_TYPECHECK(partition,v_partition)); c_lockWrite(&kernel->lock); found = c_remove(kernel->partitions,partition,NULL,NULL); c_lockUnlock(&kernel->lock); if (found == NULL) { return NULL; } if (v_objectKind(found) != K_DOMAIN) { return NULL; } return found; }
void add_base_prop_view( UI::ObjectView& object_view, unsigned const index ) { auto const root = object_view.root(); auto& session = object_view.m_session; auto& object = object_view.m_object; // Slug property auto field_slug = UI::Field::make(root, object.slug()); auto& field_slug_ref = *field_slug; field_slug->geometry().set_sizing(UI::Axis::horizontal, UI::Axis::horizontal); UI::bind_field_describer(field_slug, "slug"); field_slug->signal_user_modified.bind([&session, &object]( UI::Field::SPtr const& field_slug, bool const accept ) { if (accept) { // NB: signal_notify_command handles result Hord::Cmd::Object::SetSlug{session}( object, field_slug->text() ); } else { field_slug->set_text(object.slug()); } }); // Metadata property auto grid_metadata = UI::TableGrid::make( root, session, object, object.metadata().table() ); auto& grid_metadata_ref = *grid_metadata; grid_metadata->signal_event_filter.bind([&session, &object, &grid_metadata_ref]( UI::Widget::SPtr const& widget, UI::Event const& event ) -> bool { if (grid_metadata_ref.has_input_control()) { return false; } else if (event.type != UI::EventType::key_input) { return s_grid_metadata_describer(widget, event); } auto const* kim_match = key_input_match(event.key_input, s_kim_erase_metafield); if (kim_match) { Hord::Cmd::Object::RemoveMetaField c_remove{session}; if (grid_metadata_ref.row_count() <= 0) { return false; } if (&s_kim_erase_metafield[0] != kim_match) { c_remove(object, grid_metadata_ref.m_cursor.row); } for (signed index = grid_metadata_ref.row_count() - 1; index >= 0; --index) { if (grid_metadata_ref.m_sel[index]) { c_remove(object, index); } } return true; } else if (event.key_input.cp == 'i' || event.key_input.cp == 'n') { Hord::Cmd::Object::SetMetaField{session}( object, "new" + std::to_string(grid_metadata_ref.row_count()), {}, true ); return true; } return false; }); grid_metadata->signal_cell_edited.bind([&session, &object]( Hord::Data::Table::Iterator& it, UI::index_type col, String const& string_value, Hord::Data::ValueRef& new_value ) { if (col == 0) { Hord::Cmd::Object::RenameMetaField{session}( object, it.index, string_value ); } else if (col == 1) { Hord::Cmd::Object::SetMetaField{session}( object, it.index, new_value ); } }); auto view = UI::PropView::make(root, "base", UI::Axis::vertical); view->signal_notify_command.bind([&object, &field_slug_ref, &grid_metadata_ref]( UI::View* const /*parent_view*/, UI::PropView& /*prop_view*/, Hord::Cmd::UnitBase const& command, Hord::Cmd::TypeInfo const& type_info ) { if (command.object_id() != object.id()) { return; } switch (type_info.id) { case Hord::Cmd::Object::SetSlug::COMMAND_ID: field_slug_ref.set_text(object.slug()); break; } if (!command.ok_action()) { return; } switch (type_info.id) { case Hord::Cmd::Object::SetMetaField::COMMAND_ID: { auto const& c = static_cast<Hord::Cmd::Object::SetMetaField const&>(command); if (c.created()) { grid_metadata_ref.insert_before(c.field_index(), 1); } else { grid_metadata_ref.notify_cell_changed(c.field_index(), 1); } } break; case Hord::Cmd::Object::RenameMetaField::COMMAND_ID: { auto const& c = static_cast<Hord::Cmd::Object::RenameMetaField const&>(command); grid_metadata_ref.notify_cell_changed(c.field_index(), 0); } break; case Hord::Cmd::Object::RemoveMetaField::COMMAND_ID: { auto const& c = static_cast<Hord::Cmd::Object::RemoveMetaField const&>(command); grid_metadata_ref.erase(c.field_index(), 1); } break; } }); view->push_back(std::move(field_slug)); view->push_back(std::move(grid_metadata)); object_view.add_prop_view(std::move(view), index); }